ShaderMaterial: Extension fragDepth no longer working.
See original GitHub issueDescription of the problem
In the latest version of three.js, the fragDepth extension no longer works.
Here is an example that simply sets the fragment depth in version r110, which works fine:
https://jsfiddle.net/5o9s8kru/
Here is a corresponding example using version r113:
https://jsfiddle.net/5o9s8kru/1/
The relevant shader material is set up as follows:
var material = new THREE.ShaderMaterial( {
extensions: {
fragDepth: true,
},
fragmentShader: `
void main() {
gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
gl_FragDepthEXT = 0.5;
}
`,
vertexShader: `
void main() {
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0 );
}`
} );
In the most recent version, the shader compilation fails with
ERROR: 0:110: 'GL_EXT_frag_depth' : extension is disabled
The error is caused by a typo introduced in https://github.com/mrdoob/three.js/pull/18279, where fragDepth
is replaced with frawbuffer
:
https://github.com/mrdoob/three.js/pull/18279#discussion_r376431575
Three.js version
- Dev
- r113
Browser
- All of them
- Chrome
- Firefox
- Internet Explorer
OS
- All of them
- Windows
- macOS
- Linux
- Android
- iOS
Issue Analytics
- State:
- Created 4 years ago
- Comments:5
Top Results From Across the Web
ShaderMaterial#extensions – three.js docs
As of THREE r77, WebGLRenderTarget or WebGLCubeRenderTarget instances are no longer supposed to be used as uniforms. Their texture property must be used...
Read more >Is gl_FragDepthEXT supported by Three.js? - Stack Overflow
ShaderMaterial the program string is partly auto-generated ... null if the extension is not supported, // or otherwise an extension object ...
Read more >ShaderMaterial should be able to load shaders with .glsl ...
Simple request purely for syntax highlighting. ShaderMaterial accepts a string as a third argument to load external files as long as they ...
Read more >WebGL2 from WebGL1
Many extensions are a standard part of WebGL2 and so not available as extensions. ... tell user they don't have the required extension...
Read more >How to use the three.ShaderMaterial function in three - Snyk
ShaderMaterial examples, based on popular ways it is used in public projects. ... extensions: { derivatives: true, drawBuffers: false, fragDepth: false, ...
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
Ok thank you, I will try and look more into this.
Do you mean the live examples on
threejsfundamentals
? Well, I’ve changed one example toimport * as THREE from 'https://threejs.org/build/three.module.js';
which means the latest versionR113
is now used. I see no warnings after doing thisAlso note that this issue only affects custom materials which enable a specific extension. This is not relevant for the examples at
threejsfundamentals
.