Coordinates Flipping

For example you have drawn a Cube on the right side of the screen, after flipping the coordinates it will appear on the left side.


[IMPORTANT]
If you are visiting this website for the very first time, please have a look at the first tutorial, it would help you to understand this tutorial better.
Click Here!

Project Setup

First add a plane then rotate it's face toward camera, or set the plane rotation to (90, 180, 0).
Add a unlit shader and apply it to a material, and apply that material to the plane.

open the Unlit Shader in Visual Studio.

Bootstrap Themes



With this rotation of plane, the origin of i.uv is bottom left corner.

Bootstrap Themes

We will start from this point, with UV's origin shifted at the center.
If you don't know how to shift the origin to center, you could follow this tutorial for understanding.
Click Here !

Bootstrap Themes
Bootstrap Themes

UV.x have range of value (-0.5 . -0.25 . 0.0 . 0.25 . 0.5) from left to right.
UV.y have range of value (-0.5 . -0.25 . 0.0 . 0.25 . 0.5) from bottom to top.

Draw a cube on top right side.

Bootstrap Themes
Bootstrap Themes
Bootstrap Themes

If we multiply UV.x with -1. e.g UV.x *= -1
It will flip the coordinates.

For example, before flipping at pixel A the UV.x is 0.2, and at pixel B the UV.x is -0.5
After flipping, UV.x at pixel is -0.2 & UV.x at pixel B is 0.5
Because 0.2 * -1 = -0.2 & -0.5 * -1 = 0.5

Before Flipping

Bootstrap Themes
Bootstrap Themes

After Flipping

Bootstrap Themes

Similarly for y-axis.

Before Flipping

Bootstrap Themes
Bootstrap Themes

After Flipping

Bootstrap Themes