1
votes

I have a Collada object which i load per Three.js into my scene. Now I want to change some vertex positions of the model in the vertex shader, which is no problem. But with this I have to skip the exported collada material and take a ShaderMaterial. The problem is now that I have to calculate the complete lighting of the scene in my fragment shader. Before, with the collada material, the complete lighting was calculated by the framework by using a directional light and a hemisphere light.

So my question is, if there is a solution where I can leave the fragmentShader untouched and all the colors are calculated as if I would use no ShaderMaterial.

I tried to use THREE.ShaderLib and pass only the fragmentShader of the phong shader and my own vertexShader. But this gave only errors that not the same varyings are defined in both shaders.

1

1 Answers

1
votes

Unfortunately, you are correct. You have to create your own ShaderMaterial, and it will be tedious to incorporate scene lighting.

If your scene lighting is not that important, you can hack in some ambient light and a single light at the camera location in your fragment shader.

If your scene lighting is important, then you need to set the ShaderMaterial parameter lights: true, and you will have access to the scene light uniforms in your vertex and fragment shaders.

three.js r.63