Skip to content

Instantly share code, notes, and snippets.

@ArieLeo
Forked from aras-p/using_vpos.shader
Created December 22, 2015 06:27
Show Gist options
  • Save ArieLeo/a54c0d393c8c0b83f191 to your computer and use it in GitHub Desktop.
Save ArieLeo/a54c0d393c8c0b83f191 to your computer and use it in GitHub Desktop.
Using VPOS
// 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