duck

Legacy shader world space planar uv mapping

Mar 6th, 2015
315
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. Shader "WorldUV/Diffuse" {
  2. Properties {
  3. _Color ("Main Color", Color) = (1,1,1,1)
  4. _MainTex ("Base (RGB)", 2D) = "white" {}
  5. _Scale ("Texture Scale", Float) = 1
  6. }
  7. SubShader {
  8. Tags { "RenderType"="Opaque" }
  9. LOD 200
  10.  
  11. CGPROGRAM
  12. #pragma surface surf Lambert
  13.  
  14. sampler2D _MainTex;
  15. fixed4 _Color;
  16. float _Scale;
  17.  
  18. struct Input {
  19. float3 worldNormal;
  20. float3 worldPos;
  21. };
  22.  
  23. void surf (Input IN, inout SurfaceOutput o) {
  24. float2 uv;
  25. if (abs(IN.worldNormal.x) > 0.5) {
  26. uv = IN.worldPos.yz;
  27. } else if (abs(IN.worldNormal.z) > 0.5) {
  28. uv = IN.worldPos.xy;
  29. } else {
  30. uv = IN.worldPos.xz;
  31. }
  32. fixed4 c = tex2D(_MainTex, uv * _Scale) * _Color;
  33. o.Albedo = c.rgb;
  34. o.Alpha = c.a;
  35. }
  36. ENDCG
  37. }
  38.  
  39. Fallback "VertexLit"
  40. }
Advertisement
Add Comment
Please, Sign In to add comment