mirror of
https://github.com/DeMuenu/MoonlightVRC.git
synced 2025-12-13 11:33:54 +00:00
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:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user