- Home /
How do i turn off "Receive Shadows" and "Cast Shadows" in a Shader Script??
How do i turn off "Receive Shadows" and "Cast Shadows" in a Shader Script??
Technically speaking a shader and a script are 2 different things. I take it you mean the shader, however we can't really answer this question without knowing your shader, i.e. is it a surface shader, how is it calculating lighting, etc.
Answer by Happy-Zomby · Nov 01, 2016 at 05:26 PM
Hi, I believe you should look at:
GetComponent<Renderer>().shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.ShadowsOnly;
GetComponent<Renderer>().receiveShadows = true;
see here for details on shadow casting mode https://docs.unity3d.com/ScriptReference/Rendering.ShadowCastingMode.html
hope that helps,
No. It's in a script that references the mesh renderer of an object, which is the correct way to do it. Don't know who down voted this.
Although setting receiveShadows off didnt solve my problem, I wanted to share that you can do this by setting inspector to debug mode.
This way, you wont need the script, unless you need it.