[Discussion] vTex Coordinates?

0 favourites
  • 5 posts
From the Asset Store
Easy Isometric
$19.99 USD
EasyIsometric behavior helps creating an “isometric” perspective with 2D assets.
  • Hi all :)

    I just started looking into making some GLSL shaders, and I have a few questions about the coordinate system.

    1: What are the units for the vTex coordinate values? (e.g. pixels, sprite lengths, etc)

    2: What is the origin for the vTex coordinates? (e.g. corner of layout, corner of sprite, etc)

    3: Does the background need some kind of special coordinate conversion to ensure that it is sampled correctly? I ask because the "dodge" effect has the following line:

    [quote:sdoz8br7]lowp vec4 back = texture2D( samplerBack , mix( destStart , destEnd , vTex ) );

    It looks like "mix()" might be a lerp style function. It makes me wonder if vTex values run from 0 to 1 across a sprite, and so they are being used to lerp between the screen cords of the relevant patch of background, or something.

    4: What are the "destStart" and "destEnd" variables, and what are their units and origin?

    Just curious, thanks. :)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 1. Texture co-ordinates. These always range from 0 to 1.

    2. Always the top-left of the quad.

    3. Yes: sometimes the effect will have been rendered to an intermediate window-sized texture if multiple effects are involved. Therefore the effect is processing the background on a sub-rectangle of the texture, not the entire texture. This leads on to 4: destStart and destEnd are vec2s marking the rectangle of the sub-texture being processed. Mix is indeed like lerp, and so mixing from destStart to destEnd by vTex gives you the correct texture co-ordinate of the background pixel to sample corresponding to the foreground.

  • Wow, awesome. Thanks. :D

    A few more questions just occurred to me, actually.

    5: If you place an effect on a sprite, can you sample parts of a foreground sprite that are off-screen?

    Just checking because I played around with a blur, and it looks like it ignores pixels that are outside the visible screen area. More specifically it looks like sample coords that refer to off-screen locations are clamped to the closest equivalent on-screen location.

    6: Can the origin of the vTex coords ever be outside the visible screen area?

    i.e. If a foreground sprite's top-left corner moves off-screen, does the origin of the vTex coords move off screen with it, or are the vTex coords squeezed to fit inside the edges of the visible screen area?

    In Construct Classic, I vaguely recall the HLSL coords acting a little different as a sprite started moving off-screen.

    7: Is there any place I should look to find out more about the details of the Construct 2's GLSL related stuff, or is the forum the best place to ask about this kind of thing?

    Thanks again. :)

  • 5. No: nothing offscreen is actually rendered.

    6. No: the origin is always clamped to the visible area.

    7. You can ask C2 specific questions here, or browse through the other effects to see how they're written. For general GLSL questions though there's always the web

  • Sounds good. Thanks again. :)

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