mirror of
https://github.com/DeMuenu/MoonlightVRC.git
synced 2025-12-13 11:33:54 +00:00
Add shadowcaster support to lighting and shaders
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.
This commit is contained in:
35
Scripts/ShadowcasterUpdater.cs
Normal file
35
Scripts/ShadowcasterUpdater.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user