48 lines
1.3 KiB
C#
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);
|
|
}
|
|
}
|
|
} |