Need some help with simle shader
Hello everyone. I'm zero in shader writing, but I need one for some tests. It must work like this : If the surface normal is facing the light source, it’s lit (Color1). If it’s facing more than 90 degrees away from the light source, it’s not (Color2). Can someone help me?
Answer by UnityCoach · Feb 26, 2017 at 10:23 AM
Sounds like you're looking for a dot product.
Have a look at these examples.
It would be nice, but I know nothing about basic shader writing, so I need raw code. It would be nice, if you can give it to me.
There are several shader languages in Unity.
If you want to leverage the lighting system, you want to write a surface shader, which is specific to Unity.
If you want to have complete control over the pixel colours, you want to write a fragment shader, which is a more general approach to shader writing.
The sample Shader "Lit/Simple Diffuse" from the latter does what you want, I believe.
Your answer
Follow this Question
Related Questions
Nature/Soft Occlusion Shader Help 2 Answers
Make shader from Blender nodes 0 Answers
Very basic shader problem 0 Answers
Problem with Standard shader transparency 0 Answers
Rendering Shaders on Windows does not work but does on Mac (Unity 5.5.0f3) 0 Answers