WuhuIslandTesting/Library/PackageCache/com.unity.render-pipelines.universal@8148.0.7-4/Runtime/VolumetricConstants.cs

47 lines
1.4 KiB
C#
Raw Normal View History

2025-01-07 02:06:59 +01:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering;
namespace UnityEngine.Rendering.Universal
{
public class VolumetricConstants
{
static VolumetricConstants s_Instance;
public static VolumetricConstants instance
{
get
{
if (s_Instance == null)
{
s_Instance = new VolumetricConstants();
}
return s_Instance;
}
}
private GlobalKeyword VolumetricKW;
// public static string volumetricKWName = "_VOLUMETRICS_ENABLED";
int resultTexID = Shader.PropertyToID(VolumetricRendering.resultTextureName);
int constantBufferID = Shader.PropertyToID(VolumetricRendering.shaderCBName);
VolumetricConstants()
{
VolumetricKW = GlobalKeyword.Create(VolumetricRendering.volumetricKWName);
}
public void EnableVolumetrics(RenderTexture volumetricResult, ComputeBuffer shaderConstants)
{
Shader.SetKeyword(VolumetricKW, true);
Shader.SetGlobalTexture(resultTexID, volumetricResult);
Shader.SetGlobalConstantBuffer(constantBufferID, shaderConstants, 0, VolumetricRendering.ShaderConstantsSize);
}
public void DisableVolumetrics()
{
Shader.SetKeyword(VolumetricKW, false);
}
}
}