public void Init(HDRenderPipeline renderPipeline) { // Keep track of the pipeline asset m_PipelineRayTracingResources = renderPipeline.asset.renderPipelineRayTracingResources; // keep track of the render pipeline m_RenderPipeline = renderPipeline; // Grab the kernels we need m_RTAOApplyIntensityKernel = m_PipelineRayTracingResources.aoRaytracingCS.FindKernel("RTAOApplyIntensity"); // Allocate the intermediate textures m_AOIntermediateBuffer0 = RTHandles.Alloc(Vector2.one, TextureXR.slices, colorFormat: GraphicsFormat.R16G16B16A16_SFloat, dimension: TextureXR.dimension, enableRandomWrite: true, useDynamicScale: true, useMipMap: false, autoGenerateMips: false, name: "AOIntermediateBuffer0"); m_AOIntermediateBuffer1 = RTHandles.Alloc(Vector2.one, TextureXR.slices, colorFormat: GraphicsFormat.R16G16B16A16_SFloat, dimension: TextureXR.dimension, enableRandomWrite: true, useDynamicScale: true, useMipMap: false, autoGenerateMips: false, name: "AOIntermediateBuffer1"); }
public AmbientOcclusionSystem(HDRenderPipelineAsset hdAsset, RenderPipelineResources defaultResources) { m_Settings = hdAsset.currentPlatformRenderPipelineSettings; m_Resources = defaultResources; #if ENABLE_RAYTRACING m_RTResources = hdAsset.renderPipelineRayTracingResources; #endif if (!hdAsset.currentPlatformRenderPipelineSettings.supportSSAO) { return; } AllocRT(0.5f); }
public void Init(HDRenderPipelineRayTracingResources rpRTResources, SharedRTManager sharedRTManager) { m_ReflectionDenoiserCS = rpRTResources.reflectionDenoiserCS; m_ReflectionFilterMapping = rpRTResources.reflectionFilterMapping; m_SharedRTManager = sharedRTManager; // Fetch all the kernels we shall be using s_TemporalAccumulationKernel = m_ReflectionDenoiserCS.FindKernel("TemporalAccumulation"); s_CopyHistoryKernel = m_ReflectionDenoiserCS.FindKernel("CopyHistory"); s_BilateralFilterHKernel = m_ReflectionDenoiserCS.FindKernel("BilateralFilterH"); s_BilateralFilterVKernel = m_ReflectionDenoiserCS.FindKernel("BilateralFilterV"); m_IntermediateBuffer0 = RTHandles.Alloc(Vector2.one, TextureXR.slices, colorFormat: GraphicsFormat.R16G16B16A16_SFloat, dimension: TextureXR.dimension, enableRandomWrite: true, useDynamicScale: true, useMipMap: false, autoGenerateMips: false, name: "IntermediateBuffer0"); m_IntermediateBuffer1 = RTHandles.Alloc(Vector2.one, TextureXR.slices, colorFormat: GraphicsFormat.R16G16B16A16_SFloat, dimension: TextureXR.dimension, enableRandomWrite: true, useDynamicScale: true, useMipMap: false, autoGenerateMips: false, name: "IntermediateBuffer1"); }
public void Init(RenderPipelineResources rpResources, HDRenderPipelineRayTracingResources rpRTResources, SharedRTManager sharedRTManager, HDRenderPipeline renderPipeline) { // Keep track of the resources m_DiffuseDenoiser = rpRTResources.diffuseDenoiserCS; m_OwenScrambleRGBA = rpResources.textures.owenScrambledRGBATex; // Keep track of the shared rt manager m_SharedRTManager = sharedRTManager; m_RenderPipeline = renderPipeline; // Grab all the kernels we'll eventually need m_BilateralFilterSingleKernel = m_DiffuseDenoiser.FindKernel("BilateralFilterSingle"); m_BilateralFilterColorKernel = m_DiffuseDenoiser.FindKernel("BilateralFilterColor"); m_GatherSingleKernel = m_DiffuseDenoiser.FindKernel("GatherSingle"); m_GatherColorKernel = m_DiffuseDenoiser.FindKernel("GatherColor"); }
public void Init(HDRenderPipelineRayTracingResources rpRTResources, SharedRTManager sharedRTManager, HDRenderPipeline renderPipeline) { // Keep track of the resources m_TemporalFilterCS = rpRTResources.temporalFilterCS; // Keep track of the shared rt manager m_SharedRTManager = sharedRTManager; m_RenderPipeline = renderPipeline; // Grab all the kernels we'll eventually need m_ValidateHistoryKernel = m_TemporalFilterCS.FindKernel("ValidateHistory"); m_TemporalAccumulationSingleKernel = m_TemporalFilterCS.FindKernel("TemporalAccumulationSingle"); m_TemporalAccumulationColorKernel = m_TemporalFilterCS.FindKernel("TemporalAccumulationColor"); m_CopyHistorySingleKernel = m_TemporalFilterCS.FindKernel("CopyHistorySingle"); m_CopyHistoryColorKernel = m_TemporalFilterCS.FindKernel("CopyHistoryColor"); }
public void Init(HDRenderPipelineRayTracingResources rpRTResources, SharedRTManager sharedRTManager, HDRenderPipeline renderPipeline) { m_SharedRTManager = sharedRTManager; m_RenderPipeline = renderPipeline; m_ShadowDenoiser = rpRTResources.diffuseShadowDenoiserCS; m_BilateralFilterHSingleDirectionalKernel = m_ShadowDenoiser.FindKernel("BilateralFilterHSingleDirectional"); m_BilateralFilterVSingleDirectionalKernel = m_ShadowDenoiser.FindKernel("BilateralFilterVSingleDirectional"); m_BilateralFilterHColorDirectionalKernel = m_ShadowDenoiser.FindKernel("BilateralFilterHColorDirectional"); m_BilateralFilterVColorDirectionalKernel = m_ShadowDenoiser.FindKernel("BilateralFilterVColorDirectional"); m_BilateralFilterHSingleSphereKernel = m_ShadowDenoiser.FindKernel("BilateralFilterHSingleSphere"); m_BilateralFilterVSingleSphereKernel = m_ShadowDenoiser.FindKernel("BilateralFilterVSingleSphere"); }
public void Init(RenderPipelineResources rpResources, HDRenderPipelineRayTracingResources rpRTResources, RenderPipelineSettings pipelineSettings, HDRaytracingManager raytracingManager, SharedRTManager sharedRTManager) { // Keep track of the pipeline asset m_PipelineSettings = pipelineSettings; m_PipelineResources = rpResources; m_PipelineRayTracingResources = rpRTResources; // keep track of the ray tracing manager m_RaytracingManager = raytracingManager; // Keep track of the shared rt manager m_SharedRTManager = sharedRTManager; m_AOIntermediateBuffer0 = RTHandles.Alloc(Vector2.one, TextureXR.slices, colorFormat: GraphicsFormat.R16G16B16A16_SFloat, dimension: TextureXR.dimension, enableRandomWrite: true, useDynamicScale: true, useMipMap: false, autoGenerateMips: false, name: "AOIntermediateBuffer0"); m_AOIntermediateBuffer1 = RTHandles.Alloc(Vector2.one, TextureXR.slices, colorFormat: GraphicsFormat.R16G16B16A16_SFloat, dimension: TextureXR.dimension, enableRandomWrite: true, useDynamicScale: true, useMipMap: false, autoGenerateMips: false, name: "AOIntermediateBuffer1"); }
public void Init(HDRenderPipelineRayTracingResources rayTracingResources) { // Keep track of the compute shader we are going to use m_RayCountCS = rayTracingResources.countTracedRays; // We only require 3 buffers (this supports a maximal size of 8192x8192) m_ReducedRayCountBufferOutput = new ComputeBuffer((int)RayCountValues.Count + 1, sizeof(uint)); // Initialize the CPU ray count (Optional) for (int i = 0; i < (int)RayCountValues.Count; ++i) { m_ReducedRayCountValues[i] = 0; } // By default, this is not active m_IsActive = false; m_RayTracingSupported = true; }
public void Init(RenderPipelineResources rpResources, HDRenderPipelineRayTracingResources rpRTResources, RenderPipelineSettings pipelineSettings, HDRaytracingManager raytracingManager, SharedRTManager sharedRTManager) { // Keep track of the pipeline asset m_PipelineSettings = pipelineSettings; m_PipelineResources = rpResources; m_PipelineRayTracingResources = rpRTResources; // keep track of the ray tracing manager m_RaytracingManager = raytracingManager; // Keep track of the shared rt manager m_SharedRTManager = sharedRTManager; // Intermediate buffer that holds the pre-denoised texture m_IntermediateBuffer = RTHandles.Alloc(Vector2.one, TextureXR.slices, colorFormat: GraphicsFormat.R16G16B16A16_SFloat, dimension: TextureXR.dimension, enableRandomWrite: true, useDynamicScale: true, useMipMap: false, autoGenerateMips: false, name: "IntermediateAOBuffer"); // Buffer that holds the uncompressed normal buffer m_ViewSpaceNormalBuffer = RTHandles.Alloc(Vector2.one, TextureXR.slices, colorFormat: GraphicsFormat.R16G16B16A16_SFloat, dimension: TextureXR.dimension, enableRandomWrite: true, useDynamicScale: true, useMipMap: false, autoGenerateMips: false, name: "ViewSpaceNormalBuffer"); }
public void Init(HDRenderPipelineRayTracingResources rayTracingResources, DebugDisplaySettings currentDebugDisplaySettings) { // Keep track of the external resources m_DebugDisplaySettings = currentDebugDisplaySettings; m_PipelineResources = rayTracingResources; m_RayCountTexture = RTHandles.Alloc(Vector2.one, filterMode: FilterMode.Point, colorFormat: GraphicsFormat.R32G32B32A32_UInt, enableRandomWrite: true, useMipMap: false, name: "RayCountTexture"); // We only require 3 buffers (this supports a maximal size of 8192x8192) m_ReducedRayCountBuffer0 = new ComputeBuffer(4 * 256 * 256, sizeof(uint)); m_ReducedRayCountBuffer1 = new ComputeBuffer(4 * 32 * 32, sizeof(uint)); m_ReducedRayCountBuffer2 = new ComputeBuffer(4, sizeof(uint)); // Initialize the cpu ray count (Optional) for (int i = 0; i < 4; ++i) { m_ReducedRayCountValues[i] = 0; } }
public void Initialize(HDRenderPipeline renderPipeline) { // Keep track of the external buffers m_RenderPipelineResources = renderPipeline.asset.renderPipelineResources; m_RenderPipelineRayTracingResources = renderPipeline.asset.renderPipelineRayTracingResources; // Keep track of the render pipeline m_RenderPipeline = renderPipeline; // Texture used to output debug information m_DebugLightClusterTexture = RTHandles.Alloc(Vector2.one, TextureXR.slices, dimension: TextureXR.dimension, filterMode: FilterMode.Point, colorFormat: GraphicsFormat.R16G16B16A16_SFloat, enableRandomWrite: true, useDynamicScale: true, useMipMap: false, name: "DebugLightClusterTexture"); // Pre allocate the cluster with a dummy size m_LightCluster = new ComputeBuffer(1, sizeof(uint)); m_LightDataGPUArray = new ComputeBuffer(1, System.Runtime.InteropServices.Marshal.SizeOf(typeof(LightData))); m_EnvLightDataGPUArray = new ComputeBuffer(1, System.Runtime.InteropServices.Marshal.SizeOf(typeof(EnvLightData))); // Create the material required for debug m_DebugMaterial = CoreUtils.CreateEngineMaterial(m_RenderPipelineRayTracingResources.lightClusterDebugS); }
public void Init(HDRenderPipelineRayTracingResources rpRTResources) { // Keep track of the resources m_TemporalFilterCS = rpRTResources.temporalFilterCS; // Grab all the kernels we'll eventually need m_ValidateHistoryKernel = m_TemporalFilterCS.FindKernel("ValidateHistory"); m_TemporalAccumulationSingleKernel = m_TemporalFilterCS.FindKernel("TemporalAccumulationSingle"); m_TemporalAccumulationColorKernel = m_TemporalFilterCS.FindKernel("TemporalAccumulationColor"); m_CopyHistorySingleKernel = m_TemporalFilterCS.FindKernel("CopyHistorySingle"); m_CopyHistoryColorKernel = m_TemporalFilterCS.FindKernel("CopyHistoryColor"); m_TemporalAccumulationSingleArrayKernel = m_TemporalFilterCS.FindKernel("TemporalAccumulationSingleArray"); m_TemporalAccumulationColorArrayKernel = m_TemporalFilterCS.FindKernel("TemporalAccumulationColorArray"); m_CopyHistorySingleArrayKernel = m_TemporalFilterCS.FindKernel("CopyHistorySingleArray"); m_CopyHistoryColorArrayKernel = m_TemporalFilterCS.FindKernel("CopyHistoryColorArray"); m_CopyHistorySingleArrayNoValidityKernel = m_TemporalFilterCS.FindKernel("CopyHistorySingleArrayNoValidity"); }
public void Init(RenderPipelineSettings settings, RenderPipelineResources rpResources, HDRenderPipelineRayTracingResources rayTracingResources, BlueNoise blueNoise, HDRenderPipeline renderPipeline, SharedRTManager sharedRTManager, DebugDisplaySettings currentDebugDisplaySettings) { // Keep track of the resources m_Resources = rpResources; m_RTResources = rayTracingResources; // Keep track of the settings m_Settings = settings; // Keep track of the render pipeline m_RenderPipeline = renderPipeline; // Keep track of the shared RT manager m_SharedRTManager = sharedRTManager; // Keep track of the blue noise manager m_BlueNoise = blueNoise; // Create the list of environments m_Environments = new List <HDRaytracingEnvironment>(); // Grab all the ray-tracing graphs that have been created before (in case the order of initialization has not been respected, which happens when we open unity the first time) HDRaytracingEnvironment[] environmentArray = Object.FindObjectsOfType <HDRaytracingEnvironment>(); for (int envIdx = 0; envIdx < environmentArray.Length; ++envIdx) { RegisterEnvironment(environmentArray[envIdx]); } // Init the denoisers m_TemporalFilter.Init(rayTracingResources, m_SharedRTManager); m_SimpleDenoiser.Init(rayTracingResources, m_SharedRTManager); m_DiffuseDenoiser.Init(rpResources, rayTracingResources, m_SharedRTManager); // Init the ray count manager m_RayCountManager.Init(rayTracingResources, currentDebugDisplaySettings); #if UNITY_EDITOR // We need to invalidate the acceleration structures in case the hierarchy changed EditorApplication.hierarchyChanged += OnHierarchyChanged; #endif }
public void Initialize(RenderPipelineResources rpResources, HDRenderPipelineRayTracingResources rpRTResources, HDRaytracingManager raytracingManager, SharedRTManager sharedRTManager, HDRenderPipeline renderPipeline) { // Keep track of the external buffers m_RenderPipelineResources = rpResources; m_RenderPipelineRayTracingResources = rpRTResources; m_RaytracingManager = raytracingManager; // Keep track of the render pipeline m_RenderPipeline = renderPipeline; // Keep track of the shader rt manager m_SharedRTManager = sharedRTManager; // Texture used to output debug information m_DebugLightClusterTexture = RTHandles.Alloc(Vector2.one, filterMode: FilterMode.Point, colorFormat: GraphicsFormat.R16G16B16A16_SFloat, enableRandomWrite: true, useDynamicScale: true, useMipMap: false, name: "DebugLightClusterTexture"); // Pre allocate the cluster with a dummy size m_LightCluster = new ComputeBuffer(1, sizeof(uint)); m_LightDataGPUArray = new ComputeBuffer(1, System.Runtime.InteropServices.Marshal.SizeOf(typeof(LightData))); m_EnvLightDataGPUArray = new ComputeBuffer(1, System.Runtime.InteropServices.Marshal.SizeOf(typeof(EnvLightData))); }
public void Init(HDRenderPipelineRayTracingResources rayTracingResources, DebugDisplaySettings currentDebugDisplaySettings) { // Keep track of the compute shader we are going to use rayCountCS = rayTracingResources.countTracedRays; // Allocate the texture that will hold the ray count m_RayCountTexture = RTHandles.Alloc(Vector2.one, filterMode: FilterMode.Point, colorFormat: GraphicsFormat.R16G16B16A16_UInt, enableRandomWrite: true, useMipMap: false, name: "RayCountTextureDebug"); // We only require 3 buffers (this supports a maximal size of 8192x8192) m_ReducedRayCountBuffer0 = new ComputeBuffer((int)RayCountValues.Count * 256 * 256, sizeof(uint)); m_ReducedRayCountBuffer1 = new ComputeBuffer((int)RayCountValues.Count * 32 * 32, sizeof(uint)); m_ReducedRayCountBuffer2 = new ComputeBuffer((int)RayCountValues.Count + 1, sizeof(uint)); // Initialize the CPU ray count (Optional) for (int i = 0; i < (int)RayCountValues.Count; ++i) { m_ReducedRayCountValues[i] = 0; } // By default, this is not active m_IsActive = false; }
public void Initialize(HDRenderPipeline renderPipeline) { // Keep track of the external buffers m_RenderPipelineResources = renderPipeline.asset.renderPipelineResources; m_RenderPipelineRayTracingResources = renderPipeline.asset.renderPipelineRayTracingResources; // Keep track of the render pipeline m_RenderPipeline = renderPipeline; // Pre allocate the cluster with a dummy size m_LightDataGPUArray = new ComputeBuffer(1, System.Runtime.InteropServices.Marshal.SizeOf(typeof(LightData))); m_EnvLightDataGPUArray = new ComputeBuffer(1, System.Runtime.InteropServices.Marshal.SizeOf(typeof(EnvLightData))); // Allocate the light cluster buffer at the right size m_NumLightsPerCell = renderPipeline.asset.currentPlatformRenderPipelineSettings.lightLoopSettings.maxLightsPerClusterCell; int bufferSize = 64 * 64 * 32 * (renderPipeline.asset.currentPlatformRenderPipelineSettings.lightLoopSettings.maxLightsPerClusterCell + 4); ResizeClusterBuffer(bufferSize); // Create the material required for debug m_DebugMaterial = CoreUtils.CreateEngineMaterial(m_RenderPipelineRayTracingResources.lightClusterDebugS); }
public void Init(HDRenderPipelineRayTracingResources rpRTResources, SharedRTManager sharedRTManager, HDRenderPipeline renderPipeline) { m_SimpleDenoiserCS = rpRTResources.simpleDenoiserCS; m_SharedRTManager = sharedRTManager; m_RenderPipeline = renderPipeline; }