コード例 #1
0
        public static void BilateralFilter(CommandBuffer CmdBuffer, RenderTargetIdentifier SRV_InputColor, RenderTargetIdentifier UAV_BilateralColor, ref SVGFParameterDescriptor Parameters, ref SVGFInputDescriptor InputData)
        {
            CmdBuffer.SetComputeFloatParam(SVGF_Shader, SVGF_BilateralShaderID.BilateralRadius, Parameters.BilateralRadius);
            CmdBuffer.SetComputeFloatParam(SVGF_Shader, SVGF_BilateralShaderID.ColorWeight, Parameters.BilateralColorWeight);
            CmdBuffer.SetComputeFloatParam(SVGF_Shader, SVGF_BilateralShaderID.NormalWeight, Parameters.BilateralNormalWeight);
            CmdBuffer.SetComputeFloatParam(SVGF_Shader, SVGF_BilateralShaderID.DepthWeight, Parameters.BilateralDepthWeight);
            CmdBuffer.SetComputeVectorParam(SVGF_Shader, SVGF_BilateralShaderID.BilateralSize, InputData.Resolution);

            CmdBuffer.SetComputeTextureParam(SVGF_Shader, 1, SVGF_BilateralShaderID.SRV_InputColor, SRV_InputColor);
            CmdBuffer.SetComputeTextureParam(SVGF_Shader, 1, SVGF_BilateralShaderID.SRV_GBufferNormal, InputData.SRV_GBufferNormal);
            CmdBuffer.SetComputeTextureParam(SVGF_Shader, 1, SVGF_BilateralShaderID.SRV_SceneDepth, InputData.SRV_SceneDepth);
            CmdBuffer.SetComputeTextureParam(SVGF_Shader, 1, SVGF_BilateralShaderID.UAV_BilateralColor, UAV_BilateralColor);
            CmdBuffer.DispatchCompute(SVGF_Shader, 1, Mathf.CeilToInt(InputData.Resolution.x / 16), Mathf.CeilToInt(InputData.Resolution.y / 16), 1);
            //CmdBuffer.CopyTexture(UAV_BilateralColor, InputData.SRV_PrevColor);
        }
コード例 #2
0
        public static void SpatialFilter(CommandBuffer CmdBuffer, RenderTargetIdentifier SRV_UWVPDF, RenderTargetIdentifier SRV_ColorMask, RenderTargetIdentifier UAV_SpatialColor, ref SVGFParameterDescriptor Parameters, ref SVGFInputDescriptor InputData)
        {
            CmdBuffer.SetComputeIntParam(SVGF_Shader, SVGF_SpatialShaderID.FrameIndex, InputData.FrameIndex);
            CmdBuffer.SetComputeFloatParam(SVGF_Shader, SVGF_SpatialShaderID.SpatialRadius, Parameters.SpatialRadius);
            CmdBuffer.SetComputeVectorParam(SVGF_Shader, SVGF_SpatialShaderID.SpatialSize, InputData.Resolution);
            CmdBuffer.SetComputeMatrixParam(SVGF_Shader, SVGF_SpatialShaderID.Matrix_InvProj, InputData.Matrix_InvProj);
            CmdBuffer.SetComputeMatrixParam(SVGF_Shader, SVGF_SpatialShaderID.Matrix_InvViewProj, InputData.Matrix_InvViewProj);
            CmdBuffer.SetComputeMatrixParam(SVGF_Shader, SVGF_SpatialShaderID.Matrix_WorldToView, InputData.Matrix_WorldToView);

            CmdBuffer.SetComputeTextureParam(SVGF_Shader, 0, SVGF_SpatialShaderID.SRV_SceneDepth, InputData.SRV_SceneDepth);
            CmdBuffer.SetComputeTextureParam(SVGF_Shader, 0, SVGF_SpatialShaderID.SRV_GBufferNormal, InputData.SRV_GBufferNormal);
            CmdBuffer.SetComputeTextureParam(SVGF_Shader, 0, SVGF_SpatialShaderID.SRV_GBufferRoughness, InputData.SRV_GBufferRoughness);
            CmdBuffer.SetComputeTextureParam(SVGF_Shader, 0, SVGF_SpatialShaderID.SRV_UWVPDF, SRV_UWVPDF);
            for (uint i = 0; i < (uint)Parameters.NumSpatial; i++)
            {
                uint CurrState = i & 1;
                if (CurrState == 0)
                {
                    CmdBuffer.SetComputeTextureParam(SVGF_Shader, 0, SVGF_SpatialShaderID.SRV_ColorMask, SRV_ColorMask);
                    CmdBuffer.SetComputeTextureParam(SVGF_Shader, 0, SVGF_SpatialShaderID.UAV_SpatialColor, UAV_SpatialColor);
                    CmdBuffer.DispatchCompute(SVGF_Shader, 0, Mathf.CeilToInt(InputData.Resolution.x / 16), Mathf.CeilToInt(InputData.Resolution.y / 16), 1);
                }
                else
                {
                    CmdBuffer.SetComputeTextureParam(SVGF_Shader, 0, SVGF_SpatialShaderID.SRV_ColorMask, UAV_SpatialColor);
                    CmdBuffer.SetComputeTextureParam(SVGF_Shader, 0, SVGF_SpatialShaderID.UAV_SpatialColor, SRV_ColorMask);
                    CmdBuffer.DispatchCompute(SVGF_Shader, 0, Mathf.CeilToInt(InputData.Resolution.x / 16), Mathf.CeilToInt(InputData.Resolution.y / 16), 1);
                    CmdBuffer.CopyTexture(SRV_ColorMask, UAV_SpatialColor);
                }
            }
        }
