Reputation: 1073
I am trying to run the following simple shader with three.js
mat = new THREE.ShaderMaterial({
uniforms: {
color: { type: 'v3', value: new THREE.Color(0xcccccc) }
},
vertexShader: 'attribute vec3 vert;\n'
+ 'void main() {\n'
+ ' gl_Position = vec4(vert, 1.0);\n'
+ '}',
fragmentShader: 'uniform vec3 color;\n'
+ 'void main() {\n'
+ ' gl_FragColor = vec4(color,1);\n'
+ '}'
})
The shaders compile but the object that has this material is invisible.
This should display the object in a constant light grey color.
When I run this with kick.js shader editor it works as expected.
Predefined materials all work great.
Am I missing something?
Upvotes: 0
Views: 1139
Reputation: 12642
Your vertex shader should be:
// Multiply each vertex by the model-view matrix and the projection matrix
// (both provided by Three.js) to get a final vertex position.
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
Upvotes: 3