WorldCoordDiffuse.shader 1013 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. Shader "Custom/WorldCoord Diffuse" {
  2. Properties {
  3. _Color ("Main Color", Color) = (1,1,1,1)
  4. _MainTex ("Base (RGB)", 2D) = "white" {}
  5. _BaseScale ("Base Tiling", Vector) = (1,1,1,0)
  6. }
  7. SubShader {
  8. Tags { "RenderType"="Opaque" }
  9. LOD 150
  10. CGPROGRAM
  11. #pragma surface surf Lambert
  12. sampler2D _MainTex;
  13. fixed4 _Color;
  14. fixed3 _BaseScale;
  15. struct Input {
  16. float2 uv_MainTex;
  17. float3 worldPos;
  18. float3 worldNormal;
  19. };
  20. void surf (Input IN, inout SurfaceOutput o) {
  21. fixed4 texXY = tex2D(_MainTex, IN.worldPos.xy * _BaseScale.z);// IN.uv_MainTex);
  22. fixed4 texXZ = tex2D(_MainTex, IN.worldPos.xz * _BaseScale.y);// IN.uv_MainTex);
  23. fixed4 texYZ = tex2D(_MainTex, IN.worldPos.yz * _BaseScale.x);// IN.uv_MainTex);
  24. fixed3 mask = fixed3(
  25. dot (IN.worldNormal, fixed3(0,0,1)),
  26. dot (IN.worldNormal, fixed3(0,1,0)),
  27. dot (IN.worldNormal, fixed3(1,0,0)));
  28. fixed4 tex =
  29. texXY * abs(mask.x) +
  30. texXZ * abs(mask.y) +
  31. texYZ * abs(mask.z);
  32. fixed4 c = tex * _Color;
  33. o.Albedo = c.rgb;
  34. }
  35. ENDCG
  36. }
  37. FallBack "Diffuse"
  38. }