- Home /
Change colour on angle of viewing
Does anyone know how to do that? What I mean is that if you are looking at a surface straight on (90 degrees) it looks, say, red. But as the angle changes, it changes colour through a variety of other colours.
I think a raycast to the surface to compute the angle is the solution.
With this value, you can impact the color of the surface.
Sorry for no more informations, I'm not a pro with raycasting yet :)
$$anonymous$$aybe someone else would help you more with a code sample ...
Answer by Jessy · May 15, 2013 at 01:32 PM
In your shader, use a lookup texture. The lookup is the dot product of the surface normal and the viewing direction.
The "Toon Ramp" example here does something similar; it just uses the lighting direction instead of the viewing direction. http://docs.unity3d.com/Documentation/Components/SL-SurfaceShaderLightingExamples.html
Your answer
Follow this Question
Related Questions
How to change the colour of my car? 1 Answer
When complete level change colour of ball. 1 Answer
Pointlight changing colour with distance 2 Answers
Duplicated objects, different colors 1 Answer