Is there any way to manually specify view and model matrices?
I know Three.js is not supposed to be used in this way, but I am currently developing some educational materials to teach a typical computer graphics pipeline and would like to explicitly supply model/view/projection
matrices to a shader. While I understood which matrices are model/view/projection
matrices in Three.js from this issue, I haven't been able to find a good way to manually control them.
So far, I was able to specify the projection matrix by using camera.projectionMatrix.makePerspective()
and the model matrix by using applyMatrix()
. Actually, applyMatrix()
is not ideal from the educational point of view because it internally decomposes the matrix to position, quaternion and scale and probably reconstructs the model matrix from those values and supply it to a shader.
One possible solution is to use ShaderMaterial()
and specify all of the three matrices as uniforms. However, I may want to avoid it because they are also passed to a shader implicitly and the name "material" might confuse students.
Does anybody have suggestions to do this kind of stuff in Three.js?
THREE.ShaderMaterial
orTHREE.RawShaderMaterial
, you can always alias the object:THREE.CustomShader = THREE.ShaderMaterial;
,var myShader = new THREE.CustomShader();
– TheJim01RawShaderMaterial
should not inject anything for you. – pailheadShaderMaterial
would consist of two different shaders. But together, they make a material in three. – pailhead