I have noticed that texture have a field names “value” in all the shaders but it seems that this fields is never used.
Example :
tDiffuse: { type: "t", value: 0, texture: null },
What is the purpose of this field ?
Thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It is used.
It defines in which slot a texture needs to be stored. A slot is a place where a shaderprogram can access the texture trough samplers. This is indeed mostly 0 becuase we use only 1 texture in a shader. But if we wanted multiple textures being accessed in the shader the then the value needs to be changed to the number of slots nessecary.
Like you can see here:
https://github.com/gero3/three.js/blob/master/src/renderers/WebGLShaders.js#L1392-1397
map is the first texture. (slot 0)
envMap is the second texture. (slot 1)
lightMap is the third texture. (slot 2)
For every texture you use in the shaderprogram , you must choose a new slot.