The suggested reading regarding THREE.Js RawShaderMaterial states:
Default uniforms and attributes are not automatically included in the GLSL shader code.
Nevertheless, I have successfully executed the following shader using a rawShaderMaterial:
<script type="x-shader/x-vertex" id="vertexShader">
precision mediump float;
precision mediump int;
uniform mat4 modelViewMatrix;
uniform mat4 projectionMatrix;
attribute vec3 position;
attribute vec4 color;
varying vec3 vPosition;
varying vec4 vColor;
void main() {
vPosition = position;
vColor = color;
gl_Position = projectionMatrix *
modelViewMatrix *
vec4(position.x, position.y, position.z, 1.0);
}
Even though the modelViewMatrix
or projectionMatrix
are not explicitly defined anywhere. Could it be that certain uniforms are indeed being transmitted to the rawshader material?