ShaderMaterial extensions

Hey there, an enhancement request. I’m using ShaderMaterials in a few places and recently found myself in need of those tasty tasty GL extensions. However, sticking them in front of the shader string doesn’t really work well, as there is additional stuff that THREE adds before those. So the ask is this: add another parameter like “defines” and “uniforms” that takes a hash of extensions or something similar, allowing enabling of extensions. Here’s the sadness:

THREE.WebGLShader: gl.getShaderInfoLog() fragment WARNING: 0:16: '
' : extension directive should occur before any non-preprocessor tokens 
 1: precision highp float;
2: precision highp int;
3: #define SHADER_NAME ShaderMaterial
4: #define MAX_DIR_LIGHTS 1
5: #define MAX_POINT_LIGHTS 0
6: #define MAX_SPOT_LIGHTS 0
7: #define MAX_HEMI_LIGHTS 0
8: #define MAX_SHADOWS 0
9: #define GAMMA_INPUT
10: #define GAMMA_OUTPUT
11: #define GAMMA_FACTOR 2
12: #define USE_LIGHTMAP
13: uniform mat4 viewMatrix;
14: uniform vec3 cameraPosition;
15: 
16: #extension GL_OES_standard_derivatives : enable

Author: Fantashit

1 thought on “ShaderMaterial extensions

  1. Maybe we can add a extensions array to ShaderMaterial?

    material.extensions.push( 'GL_EXT_frag_depth' );

    And then we convert them to #extension GL_EXT_frag_depth : enable?

Comments are closed.