- Home /
Compute shader: Why colors inverse due to proximity to the object?
Hello everybody,
I'm working with an existing shader, which simulates fluids. I need the fluids to look as if they are "sandy", so I've added a normal map to the shader.
float4 frag(v2f IN) : COLOR
{
half4 bump = tex2D(_BumpMap, IN.uv);
half2 distorion = UnpackNormal(bump).rg;
IN.uvgrab.xy += distorion * _Magnitude;
fixed4 col = tex2Dproj(_GrabTexture, UNITY_PROJ_COORD(IN.uvgrab));
int x = (int)(IN.uv.x*_Size.x);
int y = (int)(IN.uv.y*_Size.y);
return _ColourRamp[clamp(_Particles[y * _Size.x + x], 0.0, 255.0)] * col;
}
In this frag function I apply the normal map together with the colors, by multiplying the returned color by the normal col variable.
This is the outcome:
You can see two images of the same object but with different colors. The first (red tinted) image is taken from a very close angle - and it actually looking as expected.
The second image is taken from a far angle, and is looking like the colors are inverse.
Why do I get this color inversion behavior?
Please help!
Your answer
Follow this Question
Related Questions
_CameraGBufferTexture3 output in shaderlab 0 Answers
Material doesn't have a color property '_Color' 4 Answers
Invert Color Shader (without see-through) 0 Answers
Shader that does per Vert alpha with co 0 Answers
Projected Texture Shader Issues 1 Answer