unity修改管线

复制代码
   public const string CustomACES = "_CUSTOMACES";
复制代码
  case TonemappingMode.CustomACES: material.EnableKeyword(ShaderKeywordStrings.CustomACES); break;
复制代码
  public enum TonemappingMode
    {
        /// <summary>
        /// Use this option if you do not want to apply tonemapping
        /// </summary>
        None,

        /// <summary>
        /// Use this option if you only want range-remapping with minimal impact on color hue and saturation.
        /// It is generally a great starting point for extensive color grading.
        /// </summary>
        Neutral, // Neutral tonemapper

        /// <summary>
        /// Use this option to apply a close approximation of the reference ACES tonemapper for a more filmic look.
        /// It is more contrasted than Neutral and has an effect on actual color hue and saturation.
        /// Note that if you use this tonemapper all the grading operations will be done in the ACES color spaces for optimal precision and results.
        /// </summary>
        ACES, // ACES Filmic reference tonemapper (custom approximation)

        CustomACES,
    }
复制代码
        #pragma multi_compile_local_fragment _ _CUSTOMACES
        #if  defined(_CUSTOMACES)
                return half4(1,1,1,1)
        #endif
复制代码
Shader "Hidden/Universal Render Pipeline/UberPost"
{
    HLSLINCLUDE
        #pragma exclude_renderers gles
        #pragma multi_compile_local_fragment _ _DISTORTION
        #pragma multi_compile_local_fragment _ _CHROMATIC_ABERRATION
        #pragma multi_compile_local_fragment _ _BLOOM_LQ _BLOOM_HQ _BLOOM_LQ_DIRT _BLOOM_HQ_DIRT
        #pragma multi_compile_local_fragment _ _HDR_GRADING _TONEMAP_ACES _TONEMAP_NEUTRAL
        #pragma multi_compile_local_fragment _ _FILM_GRAIN
        #pragma multi_compile_local_fragment _ _DITHERING
        #pragma multi_compile_local_fragment _ _GAMMA_20 _LINEAR_TO_SRGB_CONVERSION
        #pragma multi_compile_local_fragment _ _USE_FAST_SRGB_LINEAR_CONVERSION
        #pragma multi_compile _ _USE_DRAW_PROCEDURAL
        #pragma multi_compile_fragment _ DEBUG_DISPLAY

        #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
        #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Filtering.hlsl"
        #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
        #include "Packages/com.unity.render-pipelines.universal/Shaders/PostProcessing/Common.hlsl"
        #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Debug/DebuggingFullscreen.hlsl"

        // Hardcoded dependencies to reduce the number of variants
        #if _BLOOM_LQ || _BLOOM_HQ || _BLOOM_LQ_DIRT || _BLOOM_HQ_DIRT
            #define BLOOM
            #if _BLOOM_LQ_DIRT || _BLOOM_HQ_DIRT
                #define BLOOM_DIRT
            #endif
        #endif

        TEXTURE2D_X(_SourceTex);
        TEXTURE2D_X(_Bloom_Texture);
        TEXTURE2D(_LensDirt_Texture);
        TEXTURE2D(_Grain_Texture);
        TEXTURE2D(_InternalLut);
        TEXTURE2D(_UserLut);
        TEXTURE2D(_BlueNoise_Texture);

        float4 _Lut_Params;
        float4 _UserLut_Params;
        float4 _Bloom_Params;
        float _Bloom_RGBM;
        float4 _LensDirt_Params;
        float _LensDirt_Intensity;
        float4 _Distortion_Params1;
        float4 _Distortion_Params2;
        float _Chroma_Params;
        half4 _Vignette_Params1;
        float4 _Vignette_Params2;
        float2 _Grain_Params;
        float4 _Grain_TilingParams;
        float4 _Bloom_Texture_TexelSize;
        float4 _Dithering_Params;

        #define DistCenter              _Distortion_Params1.xy
        #define DistAxis                _Distortion_Params1.zw
        #define DistTheta               _Distortion_Params2.x
        #define DistSigma               _Distortion_Params2.y
        #define DistScale               _Distortion_Params2.z
        #define DistIntensity           _Distortion_Params2.w

        #define ChromaAmount            _Chroma_Params.x

        #define BloomIntensity          _Bloom_Params.x
        #define BloomTint               _Bloom_Params.yzw
        #define BloomRGBM               _Bloom_RGBM.x
        #define LensDirtScale           _LensDirt_Params.xy
        #define LensDirtOffset          _LensDirt_Params.zw
        #define LensDirtIntensity       _LensDirt_Intensity.x

        #define VignetteColor           _Vignette_Params1.xyz
        #define VignetteCenter          _Vignette_Params2.xy
        #define VignetteIntensity       _Vignette_Params2.z
        #define VignetteSmoothness      _Vignette_Params2.w
        #define VignetteRoundness       _Vignette_Params1.w

        #define LutParams               _Lut_Params.xyz
        #define PostExposure            _Lut_Params.w
        #define UserLutParams           _UserLut_Params.xyz
        #define UserLutContribution     _UserLut_Params.w

        #define GrainIntensity          _Grain_Params.x
        #define GrainResponse           _Grain_Params.y
        #define GrainScale              _Grain_TilingParams.xy
        #define GrainOffset             _Grain_TilingParams.zw

        #define DitheringScale          _Dithering_Params.xy
        #define DitheringOffset         _Dithering_Params.zw

   

        half4 Frag(Varyings input) : SV_Target
        {
            UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);

            float2 uv = UnityStereoTransformScreenSpaceTex(input.uv);
            float2 uvDistorted = uv;

            half3 color = (0.0).xxx;
      
            color = SAMPLE_TEXTURE2D_X(_SourceTex, sampler_LinearClamp, uvDistorted).xyz;

            // Gamma space... Just do the rest of Uber in linear and convert back to sRGB at the end
            #if UNITY_COLORSPACE_GAMMA
            {
                color = GetSRGBToLinear(color);
            }
            #endif
            half3 FinalColor=color;
            
            half3 BloomColor=half3(0,0,0);
            #if defined(BLOOM)
            {
                #if _BLOOM_HQ && !defined(SHADER_API_GLES)
                    half4 bloom = SampleTexture2DBicubic(TEXTURE2D_X_ARGS(_Bloom_Texture, sampler_LinearClamp), uvDistorted, _Bloom_Texture_TexelSize.zwxy, (1.0).xx, unity_StereoEyeIndex);
                #else
                 half4 bloom = SAMPLE_TEXTURE2D_X(_Bloom_Texture, sampler_LinearClamp, uvDistorted);
                #endif

                #if UNITY_COLORSPACE_GAMMA
                bloom.xyz *= bloom.xyz; // γ to linear
                #endif

                UNITY_BRANCH
                if (BloomRGBM > 0)
                {
                    bloom.xyz = DecodeRGBM(bloom);
                }
                bloom.xyz *= BloomIntensity;
                color+= bloom.xyz * BloomTint;
            }
              
            #endif
             
            FinalColor=color;
             
            


            BloomColor=FinalColor* float3(0.78125, 0.78125, 0.78125)+BloomColor;
            FinalColor=max(BloomColor.xyz, float3(6.11e-05, 6.11e-05, 6.11e-05));
            FinalColor= (float3(0.14, 0.14, 0.14) / FinalColor.xyz);


            float3 test = ((BloomColor.xyz * float3(2.43,2.43,2.43)) + float3(0.59, 0.59, 0.59)) ;

            BloomColor.xyz = ((BloomColor.xyz * float3(2.51, 2.51, 2.51)) + float3(0.03, 0.03, 0.03));
            FinalColor.xyz = (FinalColor.xyz + test.xyz);
            FinalColor=BloomColor/FinalColor;
            FinalColor=saturate(FinalColor);
             return half4(FinalColor, 1.0);
             /*
            (_u_xlat16_1.xyz = ((_u_xlat16_0.xyz * float3(0.78125, 0.78125, 0.78125)) + _u_xlat16_1.xyz));

            (_u_xlat16_2.xyz = max(_u_xlat16_1.xyz, float3(6.11e-05, 6.11e-05, 6.11e-05)));
            (_u_xlat16_2.xyz = (float3(0.14, 0.14, 0.14) / _u_xlat16_2.xyz));



            (_u_xlat16_3.xyz = ((_u_xlat16_1.xyz * float3(2.4300001, 2.4300001, 2.4300001)) + float3(0.58999997, 0.58999997, 0.58999997)));

            (_u_xlat16_1.xyz = ((_u_xlat16_1.xyz * float3(2.51, 2.51, 2.51)) + float3(0.029999999, 0.029999999, 0.029999999)));
            (_u_xlat16_2.xyz = (_u_xlat16_2.xyz + _u_xlat16_3.xyz));
            (out_SV_Target0.xyz = (_u_xlat16_1.xyz / _u_xlat16_2.xyz));
            (out_SV_Target0.xyz = clamp(out_SV_Target0.xyz, 0.0, 1.0));

            */
           
        }

    ENDHLSL

    SubShader
    {
        Tags { "RenderType" = "Opaque" "RenderPipeline" = "UniversalPipeline"}
        LOD 100
        ZTest Always ZWrite Off Cull Off

        Pass
        {
            Name "UberPost"

            HLSLPROGRAM
                #pragma vertex FullscreenVert
                #pragma fragment Frag
            ENDHLSL
        }
    }
}
相关推荐
2401_cf3 小时前
为什么hadoop不用Java的序列化?
java·hadoop·eclipse
帮帮志3 小时前
idea整合maven环境配置
java·maven·intellij-idea
LuckyTHP3 小时前
java 使用zxing生成条形码(可自定义文字位置、边框样式)
java·开发语言·python
DN金猿3 小时前
Jenkins的流水线执行shell脚本执行jar命令后项目未启动未输出日志问题处理
servlet·jenkins·jar
无声旅者6 小时前
深度解析 IDEA 集成 Continue 插件:提升开发效率的全流程指南
java·ide·ai·intellij-idea·ai编程·continue·openapi
Ryan-Joee6 小时前
Spring Boot三层架构设计模式
java·spring boot
Hygge-star6 小时前
【数据结构】二分查找5.12
java·数据结构·程序人生·算法·学习方法
dkmilk6 小时前
Tomcat发布websocket
java·websocket·tomcat
工一木子7 小时前
【Java项目脚手架系列】第七篇:Spring Boot + Redis项目脚手架
java·spring boot·redis
哞哞不熬夜7 小时前
JavaEE--初识网络
java·网络·java-ee