{
    "Name": "depthMitigation",
    "OverrideMaterial": "engine:engineDefaults.rematerialdefinition",
    "Parameters": {
        "Constants": {
            "viewToProjArray": "view.viewToProjArray",
            "viewportPercentsArray" : "view.viewportPercentsArray"
        },
        "Buffers": {
            "position": "geometry.vertexPosition",
            "texcoord": "geometry.vertexUV"
        },
        "Textures": {
            "lowResPortalMask" : "fallback.blackArray",
            "textureBlueNoise" : "engine:blueNoise64RGBA8.ktx"
        }
    },
    "Techniques": [
        {
            "Name": "ClearDepth",
            "VertexShader": {
                "Entry": "fullScreen2Vert"
            },
            "State" : {
                "AlphaBlend" : false,
                "WriteDepth" : true,
                "DepthCompareFunction" : "Always"
            },
            "SupportsRuntimeFunctionConstants" : true
        },
        {
            "Name": "RenderLinearizedDepthSU",
            "VertexShader": {
                "Entry": "vsLinearizedDepthOnly"
            },

            "PixelShader": {
                "Entry": "fsLinearizedDepthAsColor"
            },
            "State" : {
                "AlphaBlend" : false,
                "WriteDepth" : true,
                "DepthCompareFunction" : "Greater"
            },
            "FunctionConstants": {
                "LinearizeDepthColorOutputIndex" : "0",
                "PortalClippingMode"             : "0"
            },
            "Variations" : {
                "PortalClippingMode"             : ["0", "1", "2", "3", "4"]
            },
            "RuntimeFunctionConstantDefaults" : {
                "PortalClippingMode"             : "0"
            },
            "SupportsRuntimeFunctionConstants" : true
        },
        {
            "Name": "RenderLinearizedDepthPhysicalTreatment",
            "VertexShader": {
                "Entry": "vsLinearizedDepthOnly"
            },

            "PixelShader": {
                "Entry": "fsLinearizedDepthAsColorWithDither"
            },
            "State" : {
                "AlphaBlend" : false,
                "WriteDepth" : true,
                "DepthCompareFunction" : "Greater"
            },
            "FunctionConstants": {
                "EnableDepthDither"              : "true",
                "LinearizeDepthColorOutputIndex" : "3"
            },
            "Variations": {
                "EnableDepthDither"              : ["true", "false"]
            }
        },
        {
            "Name": "RenderLinearizedDepthContent",
            "VertexShader": {
                "Entry": "vsLinearizedDepthOnly"
            },
            "PixelShader": {
                "Entry": "fsLinearizedDepthAsColorWithAlpha"
            },
            "State" : {
                "WriteStencil": true,
                "WriteDepth" : true,
                "DepthCompareFunction" : "Greater",
                "RenderAttachmentState" : [
                    {},
                    {
                        "PreferProgrammableBlending" : true,
                        "AlphaBlend"                 : true,
                        "AlphaBlendOperation"        : "Add",
                        "AlphaSourceFactor"          : "One",
                        "AlphaDestinationFactor"     : "OneMinusSourceAlpha",
                        "RgbBlendOperation"          : "Add",
                        "RgbSourceFactor"            : "One",
                        "RgbDestinationFactor"       : "OneMinusSourceAlpha"
                    }
                ]
            },
            "FunctionConstants": {
                "LinearizeDepthColorOutputIndex"  : "1",
                "PortalClippingMode"              : "0"
            },
            "Variations" : {
                "PortalClippingMode"              : ["0", "1", "2", "3", "4"]
            },
            "RuntimeFunctionConstantDefaults" : {
                "PortalClippingMode"              : "0"
            },
            "SupportsRuntimeFunctionConstants" : true
        },
        {
            "Name": "RenderLinearizedDepthEnvironment",
            "VertexShader": {
                "Entry": "vsLinearizedDepthOnly"
            },
            "PixelShader": {
                "Entry": "fsLinearizedDepthAsColor"
            },
            "State" : {
                "AlphaBlend" : false,
                "WriteDepth" : true,
                "DepthCompareFunction" : "Greater"
            },
            "FunctionConstants": {
                "LinearizeDepthColorOutputIndex"  : "2"
            },
            "SupportsRuntimeFunctionConstants" : true
        }
    ],
    "TechniqueMapping": {
        "ClearDepth": "ClearDepth",
        "RenderLinearizedDepthSU": "RenderLinearizedDepthSU",
        "RenderLinearizedDepthPhysicalTreatment": "RenderLinearizedDepthPhysicalTreatment",
        "RenderLinearizedDepthEnvironmentToDepthDifferenceTexture": "RenderLinearizedDepthEnvironment",
        "RenderLinearizedDepthContent": "RenderLinearizedDepthContent"
    }
}
