材质更新
using System.Collections.Generic;
using UnityEngine;
namespace Nahida
{
public class MaterialUpdater : MonoBehaviour
{
[SerializeField]
private GameObject m_HeadBone;
[SerializeField]
private Vector3 m_HeadDirection = Vector3.up;
[SerializeField]
private List<SkinnedMeshRenderer> m_FaceRenderers;
private void Update()
{
if (m_FaceRenderers == null || m_HeadBone == null)
{
return;
}
Vector3 direction = m_HeadBone.transform.rotation * m_HeadDirection;
foreach (var renderer in m_FaceRenderers)
{
foreach (var material in renderer.materials)
{
material.SetVector("_FaceDirection", direction);
}
}
}
}
}
BloomMode
namespace Nahida.Rendering
{
public enum BloomMode
{
None,
Color,
Brightness
}
}
BloomVolueme
using System;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.Universal;
namespace Nahida.Rendering
{
[Serializable]
[VolumeComponentMenuForRenderPipeline("Custom/Bloom", typeof(UniversalRenderPipeline))]
public class BloomVolume : VolumeComponent, IPostProcessComponent
{
public VolumeParameter<BloomMode> mode = new VolumeParameter<BloomMode>();
public MinFloatParameter threshold = new MinFloatParameter(0.7f, 0f);
public MinFloatParameter intensity = new MinFloatParameter(1.5f, 0f);
public Vector4Parameter weights = new Vector4Parameter(0.25f * Vector4.one);
public ColorParameter color = new ColorParameter(Color.white);
public MinFloatParameter blurRadius = new MinFloatParameter(2f, 0f);
public ClampedFloatParameter downSampleScale = new ClampedFloatParameter(0.5f, 0.1f, 1f);
public bool IsActive()
{
return mode.value != BloomMode.None;
}
public bool IsTileCompatible()
{
return false;
}
}
}
ColorGradingVolume
using System;
using UnityEngine.Rendering;
using UnityEngine.Rendering.Universal;
namespace Nahida.Rendering
{
[Serializable]
[VolumeComponentMenuForRenderPipeline("Custom/ColorGrading", typeof(UniversalRenderPipeline))]
public class ColorGradingVolume : VolumeComponent, IPostProcessComponent
{
public BoolParameter useTonemapping = new BoolParameter(false);
public MinFloatParameter exposure = new MinFloatParameter(1f, 0f);
public ClampedFloatParameter contrast = new ClampedFloatParameter(0f, -100f, 100f);
public ClampedFloatParameter saturation = new ClampedFloatParameter(0f, -100f, 100f);
public bool IsActive()
{
return useTonemapping.value || exposure.value != 1f || contrast.value != 0f || saturation.value != 0f;
}
public bool IsTileCompatible()
{
return false;
}
}
}