question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ShaderMaterial: Extension fragDepth no longer working.

See original GitHub issue
Description 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:closed
  • Created 4 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
Mardoniscommented, Feb 7, 2020

Ok thank you, I will try and look more into this.

0reactions
Mugen87commented, Feb 7, 2020

Do you mean the live examples on threejsfundamentals? Well, I’ve changed one example to import * as THREE from 'https://threejs.org/build/three.module.js'; which means the latest version R113 is now used. I see no warnings after doing this

Also note that this issue only affects custom materials which enable a specific extension. This is not relevant for the examples at threejsfundamentals.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found