-
-
Save ArieLeo/a54c0d393c8c0b83f191 to your computer and use it in GitHub Desktop.
Using VPOS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// yeah it's not terribly nice | |
Shader "Foo" { | |
SubShader { | |
Pass { | |
CGPROGRAM | |
#pragma vertex vert | |
#pragma fragment frag | |
#pragma target 3.0 | |
#include "UnityCG.cginc" | |
#if defined(SHADER_API_D3D9) | |
#define VPOS_TYPE float2 | |
#else | |
#define VPOS_TYPE float4 | |
#endif | |
struct appdata_t { | |
float4 vertex : POSITION; | |
float2 texcoord : TEXCOORD0; | |
}; | |
struct v2f { | |
float2 texcoord : TEXCOORD0; | |
}; | |
v2f vert (appdata_t v, out float4 opos : SV_POSITION) | |
{ | |
v2f o; | |
opos = mul(UNITY_MATRIX_MVP, v.vertex); | |
o.texcoord = v.texcoord; | |
return o; | |
} | |
fixed4 frag (v2f i, VPOS_TYPE ppp : VPOS) : SV_Target | |
{ | |
fixed4 c = 0; | |
c.xy = ppp; | |
c.xy *= 0.01; | |
return c; | |
} | |
ENDCG | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment