Skip to content

Instantly share code, notes, and snippets.

@lsei
Created January 9, 2020 23:05
Show Gist options
  • Save lsei/71e7f7cb3854de97b6d6140e7e2e0f90 to your computer and use it in GitHub Desktop.
Save lsei/71e7f7cb3854de97b6d6140e7e2e0f90 to your computer and use it in GitHub Desktop.
Shader "Unlit/WhereAmITestShader"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
}
SubShader
{
Tags { "RenderType"="Opaque" }
LOD 100
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
};
struct v2f
{
float2 uv : TEXCOORD0;
float4 vertex : SV_POSITION;
// Add another float4 to the object that carries the data from the verticies to the fragmet shaders.
float4 original_vertex : TEXCOORD1;
};
v2f vert (appdata v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
// Pass the original data through here.
o.original_vertex = v.vertex;
return o;
}
fixed4 frag (v2f i) : SV_Target
{
// Use the original vertex value to determine the fragment color.
fixed4 col = i.original_vertex;
return col;
}
ENDCG
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment