Search Unity

Shader not working with HDR

Discussion in 'Shaders' started by LootlabGames, Jul 20, 2017.

  1. LootlabGames

    LootlabGames

    Joined:
    Nov 21, 2014
    Posts:
    343
    I have a shader that I use for minimap FOW.
    The base shader was taken from here and modified to work with Unity 5



    Code (CSharp):
    1. Shader "Custom/FogOfWarMask" {
    2.     Properties{
    3.         _Color("Main Color", Color) = (1, 1, 1, 1)
    4.         _MainTex("Base (RGB)", 2D) = "white" {}
    5.     }
    6.     SubShader{
    7.             Tags{ "Queue" = "Transparent" "RenderType" = "Transparent" "LightMode" = "ForwardBase" }
    8.             Blend SrcAlpha OneMinusSrcAlpha
    9.             Lighting Off
    10.             LOD 200
    11.  
    12.             CGPROGRAM
    13. #pragma surface surf Lambert alpha:fade
    14.  
    15.             fixed4 LightingNoLighting(SurfaceOutput s, fixed3 lightDir, float aten)
    16.             {
    17.                 fixed4 color;
    18.                 color.rgb = s.Albedo;
    19.                 color.a = s.Alpha;
    20.                 return color;
    21.             }
    22.  
    23.             fixed4 _Color;
    24.             sampler2D _MainTex;
    25.  
    26.             struct Input {
    27.                 float2 uv_MainTex;
    28.             };
    29.  
    30.             void surf(Input IN, inout SurfaceOutput o)
    31.             {
    32.                 half4 baseColor = tex2D(_MainTex, IN.uv_MainTex);
    33.                 o.Albedo = _Color.rgb * baseColor.b;
    34.                 o.Alpha = clamp(_Color.a - baseColor.g, 0, 1); //green - color of aperture mask
    35.             }
    36.             ENDCG
    37.         }
    38.         Fallback "Diffuse"
    39. }
    40.  
    It works fine without HDR or other post processing effects running.
    Soon as HDR is enabed the shader stops working.
    Or at least it looks like it is not working in the game view.

    Is there a certain command I need to add so it will work with HDR?