mirror of
https://github.com/DeMuenu/MoonlightVRC.git
synced 2025-12-13 11:33:54 +00:00
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.
57 lines
1.6 KiB
C#
57 lines
1.6 KiB
C#
|
|
using System.Security.Permissions;
|
|
using UdonSharp;
|
|
using UnityEngine;
|
|
using VRC.SDKBase;
|
|
using VRC.Udon;
|
|
|
|
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;
|
|
|
|
|
|
foreach (Renderer mat in rendererTargets)
|
|
{
|
|
if (mat == null) continue;
|
|
mat.GetPropertyBlock(_mpb);
|
|
_mpb.SetMatrix(propertyName + "_" + (string)shadowcasterIndex, w2l);
|
|
mat.SetPropertyBlock(_mpb);
|
|
}
|
|
|
|
}
|
|
}
|