- Home /
Separate texture coordinates in shaders
Hello, I have been trying to learn CG shaders, my goal is to set up a additive shader that has a detail texture.
I have made the modifications for a separate Detail texture property. And have the detail multiplied by the particle texture.. This works fine, except both the detail and the particle textures have the same coordinates.
Here is the line of code that I changed in the default additive shader:
return 2.0f * i.color * _TintColor * tex2D(_MainTex, i.texcoord) * tex2D(_Detail, i.texcoord);
I am guessing the problem is because both the detail and the particle texture use "i.texcoord".
Thanks
Answer by ScroodgeM · Jul 20, 2012 at 07:36 AM
method 1. use a custom offset like this:
return 2.0f * i.color * _TintColor * tex2D(_MainTex, i.texcoord) * tex2D(_Detail, i.texcoord * (-0.23));
method 2. use second uv set from model. this must be declared in shader first and then just use i.texcoord2
Your answer
![](https://koobas.hobune.stream/wayback/20220613064908im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Uniform variable operations not for every vertex and fragment. 0 Answers
Weird shader error X5204 - read of uninitialized components 1 Answer
Porting from ShaderToy(GLSL) to shaderlab(HLSL/CG) unity not giving me the desired result. 2 Answers
ShaderLab builtin lighting properties are not correct? 0 Answers
Fragment shader alpha 0 Answers