How can I enable an extension on a Three.js shader?
My code so far:
getting extension:
var domElement = document.createElement( 'canvas' );
var gl = domElement.getContext('webgl') || domElement.getContext('experimental-webgl');
gl.getExtension('OES_standard_derivatives');
on my shader:
fragmentShader: [
"#extension GL_OES_standard_derivatives : enable",
"code..."
]...
The console output:
WARNING: 0:26: extension 'GL_OES_standard_derivatives' is not supported
ERROR: 0:32: 'dFdx' : no matching overloaded function found
ERROR: 0:32: '=' : cannot convert from 'const mediump float' to '2-component vector of float'
ERROR: 0:33: 'dFdy' : no matching overloaded function found
ERROR: 0:33: '=' : cannot convert from 'const mediump float' to '2-component vector of float'
After reading this issue on github, I tried this example: From http://jsfiddle.net/VJca4/ I get these errors
WARNING: 0:27: extension 'GL_OES_standard_derivatives' is not supported
ERROR: 0:30: '=' : cannot convert from 'const mediump float' to '2-component vector of float'
ERROR: 0:31: 'dFdx' : no matching overloaded function found
ERROR: 0:31: '=' : cannot convert from 'const mediump float' to '2-component vector of float'
You should also be able to do this:
renderer.context.getExtension('OES_standard_derivatives');
Found the error. You have to use the renderer's dom element:
var gl = renderer.domElement.getContext('webgl') ||
renderer.domElement.getContext('experimental-webgl');
gl.getExtension('OES_standard_derivatives');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With