Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Shader "Custom/Triplanar" {
- Properties {
- colour("Texture", 2D) = "white"{}
- scale("Scale", Float) = 1
- }
- SubShader {
- Tags { "RenderType"="Opaque" }
- 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 colour;
- float scale;
- struct Input {
- float3 worldPos;
- float3 worldNormal;
- };
- float3 triplanar(float3 scaledWorldPos, float3 blendAxes) {
- float3 xProjection = tex2D(colour, scaledWorldPos.yz) * blendAxes.x;
- float3 yProjection = tex2D(colour, scaledWorldPos.xz) * blendAxes.y;
- float3 zProjection = tex2D(colour, scaledWorldPos.xy) * blendAxes.z;
- return xProjection + yProjection + zProjection;
- }
- void surf (Input IN, inout SurfaceOutputStandard o) {
- float3 blendAxes = abs(IN.worldNormal);
- blendAxes /= blendAxes.x + blendAxes.y + blendAxes.z;
- o.Albedo = triplanar(IN.worldPos/scale, blendAxes);
- }
- ENDCG
- }
- FallBack "Diffuse"
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement