65 lines
1.7 KiB
Text
65 lines
1.7 KiB
Text
|
Shader "CrispyPin/Triplanar"
|
||
|
{
|
||
|
Properties
|
||
|
{
|
||
|
_Color ("Color", Color) = (1,1,1,1)
|
||
|
_TexX ("X texture", 2D) = "white" {}
|
||
|
_TexY ("Y texture", 2D) = "white" {}
|
||
|
_TexZ ("Z texture", 2D) = "white" {}
|
||
|
}
|
||
|
SubShader
|
||
|
{
|
||
|
Tags { "RenderType"="Opaque" }
|
||
|
Cull off
|
||
|
LOD 200
|
||
|
|
||
|
CGPROGRAM
|
||
|
// Physically based Standard lighting model, and enable shadows on all light types
|
||
|
#pragma surface surf Standard fullforwardshadows
|
||
|
|
||
|
// Use shader model 3.0 target, to get nicer looking lighting
|
||
|
#pragma target 3.0
|
||
|
|
||
|
sampler2D _TexX;
|
||
|
sampler2D _TexY;
|
||
|
sampler2D _TexZ;
|
||
|
|
||
|
struct Input
|
||
|
{
|
||
|
float3 worldPos;
|
||
|
float3 worldNormal;
|
||
|
};
|
||
|
|
||
|
fixed4 _Color;
|
||
|
|
||
|
// Add instancing support for this shader. You need to check 'Enable Instancing' on materials that use the shader.
|
||
|
// See https://docs.unity3d.com/Manual/GPUInstancing.html for more information about instancing.
|
||
|
// #pragma instancing_options assumeuniformscaling
|
||
|
UNITY_INSTANCING_BUFFER_START(Props)
|
||
|
// put more per-instance properties here
|
||
|
UNITY_INSTANCING_BUFFER_END(Props)
|
||
|
|
||
|
void surf (Input IN, inout SurfaceOutputStandard o)
|
||
|
{
|
||
|
// Albedo comes from a texture tinted by color
|
||
|
// fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color;
|
||
|
// float3 amounts = IN.worldNormal / (IN.worldNormal.x+IN.worldNormal.y+IN.worldNormal.z);
|
||
|
float3 amounts = float3(
|
||
|
dot(IN.worldNormal, float3(1,0,0)),
|
||
|
dot(IN.worldNormal, float3(0,1,0)),
|
||
|
dot(IN.worldNormal, float3(0,0,1)));
|
||
|
amounts = abs(amounts);
|
||
|
float3 uv = IN.worldPos;
|
||
|
fixed3 c = _Color
|
||
|
*(
|
||
|
tex2D (_TexZ, uv.xy) * amounts.z
|
||
|
+ tex2D (_TexY, uv.xz) * amounts.y
|
||
|
+ tex2D (_TexX, uv.zy) * amounts.x);
|
||
|
o.Albedo = c.rgb;
|
||
|
|
||
|
}
|
||
|
ENDCG
|
||
|
}
|
||
|
FallBack "Diffuse"
|
||
|
}
|