我们创建了 Fontainebleau 演示来说明摄影photogrammetry流程和 LayeredLit 着色器的使用。
您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 

63 行
2.2 KiB

using UnityEngine;
using UnityEngine.Playables;
using UnityEngine.Rendering;
using UnityEngine.Rendering.HighDefinition;
public class ShadowsPlayableMixer : PlayableBehaviour
{
// Called each frame the mixer is active, after inputs are processed
public override void ProcessFrame(Playable handle, FrameData info, object playerData)
{
if (playerData == null)
return;
var volume = playerData as Volume;
//var camera = Camera.main;
//if (camera == null || Camera.main.transform.parent.gameObject.tag == "Player")
// return;
//var volume = camera.GetComponent<Volume>();
HDShadowSettings m_shadowSettings;
var profile = Application.isPlaying
? volume.profile
: volume.sharedProfile;
if (!profile.Has<HDShadowSettings>())
return;
float newMaxDistance = 0;
int newCascadeCount = 0;
float newSplit0 = 0f;
float newSplit1 = 0f;
float newSplit2 = 0f;
var count = handle.GetInputCount();
for (var i = 0; i < count; i++)
{
var inputHandle = handle.GetInput(i);
var weight = handle.GetInputWeight(i);
if (inputHandle.IsValid() &&
inputHandle.GetPlayState() == PlayState.Playing &&
weight > 0)
{
var data = ((ScriptPlayable<ShadowsPlayable>)inputHandle).GetBehaviour();
if (data != null)
{
newMaxDistance = data.maxDistance * weight;
newCascadeCount = Mathf.FloorToInt((float)data.cascadeCount * weight);
newSplit0 = data.split0 * weight;
newSplit1 = data.split1 * weight;
newSplit2 = data.split2 * weight;
}
}
}
profile.TryGet<HDShadowSettings>(out m_shadowSettings);
m_shadowSettings.maxShadowDistance.value = newMaxDistance;
m_shadowSettings.cascadeShadowSplitCount.value = newCascadeCount;
m_shadowSettings.cascadeShadowSplit0.value = newSplit0;
m_shadowSettings.cascadeShadowSplit1.value = newSplit1;
m_shadowSettings.cascadeShadowSplit2.value = newSplit2;
}
}