Is there any way to change render face option through script during runtime?

Hi! Im currently trying to use urp shader/lit right. What Im looking for is change renderface of shader from “front” to “both” through the unity script during the runtime. Is there any way? Thank you .

Hello, the URP/Lit shader Render Face setting is controlled by a property called “_Cull”.
You can do material.SetFloat("_Cull", value) to change the state in runtime. value 0 is both, 1 is back, 2 is front.

If you are calling material.SetFloat() a lot, then it’s better to use a identifier for the _Cull property:

private static readonly int m_CullId = Shader.PropertyToID("_Cull");
material.SetFloat(m_CullId, value);
1 Like

I would also say to use the CullMode enum (at UnityEngine.Rendering.CullMode) so you dont have to remember the int! (SetInteger works also)

using UnityEngine.Rendering
...
...
private static readonly int m_CullId = Shader.PropertyToID("_Cull");
...
public void SetCullMode(CullMode cullMode)
{
    _material.SetInteger(m_CullId, (int)cullMode);
}
1 Like

Thank you for your help! :slight_smile:

How do find out that _renderface is really _cull from the code? I can’t see the _renderface at all in the lit shader.