Skip to content

Instantly share code, notes, and snippets.

@Crushy
Last active January 11, 2016 23:55
Show Gist options
  • Save Crushy/aee0b7782fa053545d66 to your computer and use it in GitHub Desktop.
Save Crushy/aee0b7782fa053545d66 to your computer and use it in GitHub Desktop.
Shader "Tri-Planar Bumped" {
Properties {
_Side("Side", 2D) = "white" {}
_BumpMap ("Bumpmap", 2D) = "bump" {}
_Top("Top", 2D) = "white" {}
_SideScale("Side Scale", Float) = 2
_TopScale("Top Scale", Float) = 2
}
SubShader {
Tags {
"RenderType"="Opaque"
}
CGPROGRAM
#pragma target 3.0
#pragma surface surf Lambert
sampler2D _Side;
sampler2D _Top;
sampler2D _BumpMap;
float _SideScale, _TopScale;
struct Input {
float3 worldPos;
float3 worldNormal;
};
void surf (Input IN, inout SurfaceOutput o) {
half3 blendWeights = abs( IN.worldNormal.xyz );
//Sample textures
half4 colourSide = tex2D(_Side, (IN.worldPos.yz * _SideScale));
half4 colourTop = tex2D(_Top, (IN.worldPos.zx * _TopScale));
half4 colourBottom = tex2D(_Side, (IN.worldPos.xy * _SideScale));
half4 final;
final = colourSide;
o.Albedo = final.rgb;
o.Normal = UnpackNormal (tex2D (_BumpMap, IN.worldPos.yz * _SideScale));
}
ENDCG
}
Fallback "Diffuse"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment