I've been trying to work with more complicated shaders, and have run into issues with the coordinate systems used by the vertex shader and texture sampler. In short: they don't seem to make any sense, and when trying to test them I end up getting inconsistent results. To make matters worse, the internet has little in the way of documentation, and most of the information I've found seems to expect me to know how this works already. I was hoping someone could clarify the following:
- The vertex shaders pass an (x, y, z) representing a location on the render target. What are acceptable values for x, y, and z?
- How do x and y correspond to the width and height of the back buffer (assuming that it's the render target)?
- How do x and y correspond to the width and height on an output texture (assuming that it's the render target)?
- When x=0 and y=0 where does the vertex sit, location-wise?
- The texture samplers sample a texture at a (u, v) coordinate. What are acceptable values for u and v?
- How do u and v correspond with the width and height of the texture being sampled?
- How do AGAL's wrap, clamp, and repeat flags alter sampling, and what is the default behavior when one isn't given?
- when sampling at u=0 and v=0, which pixel is returned location-wise?
EDIT: From my tests, I believe the answers are:
- Unsure
- -1 is left/bottom, 1 is right/top
- Unsure
- At the center of the output
- Unsure
- 0 is left/bottom, 1 is right/top
- Unsure
- The far bottom-left of the texture