Skip to content

Commit

Permalink
Create ObsidianTestShader.shader
Browse files Browse the repository at this point in the history
  • Loading branch information
Xlinka committed Jul 2, 2024
1 parent 8217491 commit 538e480
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions ProjectObsidian/Shaders/ObsidianTestShader.shader
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
Shader "ObsidianPlus/ObsidianTestShader"
{
SubShader
{
// This shader renders objects with an opaque render type.
// It transforms vertex positions to clip space and calculates the view direction.
// The fragment shader outputs the view direction as the RGB color with alpha set to 1.
// Created by LeCloutPanda

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;
float3 viewDir : TEXCOORD3;
};

v2f vert (appdata v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.viewDir = normalize(WorldSpaceViewDir(v.vertex));
return o;
}

fixed4 frag (v2f i) : SV_Target
{
return float4(i.viewDir, 1);
}
ENDCG
}
}
}

0 comments on commit 538e480

Please sign in to comment.