63 lines
2.3 KiB
C#
63 lines
2.3 KiB
C#
//pipelinedefine
|
|
#define H_URP
|
|
|
|
using HTraceWSGI.Scripts.Extensions;
|
|
using HTraceWSGI.Scripts.Globals;
|
|
using HTraceWSGI.Scripts.Wrappers;
|
|
using UnityEngine;
|
|
using UnityEngine.Experimental.Rendering; // For OLD Unity
|
|
using UnityEngine.Rendering;
|
|
|
|
namespace HTraceWSGI.Scripts.Passes.Shared
|
|
{
|
|
internal static class HardwareTracingShared
|
|
{
|
|
// Shader properties
|
|
private static readonly int _ShaderPropertysample = Shader.PropertyToID("_ShaderPropertysample");
|
|
|
|
// Samplers
|
|
private static readonly ProfilingSamplerHTrace SampleProfilingSampler = new ProfilingSamplerHTrace("Sample Profiling Sampler", parentName: HNames.HTRACE_HARDWARE_TRACING_PASS_NAME, priority: 0);
|
|
internal static readonly ProfilingSamplerHTrace s_LightEvaluationProfilingSampler = new ProfilingSamplerHTrace("Light Evaluation", parentName: HNames.HTRACE_HARDWARE_TRACING_PASS_NAME, priority: 11);
|
|
|
|
|
|
// Materials
|
|
internal static Material VoxelVisualizationMaterial = null;
|
|
|
|
internal static ComputeBuffer PrevBuffer = null;
|
|
internal static RayTracingShader HRayTracing = null;
|
|
|
|
internal static RTWrapper TestBuffer = new RTWrapper();
|
|
internal static RTWrapper RayTracedGBufferPayload = new RTWrapper();
|
|
internal static RTWrapper VoxelVisualizationRayDirections = new RTWrapper();
|
|
|
|
internal struct HistoryData : IHistoryData
|
|
{
|
|
public Vector3 CameraPosition;
|
|
|
|
public void Update(Camera camera)
|
|
{
|
|
CameraPosition = camera.transform.position;
|
|
}
|
|
}
|
|
|
|
internal static HistoryData History = new HistoryData()
|
|
{
|
|
CameraPosition = Vector3.zero
|
|
};
|
|
|
|
internal static void Execute(CommandBuffer cmd, Camera camera, int cameraWidth, int cameraHeight)
|
|
{
|
|
// Raytrace
|
|
cmd.SetRayTracingShaderPass(HRayTracing, "GBufferDXR");
|
|
cmd.SetRayTracingTextureParam(HRayTracing, "_RayDirection", VoxelVisualizationRayDirections.rt);
|
|
//cmd.SetRayTracingTextureParam(HRayTracing, "_Output", TestBuffer.rt);
|
|
cmd.SetRayTracingTextureParam(HRayTracing, "_Output", RayTracedGBufferPayload.rt);
|
|
cmd.DispatchRays(HRayTracing, "TraceAmbientOcclusion", (uint)Mathf.CeilToInt(cameraWidth), (uint)Mathf.CeilToInt(cameraHeight), (uint)HRenderer.TextureXrSlices);
|
|
|
|
cmd.SetGlobalBuffer("_PrevBuffer", PrevBuffer);
|
|
|
|
cmd.SetGlobalTexture(HShaderParams.g_HTraceBufferGI, TestBuffer.rt);
|
|
}
|
|
}
|
|
}
|