Add support for multiple shadowcaster planes

Extended ShadowcasterUpdater and shaders to handle multiple shadowcaster planes by introducing indexed properties and logic for two shadowcaster sets. Updated property names and shader logic to support per-index shadowcaster textures, colors, and brightness, enabling more flexible shadow casting in scenes.
This commit is contained in:
DeMuenu
2025-09-30 12:59:56 +02:00
parent 7a3065211e
commit fd5eb748e2
4 changed files with 74 additions and 25 deletions

View File

@@ -9,15 +9,36 @@ public class ShadowcasterUpdater : UdonSharpBehaviour
{
public Renderer[] rendererTargets;
public Texture2D ShadowcasterTexture;
public Color OutsideColor = Color.white;
public Color TextureColor = Color.white;
public float MinBrightness = 0.0f;
public int shadowcasterIndex = 1;
public string propertyName = "_Udon_WorldToLocal";
private MaterialPropertyBlock _mpb;
void Start()
{
_mpb = new MaterialPropertyBlock();
ApplyTextureData();
}
public void ApplyTextureData()
{
foreach (Renderer mat in rendererTargets)
{
if (mat == null) continue;
mat.GetPropertyBlock(_mpb);
_mpb.SetTexture("_Udon_ShadowcasterTex" + "_" + (string)shadowcasterIndex, ShadowcasterTexture);
_mpb.SetColor("_Udon_shadowCasterColor" + "_" + (string)shadowcasterIndex, TextureColor);
_mpb.SetColor("_Udon_OutSideColor" + "_" + (string)shadowcasterIndex, OutsideColor);
_mpb.SetFloat("_Udon_MinBrightnessShadow" + "_" + (string)shadowcasterIndex, MinBrightness);
mat.SetPropertyBlock(_mpb);
}
}
void LateUpdate()
{
var w2l = transform.worldToLocalMatrix;
@@ -27,7 +48,7 @@ public class ShadowcasterUpdater : UdonSharpBehaviour
{
if (mat == null) continue;
mat.GetPropertyBlock(_mpb);
_mpb.SetMatrix(propertyName, w2l);
_mpb.SetMatrix(propertyName + "_" + (string)shadowcasterIndex, w2l);
mat.SetPropertyBlock(_mpb);
}