public AmbientOcclusionSystem(HDRenderPipelineAsset hdAsset) { m_Settings = hdAsset.currentPlatformRenderPipelineSettings; m_Resources = hdAsset.renderPipelineResources; #if ENABLE_RAYTRACING m_RTResources = hdAsset.renderPipelineRayTracingResources; #endif if (!hdAsset.currentPlatformRenderPipelineSettings.supportSSAO) { return; } AllocRT(0.5f); }
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)); }
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 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 simple denoiser m_SimpleDenoiser.Init(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 AmbientOcclusionSystem(HDRenderPipelineAsset hdAsset) { m_Settings = hdAsset.currentPlatformRenderPipelineSettings; m_Resources = hdAsset.renderPipelineResources; #if ENABLE_RAYTRACING m_RTResources = hdAsset.renderPipelineRayTracingResources; #endif if (!hdAsset.currentPlatformRenderPipelineSettings.supportSSAO) { return; } bool supportMSAA = hdAsset.currentPlatformRenderPipelineSettings.supportMSAA; // Destination targets m_AmbientOcclusionTex = RTHandles.Alloc(Vector2.one, filterMode: FilterMode.Bilinear, colorFormat: GraphicsFormat.R8_UNorm, slices: TextureXR.slices, dimension: TextureXR.dimension, enableRandomWrite: true, useDynamicScale: true, name: "Ambient Occlusion" ); if (supportMSAA) { m_MultiAmbientOcclusionTex = RTHandles.Alloc(Vector2.one, filterMode: FilterMode.Bilinear, colorFormat: GraphicsFormat.R8G8_UNorm, slices: TextureXR.slices, dimension: TextureXR.dimension, enableRandomWrite: true, useDynamicScale: true, name: "Ambient Occlusion MSAA" ); m_ResolveMaterial = CoreUtils.CreateEngineMaterial(m_Resources.shaders.aoResolvePS); m_ResolvePropertyBlock = new MaterialPropertyBlock(); } // Prepare scale functors m_ScaleFunctors = new ScaleFunc[(int)MipLevel.Count]; m_ScaleFunctors[0] = size => size; // 0 is original size (mip0) for (int i = 1; i < m_ScaleFunctors.Length; i++) { int mult = i; m_ScaleFunctors[i] = size => { int div = 1 << mult; return(new Vector2Int( (size.x + (div - 1)) / div, (size.y + (div - 1)) / div )); }; } var fmtFP16 = supportMSAA ? GraphicsFormat.R16G16_SFloat : GraphicsFormat.R16_SFloat; var fmtFP32 = supportMSAA ? GraphicsFormat.R32G32_SFloat : GraphicsFormat.R32_SFloat; var fmtFX8 = supportMSAA ? GraphicsFormat.R8G8_UNorm : GraphicsFormat.R8_UNorm; // All of these are pre-allocated to 1x1 and will be automatically scaled properly by // the internal RTHandle system Alloc(out m_LinearDepthTex, MipLevel.Original, fmtFP16, true, "AOLinearDepth"); Alloc(out m_LowDepth1Tex, MipLevel.L1, fmtFP32, true, "AOLowDepth1"); Alloc(out m_LowDepth2Tex, MipLevel.L2, fmtFP32, true, "AOLowDepth2"); Alloc(out m_LowDepth3Tex, MipLevel.L3, fmtFP32, true, "AOLowDepth3"); Alloc(out m_LowDepth4Tex, MipLevel.L4, fmtFP32, true, "AOLowDepth4"); AllocArray(out m_TiledDepth1Tex, MipLevel.L3, fmtFP16, true, "AOTiledDepth1"); AllocArray(out m_TiledDepth2Tex, MipLevel.L4, fmtFP16, true, "AOTiledDepth2"); AllocArray(out m_TiledDepth3Tex, MipLevel.L5, fmtFP16, true, "AOTiledDepth3"); AllocArray(out m_TiledDepth4Tex, MipLevel.L6, fmtFP16, true, "AOTiledDepth4"); Alloc(out m_Occlusion1Tex, MipLevel.L1, fmtFX8, true, "AOOcclusion1"); Alloc(out m_Occlusion2Tex, MipLevel.L2, fmtFX8, true, "AOOcclusion2"); Alloc(out m_Occlusion3Tex, MipLevel.L3, fmtFX8, true, "AOOcclusion3"); Alloc(out m_Occlusion4Tex, MipLevel.L4, fmtFX8, true, "AOOcclusion4"); Alloc(out m_Combined1Tex, MipLevel.L1, fmtFX8, true, "AOCombined1"); Alloc(out m_Combined2Tex, MipLevel.L2, fmtFX8, true, "AOCombined2"); Alloc(out m_Combined3Tex, MipLevel.L3, fmtFX8, true, "AOCombined3"); }