Why is it necessary to transform vertex coordinate in vertex shader?
Now this is something i thought was obvious, but it doesn't work as expected.
I know that in vertex shader we should use UnityObjectToClipPos() on vertex position, in order to transform it from object space to clip space. But what if i don't use it? What if i send vertex position straight through, without modifying it in any way?
Then what i assume should happen is that object position of a vertex goes through perspecive divide and then gets send to fragment shader. If w = 1, then object space position of a vertex should get interpreted as clip space position ( in range -1 to 1, i assume ), and it should get rendered with no problem.
But that doesn't happen. If you take standard unlit shader that Unity generates, and delete UnityObjectToClipPos(), then nothing gets rendered at all. Even though i use basic standard Quad mesh, so coordinates are withing -1 to 1 range.
Why does it happen like that? How to render vertices in object space directly?
Answer by skyparticle99ii · Apr 16, 2020 at 11:14 AM
I think i've found a solution: in Unity default 2D camera is at position ( 0, 0, -10 ), so it is looking in positive direction of z. And in clip space z axis is -1 closer to screen, and 1 farther from screen. So if you project your vertices into clip space directly, without transforming them, then you would see them from another side, which isn't rendered, because it is backside of triangles. If you turn off culling with "Cull off" command then object indeed gets rendered. You should also check if it's behind any other objects