Data texture with LuminanceFormat used as alphaMap broken from r136
See original GitHub issueDescribe the bug
After upgrading from v135 to latest the data texture I was using is now logging WebGL warnings to console, looking through the changelog there doesn’t seem to be any breaking changes I should be aware of outside of setting needsUpdate
. The change that affected this was introduced in v136.
WebGL warning: texStorage(Multisample)?: internalformat: Invalid enum value LUMINANCE
WebGL warning: texSubImage: The specified TexImage has not yet been specified.
Code
import {
DataTexture,
LuminanceFormat,
UnsignedByteType,
} from 'three';
const primaryMask = new Uint8Array(2500);
const texture = new DataTexture(
primaryMask,
50,
50,
LuminanceFormat,
UnsignedByteType
);
texture.needsUpdate = true;
In v135 - nothing logged to console, alphaMap working as intended (partial transparent) In v136 - two warnings logged to console, alphaMap not working as intended (everything transparent)
Live example
- r135 WORKS https://codesandbox.io/s/wild-microservice-7yobcp?file=/src/index.js
- r139.1 DOES NOT WORK https://codesandbox.io/s/crazy-mcclintock-09k4pb?file=/src/index.js
Expected behavior
No warnings logged to console, transparency working as intended.
Platform:
- Device: Desktop
- OS: MacOS
- Browser: Firefox
- Three.js version: r136
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:5
Top Results From Across the Web
Use WebGL texture as a Three.js Texture map - Stack Overflow
I've already tried this solution. But it seems like THREE.Texture() doesn't grab data from raw WebGL texture. javascript · three.
Read more >A Brief Introduction to Texture Mapping | Discover three.js
Textures are used to store surface details of the objects in our scenes, such as color, ... Data representing the UV mapping is...
Read more >WebGL 3D - Data Textures
Let's create a 3x2 pixel LUMINANCE texture. Because it's LUMINANCE texture there is only 1 value per pixel and it is repeated for...
Read more >Animations with alpha textures in Three.js
Here's the image we're going to use: 16x16 px black and white texture var alphaMap = new THREE.TextureLoader().load('alpha.png'); material.
Read more >Three js alpha maps | Dustin John Pfister at github pages
CanvasTexture method as a way to create a texture to use as an alpha map. This kind of thing can also be used...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@madou You can use this pattern to support a single-channel alpha map texture using
RedFormat
with three.js r139.You could also use
NodeMaterial
, I assume.Please keep in mind that
gl.LUMINANCE
is problematic since at least one WebGL implementation (ANGLE) has to expand texture data to four channels to make luminance textures work with Direct 3D. This is not necessary when usingRGFormat
(orRedFormat
).I suggest you ask this question at the forum or stackoverflow. If it turns out to be a problem of
three.js
, we can reopen this issue.