Effect pipeline broken?

This forum is currently in read-only mode.
From the Asset Store
Cat Ninja vs Monster Block is an exciting arcade game inspired by the break breaker style
  • Before posting to the tracker, I want to make sure that I am not doing anything wrong. I am currently testing for a few effects in mind, but the results are unexpected.

    For example, this code:

    float4 EffectProcess( float2 Tex : TEXCOORD0 ) : COLOR0
    {
        float4 color = tex2D( foreground, Tex.xy );
        float vpos = (Tex.y - boxTop) / pixelHeight;
        int test = vpos % 2;
        if(test == 0)
            color.rgb *= float3(0.5, 0.5, 0.5);
    
        return color;
    }[/code:20hyqrqi]
    
    leads to this result in the editor (better look at the original size):
    [url=http://www.bilderhoster.net/img.php?id=z5z9wjjs.jpg][/url]
    exactly what I expected. Every second line darkened, beginning with the first line. However, when I run the layout or export to exe, I get this result:
    [url=http://www.bilderhoster.net/img.php?id=hvgyjgwr.jpg][/url]
    
    How come? Any idea, or should I post to the tracker?
  • Coordinates in the runtime go from 0 to 1, from top to bottom and from left to right of the screen.

    In the Editor, though, this is from the edge of the EDITING WINDOW, not the layout, so effects get different coordinates.

    That said, you are testing for an int result of a modulus

    so if you were thinking integer pixels

    vpos=0 -> vpos%2 = 0, darken
    vpos=1 -> vpos%2 = 1, ignore
    vpos=2 -> vpos%2 = 0, darken
    vpos=3 -> vpos%2 = 0, ignore[/code:1wmitvxv]
    
    but the shader is fractional
    [code:1wmitvxv]
    vpos=0 -> vpos%2 = 0, darken
    vpos=0.3 -> vpos%2 = 0.3, ignore
    vpos=0.7-> vpos%2 = 0.7, ignore
    vpos=1 -> vpos%2 = 1, ignore
    vpos=1.2 -> vpos%2 = 1.2, ignore
    vpos=1.7 -> vpos%2 = 1.7, ignore
    vpos=2 -> vpos%2 = 0, darken[/code:1wmitvxv]
    
    As you can see, depending on the size in pixels the effect will look very different.
    
    I recommend the following test instead
    [code:1wmitvxv]if(vpos%2 > 1)[/code:1wmitvxv]
    ALL THAT SAID.... yeah, the diagonal line shouldn't be there at all, and the scanlining should be regular, so yeah it looks like a bug in effect coordinates.....
    
    MORE TESTING REVEALS that this effect only happens when there's more scanlines than physically possible (half the vertical resolution). Why? no idea, but while testing, I ended up writing a full scanlines shader, so here it is.
    
    EDIT: Posted as addon: [url]http://www.scirra.com/forum/viewtopic.php?f=29&t=5643[/url]
    you may change number of shown scanlines, scanline width and intensity of the effect. No offset, because I didn't feel like it.
  • Coordinates in the runtime go from 0 to 1, from top to bottom and from left to right of the screen.

    In the Editor, though, this is from the edge of the EDITING WINDOW, not the layout, so effects get different coordinates.

    That said, you are testing for an int result of a modulus

    so if you were thinking integer pixels

    vpos=0 -> vpos%2 = 0, darken
    vpos=1 -> vpos%2 = 1, ignore
    vpos=2 -> vpos%2 = 0, darken
    vpos=3 -> vpos%2 = 0, ignore[/code:35mxhfk7]
    
    but the shader is fractional
    [code:35mxhfk7]
    vpos=0 -> vpos%2 = 0, darken
    vpos=0.3 -> vpos%2 = 0.3, ignore
    vpos=0.7-> vpos%2 = 0.7, ignore
    vpos=1 -> vpos%2 = 1, ignore
    vpos=1.2 -> vpos%2 = 1.2, ignore
    vpos=1.7 -> vpos%2 = 1.7, ignore
    vpos=2 -> vpos%2 = 0, darken[/code:35mxhfk7]
    
    As you can see, depending on the size in pixels the effect will look very different.
    
    I recommend the following test instead
    [code:35mxhfk7]if(vpos%2 > 1)[/code:35mxhfk7]
    ALL THAT SAID.... yeah, the diagonal line shouldn't be there at all, and the scanlining should be regular, so yeah it looks like a bug in effect coordinates.....
    
    MORE TESTING REVEALS that this effect only happens when there's more scanlines than physically possible (half the vertical resolution). Why? no idea, but while testing, I ended up writing a full scanlines shader, so here it is.
    
    EDIT: Posted as addon: [url]http://www.scirra.com/forum/viewtopic.php?f=29&t=5643[/url]
    you may change number of shown scanlines, scanline width and intensity of the effect. No offset, because I didn't feel like it.
    

    Thank you very much, madster

    I am mislead by "pixelHeight". I thought it was the factor, the height of one pixel in units and that coordinates would give results in units orienting at pixelHeights, so that dividing would lead to integer pixel values. Listened and learned.

    I will post to the tracker, and hopefully find workarounds for the bug in transmitting the coordinates to the shader.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I am mislead by "pixelHeight". I thought it was the factor, the height of one pixel in units and that coordinates would give results in units orienting at pixelHeights, so that dividing would lead to integer pixel values. Listened and learned.

    Actually you could be right. I'm rather new at shaders. Anyway, turns out the artifacts only happen when scanlines are "packed in too tight", which is useless anyway =)

    (my effect shows the same artifact if you increase the number of scanlines over half the vertical resolution)

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)