Files
Main/Assets/Launcher/ExternalLibs/StencilShadow/FStencilShadowScript.cs
2025-01-25 04:38:09 +08:00

48 lines
1.3 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Thousandto.Launcher.ExternalLibs
{
//使用Stencil来实现阴影的脚本
public class FStencilShadowScript : MonoBehaviour
{
//接受阴影的面板
public Transform ReceiverPanel;
//灯光位置方向
//public Transform LightTransform;
// Use this for initialization
void Start()
{
if (ReceiverPanel == null)
ReceiverPanel = transform;
}
// Update is called once per frame
void LateUpdate()
{
UpdateLightDir();
}
void UpdateLightDir()
{
/*
Vector4 source;
if (LightTransform != null)
{
Vector3 direction = LightTransform.forward;
source = new Vector4(direction.x, direction.y, direction.z, 0.0f);
Shader.SetGlobalVector("_LightDir", source);
Debug.Log(source);
}
*/
if (ReceiverPanel != null)
{
Shader.SetGlobalMatrix("_World2Receiver", ReceiverPanel.worldToLocalMatrix);
}
//Shader.SetGlobalVector("_ShadowColor", shadowColor);
}
}
}