mirror of
https://github.com/DeMuenu/MoonlightVRC.git
synced 2025-12-12 19:13:56 +00:00
Introduces shadowcaster support by adding shadow map index fields to light data, updating PlayerPositionsToShader and LightdataStorage to handle shadow map indices, and extending the shader and its includes to sample shadowcaster planes. Adds ShadowcasterUpdater script and editor preview for updating world-to-local matrices, and updates relevant arrays and property handling throughout the codebase. Also adds a sample plane mesh for shadowcasting.
36 lines
705 B
C#
36 lines
705 B
C#
|
|
using System.Security.Permissions;
|
|
using UdonSharp;
|
|
using UnityEngine;
|
|
using VRC.SDKBase;
|
|
using VRC.Udon;
|
|
|
|
public class ShadowcasterUpdater : UdonSharpBehaviour
|
|
{
|
|
|
|
public Renderer[] rendererTargets;
|
|
public string propertyName = "_Udon_WorldToLocal";
|
|
private MaterialPropertyBlock _mpb;
|
|
|
|
void Start()
|
|
{
|
|
_mpb = new MaterialPropertyBlock();
|
|
}
|
|
|
|
|
|
void LateUpdate()
|
|
{
|
|
var w2l = transform.worldToLocalMatrix;
|
|
|
|
|
|
foreach (Renderer mat in rendererTargets)
|
|
{
|
|
if (mat == null) continue;
|
|
mat.GetPropertyBlock(_mpb);
|
|
_mpb.SetMatrix(propertyName, w2l);
|
|
mat.SetPropertyBlock(_mpb);
|
|
}
|
|
|
|
}
|
|
}
|