Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Depth of field near blur Y inversion

Discussion in 'Unity 5 Pre-order Beta' started by HarryCodder, Feb 20, 2015.

  1. HarryCodder

    HarryCodder

    Joined:
    Feb 20, 2015
    Posts:
    84
    Hello,

    I've encountered a bug in the standard assets depth of field shader : when using DX11 on forward rendering with image effects and no HDR, near blur is inverted on the Y axis. It works fine with HDR.

    I've fixed the problem by adding
    Code (cg):
    1.  
    2. struct v2fFg
    3. {
    4.     float4 pos : SV_POSITION;
    5.    float2 uv : TEXCOORD0;
    6.    float2 uv1 : TEXCOORD1;
    7.    float2 uv2 : TEXCOORD2;
    8. };
    9. v2fFg vertFgFlip( appdata_img v)
    10. {
    11.    v2fFg o;
    12.    o.pos = mul (UNITY_MATRIX_MVP, v.vertex);
    13.    o.uv2.xy = v.texcoord.xy;
    14.    o.uv1.xy = v.texcoord.xy;
    15.    o.uv.xy = v.texcoord.xy;
    16.  
    17.    #if UNITY_UV_STARTS_AT_TOP
    18.    if (_MainTex_TexelSize.y < 0)
    19.    {
    20.       o.uv.y = 1-o.uv.y;
    21.       o.uv2.y = 1-o.uv2.y;
    22.    }
    23.    #endif          
    24.        
    25.    return o;
    26. }
    27.  
    I then changed every tex2d calls on _FgOverlap using i.uv2.xy instead of i.uv1.xy.

    I've joined my modified file. It might not be the best solution but it seems to work for me.
    Hope it can help.
     

    Attached Files: