I'm trying to render an object using it's uv's as coordinates. I want the object to appears as a 2D overlay. I can make the object render, however it is a flat, unwrapped object, but still in 3D space around the origin. I've tried writing the position out to clip space but nothing renders. I'm also wanting to do this for pre-transformed vertices, so I store a pre-transformed vertex in clip space [-1,-1] to [1,1] and just pass this through the vert program. However I just can't make it rendering anything. Code (CSharp): Shader "Custom/Flat" { Properties { } SubShader { Tags { "RenderType"="Opaque" } Pass { CGPROGRAM #pragma vertex vert #pragma fragment frag #include "UnityCG.cginc" struct v2f { float4 pos : SV_POSITION; }; v2f vert (appdata_base v) { v2f o; float4 pos; pos = float4(v.texcoord.x,v.texcoord.y, 0.0, 1.0); o.pos = pos; //o.pos = mul (UNITY_MATRIX_MVP, pos); return o; } half4 frag (v2f i) : COLOR { return half4(0.0,0.0,1.0,1.0); } ENDCG } } FallBack "Diffuse" } If I comment in the matrix multiple line UNITY_MATRIX_MVP, then it will render a sphere object as a flat grid, but still in 3D as a flat plane. I want to output a clip space, or screen space position, so it acts as an overlay. I kind of expected it to appear in one of quadrants of the screen as the uv's go from 0 to 1. I'll obviously need to do some additional math to convert it into clip space, but I can't even get a single triangle to appear yet. I suspect I have the Z or W component wrongly set but I've tried a load of combination and still can't make it work. How do I go about this in Unity? What space should the vertex shader been outputing?
Never mind... It does work. It just doesn't display in the Editor window. With the UNITY_MATRIX_MVP line added in the Scene window does show the flattened objected, just in 3D space at the origin. Without it, the editor doesn't draw anything for the sphere. However if I select the Camera, then the Camera Preview window does show the flattened object as I would expect, drawn in the top right quadrant of the screen. This also obviously works in the Game window. I would still however be interested to know why the Scene window doesn't work? How does Unity prevent the shader from rendering to the screen in the Scene view. That is odd.