Issue on using an extension for GLSL when updating three.js

Viewed 218

I'm currently upgrading three.js from a 2015 version, to the latest! However it seems that the GLSL shaders work in a slightly different manner. As a result, when trying to add an extension with #extension GL_OES_standard_derivatives : enable it seems to error and prevent the shader from being used. See below for the stack trace and the code pen for an example of the shader i'm using.

THREE.WebGLShader: gl.getShaderInfoLog() fragment
ERROR: 0:89: '
' : extension directive must occur before any non-preprocessor tokens in ESSL31: #version 300 es

https://codepen.io/redrubia/pen/ZEezjVw

1 Answers

It's not necessary to manually add #extension GL_OES_standard_derivatives : enable to your shader code. Instead, extensions can be managed over the material object. Please use this approach:

material.extensions.derivatives = true;
Related