cvr-props/Assets/raymarched/tes.shader

90 lines
1.6 KiB
Text
Raw Normal View History

2023-06-17 21:13:30 +02:00
Shader "Unlit/tes"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
_Color ("Color", Color) = (1,1,1,1)
}
SubShader
{
Tags { "RenderType"="Opaque" }
LOD 100
ZWrite On
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
// make fog work
#pragma multi_compile_fog
#include "UnityCG.cginc"
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
};
struct v2f
{
float2 uv : TEXCOORD0;
// UNITY_FOG_COORDS(1)
float4 vertex : SV_POSITION;
float3 ro : TEXCOORD1;
float3 vert_obspace : TEXCOORD2;
};
struct fragOut
{
fixed4 col : SV_Target;
float depth : SV_Depth;
};
sampler2D _MainTex;
float4 _MainTex_ST;
float4 _Color;
v2f vert (appdata v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.vert_obspace = v.vertex;
o.ro = mul(unity_WorldToObject, float4(_WorldSpaceCameraPos, 1));
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
// UNITY_TRANSFER_FOG(o,o.vertex);
return o;
}
fragOut frag (v2f i)
{
// sample the texture
fixed4 col = tex2D(_MainTex, i.uv);
// apply fog
// UNITY_APPLY_FOG(i.fogCoord, col);
fragOut o;
// o.col = _Color*0.5;
o.col.a=1;
// o.depth = 1;
float3 rd = normalize(i.vert_obspace - i.ro);
float d = 0;//-0.1;
float4 vClipPos = mul(UNITY_MATRIX_VP, mul(unity_ObjectToWorld, i.vert_obspace));
// o.depth = (vClipPos.z / vClipPos.w + 1.0) * 0.5 ;
// o.col.r = o.depth;
// o.col.gb = i.ro;
return o;
}
ENDCG
}
}
}