Shader "Hidden/Shader/Adaptation3" { Properties { // This property is necessary to make the CommandBuffer.Blit bind the source texture to _MainTex _MainTex("Main Texture", 2DArray) = "grey" {} } HLSLINCLUDE #pragma target 4.5 #pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch #pragma shader_feature CLIP_DEBUG #pragma shader_feature COLOUR_PROCESSING #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl" #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl" #include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl" #include "Packages/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/FXAA.hlsl" #include "Packages/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/RTUpscale.hlsl" struct Attributes { uint vertexID : SV_VertexID; UNITY_VERTEX_INPUT_INSTANCE_ID }; struct Varyings { float4 positionCS : SV_POSITION; float2 texcoord : TEXCOORD0; UNITY_VERTEX_OUTPUT_STEREO }; Varyings Vert(Attributes input) { Varyings output; UNITY_SETUP_INSTANCE_ID(input); UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output); output.positionCS = GetFullScreenTriangleVertexPosition(input.vertexID); output.texcoord = GetFullScreenTriangleTexCoord(input.vertexID); return output; } // List of properties to control your post process effect //float _Intensity; //float _Test; //float _Exposure; TEXTURE2D_X(_MainTex); TEXTURE2D(_Adapt); float _Mult; float _Clip; float4 CustomPostProcess(Varyings input) : SV_Target { UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input); // Note that if HDUtils.DrawFullScreen is used to render the post process, use ClampAndScaleUVForBilinearPostProcessTexture(input.texcoord.xy) to get the correct UVs //float3 sourceColor = SAMPLE_TEXTURE2D_X(_MainTex, s_linear_clamp_sampler, input.texcoord).xyz; float3 sourceColor = SAMPLE_TEXTURE2D_X(_MainTex, s_linear_clamp_sampler, ClampAndScaleUVForBilinearPostProcessTexture(input.texcoord.xy)).xyz; //float3 color = lerp(_Test, Luminance(sourceColor), _Intensity) / _Exposure; //float3 color = Luminance(sourceColor); //float mask = Luminance(sourceColor) > _Exposure ? 1 : 0; //return float4(mask, mask, mask, 1); float2 adaptation = LOAD_TEXTURE2D(_Adapt, int2(0, 0)); #if CLIP_DEBUG if (_Mult * Luminance(sourceColor) < _Clip) { return float4(0, 0, 0, 1); } #endif #if COLOUR_PROCESSING float luma = Luminance(sourceColor); float luminance = luma * _Mult; float sigma = /*luminance < 0.03 ? 0.0 :*/ (luminance > 3 ? 1.0 : (0.069 / (0.069 + 1.409 * exp(-4.267 * luminance)))); float3 color = lerp(luma, sourceColor, sigma) * adaptation.x + adaptation.y; #else float3 color = sourceColor * adaptation.x + adaptation.y; #endif return float4(color, 1); } ENDHLSL SubShader { Tags{ "RenderPipeline" = "HDRenderPipeline" } Pass { Name "New Post Process Volume" ZWrite Off ZTest Always Blend Off Cull Off HLSLPROGRAM #pragma fragment CustomPostProcess #pragma vertex Vert ENDHLSL } } Fallback Off }