SHADERed icon indicating copy to clipboard operation
SHADERed copied to clipboard

Texture coordinates are flipped on a plane + Why is a non-rotated plane rotated?

Open bencresty opened this issue 3 years ago • 0 comments

Walking my way through thebookofshaders.com, doing some examples, it turns out already the first example in the book shows a flipped result in SHADERed.

After doing some testing myself to be absolutely sure I'm seeing this right when using a plane in SHADERed the position (0,0) is displayed in the bottom right. I would expect (0,0) to be the bottomleft corner though.

This is the test I did:

float plotOrigin(vec2 p, float relSize) {
    if (p.x >= 0 && p.x <= relSize
        && p.y >= 0 && p.y <= relSize) {
        return 1.0;
    } else {
        return 0.0;
    }
}


void main() {
    vec3 backgroundColor = vec3(0.2, 0.2, 0.2); // gray
    vec3 plotColor = vec3(1.0, 1.0, 0.0); // yellow

    outColor = vec4(
        (plotOrigin(texCoordV.xy, 0.1) * plotColor) + backgroundColor,
        1.0);
}

And this is the output: image

As mentioned in https://github.com/dfranx/SHADERed/issues/244 it's probably the normal of the plane being in the wrong direction. Could this please be fixed? Thanks in advance!

Aside from this I don't really get why the plane is being rotated when rotation is set to 0 on all axis. I would expect a non rotated plane to face the camera of the viewport.

SHADERed version: 1.5.6

bencresty avatar Dec 22 '21 15:12 bencresty