156 lines
4.6 KiB
Plaintext
156 lines
4.6 KiB
Plaintext
|
Shader "Terrain/Tile Terrain"
|
||
|
{
|
||
|
// The properties block of the Unity shader. In this example this block is empty
|
||
|
// because the output color is predefined in the fragment shader code.
|
||
|
Properties
|
||
|
{
|
||
|
}
|
||
|
|
||
|
// The SubShader block containing the Shader code.
|
||
|
SubShader
|
||
|
{
|
||
|
// SubShader Tags define when and under which conditions a SubShader block or
|
||
|
// a pass is executed.
|
||
|
Tags
|
||
|
{
|
||
|
"RenderType"="TransparentCutout"
|
||
|
"IgnoreProjector" = "True"
|
||
|
"PreviewType" = "Plane"
|
||
|
"UniversalMaterialType" = "Unlit"
|
||
|
"Queue" = "AlphaTest"
|
||
|
"RenderPipeline" = "UniversalPipeline"
|
||
|
}
|
||
|
Blend One Zero
|
||
|
AlphaToMask On
|
||
|
|
||
|
Pass
|
||
|
{
|
||
|
// The HLSL code block. Unity SRP uses the HLSL language.
|
||
|
HLSLPROGRAM
|
||
|
|
||
|
// This line defines the name of the vertex shader.
|
||
|
#pragma vertex vert
|
||
|
// This line defines the name of the fragment shader.
|
||
|
#pragma fragment frag
|
||
|
|
||
|
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||
|
|
||
|
struct Attributes
|
||
|
{
|
||
|
float4 positionOS : POSITION;
|
||
|
};
|
||
|
|
||
|
struct Varyings
|
||
|
{
|
||
|
float4 positionCS : SV_POSITION;
|
||
|
float2 uv : TEXCOORD0;
|
||
|
float3 positionWS : TEXCOORD1;
|
||
|
};
|
||
|
|
||
|
CBUFFER_START(UnityPerMaterial)
|
||
|
half4 _Color1a;
|
||
|
half4 _Color1b;
|
||
|
half4 _Color2a;
|
||
|
half4 _Color2b;
|
||
|
CBUFFER_END
|
||
|
|
||
|
SamplerState my_point_clamp_sampler;
|
||
|
|
||
|
Varyings vert(Attributes IN)
|
||
|
{
|
||
|
Varyings OUT;
|
||
|
|
||
|
OUT.positionCS = TransformObjectToHClip(IN.positionOS.xyz);
|
||
|
OUT.positionWS = TransformObjectToWorld(IN.positionOS.xyz);
|
||
|
// OUT.uv = TransformWorldToControlMapUVs(OUT.positionWS);
|
||
|
|
||
|
return OUT;
|
||
|
}
|
||
|
|
||
|
half4 frag(Varyings IN) : SV_Target
|
||
|
{
|
||
|
return half4(1, 1, 1, 1);
|
||
|
// half4 controlMapPoint = SamplePointControlMap(IN.uv);
|
||
|
// clip(controlMapPoint.a - 0.01f);
|
||
|
//
|
||
|
// half4 baseColor;
|
||
|
// bool isDark = GetCheckerPattern(IN.positionWS);
|
||
|
// if(controlMapPoint.r > 0.1)
|
||
|
// baseColor = isDark ? _Color2b : _Color2a;
|
||
|
// else
|
||
|
// baseColor = isDark ? _Color1b : _Color1a;
|
||
|
//
|
||
|
// ApplyShadow(baseColor.rgb, SampleShadowMask(IN.uv, controlMapPoint));
|
||
|
//
|
||
|
// return baseColor;
|
||
|
}
|
||
|
ENDHLSL
|
||
|
}
|
||
|
|
||
|
Pass
|
||
|
{
|
||
|
Name "DepthOnly"
|
||
|
Tags
|
||
|
{
|
||
|
"LightMode" = "DepthOnly"
|
||
|
}
|
||
|
|
||
|
// -------------------------------------
|
||
|
// Render State Commands
|
||
|
ZWrite On
|
||
|
ColorMask R
|
||
|
|
||
|
HLSLPROGRAM
|
||
|
#pragma target 2.0
|
||
|
|
||
|
// -------------------------------------
|
||
|
// Shader Stages
|
||
|
#pragma vertex vert
|
||
|
#pragma fragment frag
|
||
|
|
||
|
// -------------------------------------
|
||
|
// Includes
|
||
|
|
||
|
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||
|
|
||
|
struct Attributes
|
||
|
{
|
||
|
float4 positionOS : POSITION;
|
||
|
float4 uv0 : TEXCOORD0;
|
||
|
};
|
||
|
|
||
|
struct Varyings
|
||
|
{
|
||
|
float4 positionCS : SV_POSITION;
|
||
|
float2 uv : TEXCOORD0;
|
||
|
};
|
||
|
|
||
|
CBUFFER_START(UnityPerMaterial)
|
||
|
half4 _Color1a;
|
||
|
half4 _Color1b;
|
||
|
half4 _Color2a;
|
||
|
half4 _Color2b;
|
||
|
CBUFFER_END
|
||
|
|
||
|
Varyings vert(Attributes IN)
|
||
|
{
|
||
|
Varyings OUT;
|
||
|
|
||
|
OUT.positionCS = TransformObjectToHClip(IN.positionOS.xyz);
|
||
|
float3 positionWS = TransformObjectToWorld(IN.positionOS.xyz);
|
||
|
// OUT.uv = TransformWorldToControlMapUVs(positionWS);
|
||
|
|
||
|
return OUT;
|
||
|
}
|
||
|
|
||
|
half4 frag(Varyings IN) : SV_Target
|
||
|
{
|
||
|
// half4 controlMap = SamplePointControlMap(IN.uv);
|
||
|
// clip(controlMap.a - 0.01f);
|
||
|
return IN.positionCS.z;
|
||
|
}
|
||
|
|
||
|
ENDHLSL
|
||
|
}
|
||
|
}
|
||
|
}
|