Last active
January 11, 2016 23:55
-
-
Save Crushy/aee0b7782fa053545d66 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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