コード例 #3
0
 public static void TemporalFilter(CommandBuffer CmdBuffer, RenderTargetIdentifier SRV_RayDepth, RenderTargetIdentifier SRV_CurrColor, RenderTargetIdentifier SRV_PrevColor, RenderTargetIdentifier UAV_TemporalColor, ref SVGFParameterDescriptor Parameters, ref SVGFInputDescriptor InputData)
 {
     CmdBuffer.SetComputeFloatParam(SVGF_Shader, SVGF_TemporalShaderID.TemporalScale, Parameters.TemporalScale);
     CmdBuffer.SetComputeFloatParam(SVGF_Shader, SVGF_TemporalShaderID.TemporalWeight, Parameters.TemporalWeight);
     CmdBuffer.SetComputeVectorParam(SVGF_Shader, SVGF_TemporalShaderID.TemporalSize, InputData.Resolution);
     CmdBuffer.SetComputeMatrixParam(SVGF_Shader, SVGF_TemporalShaderID.Matrix_PrevViewProj, InputData.Matrix_PrevViewProj);
     CmdBuffer.SetComputeMatrixParam(SVGF_Shader, SVGF_TemporalShaderID.Matrix_ViewProj, InputData.Matrix_ViewProj);
     CmdBuffer.SetComputeMatrixParam(SVGF_Shader, SVGF_TemporalShaderID.Matrix_InvViewProj, InputData.Matrix_InvViewProj);
     CmdBuffer.SetComputeTextureParam(SVGF_Shader, 1, SVGF_TemporalShaderID.SRV_GBufferMotion, InputData.SRV_GBufferMotion);
     CmdBuffer.SetComputeTextureParam(SVGF_Shader, 1, SVGF_TemporalShaderID.SRV_RayDepth, SRV_RayDepth);
     CmdBuffer.SetComputeTextureParam(SVGF_Shader, 1, SVGF_TemporalShaderID.SRV_CurrColor, SRV_CurrColor);
     CmdBuffer.SetComputeTextureParam(SVGF_Shader, 1, SVGF_TemporalShaderID.SRV_PrevColor, SRV_PrevColor);
     CmdBuffer.SetComputeTextureParam(SVGF_Shader, 1, SVGF_TemporalShaderID.UAV_TemporalColor, UAV_TemporalColor);
     CmdBuffer.DispatchCompute(SVGF_Shader, 1, Mathf.CeilToInt(InputData.Resolution.x / 16), Mathf.CeilToInt(InputData.Resolution.y / 16), 1);
 }