Search Unity

Screen Flickering from UNITY_MATRIX_MVP in Unity 4.6

Discussion in 'Shaders' started by macdude2, Jul 27, 2015.

  1. macdude2

    macdude2

    Joined:
    Sep 22, 2010
    Posts:
    686
    I've been trying to fix a glow effect, namely the one called Glow11, which stopped working in 4.5 due to an weird offset issue. Anyhow, recently I've come to mess with it to try and fix it and was able to get pretty far.

    By adding in some offset values in the blur shader, I was able to correct the offset. However, after fixing this issue, there ended up being another issue, the screen now would start flicking when the glow filled up a large portion of the screen. Commenting out portions of code and whatnot, I was able to figure out the flicking was coming from the first line in the code below. Specifically, it seems to be the 'P' part of the matrix multiplication that is messing things up (and conversely making the glow look correct). A further note – the offset is not what is causing the flickering – removing the offset didn't eliminate the flickering...

    Would anyone know the flickering is occuring? I'd really appreciate any help, thanks a lot!

    Code (CSharp):
    1. o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
    2. o.uv[0] = v.texcoord[0] + float4(offX*.5,offY*.5,1,0);
    3. o.uv[1] = v.texcoord[1]+ float4(-offX*1.5,-offY*1.5,1,0);
    4. o.uv[2] = v.texcoord[2]+ float4(-offX,-offY,1.5,0);
    5. o.uv[3] = v.texcoord[3] + float4(-offX,-offY,1,0);
    6. o.uv[4] = v.texcoord[4] + float4(-offX,-offY,1,0);
    7. return o;