Advertisement
Guest User

Untitled

a guest
May 20th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.89 KB | None | 0 0
  1. // Upgrade NOTE: replaced '_World2Object' with 'unity_WorldToObject'
  2.  
  3. // Upgrade NOTE: replaced '_Object2World' with 'unity_ObjectToWorld'
  4.  
  5. Shader "PPP/BendWorld2"
  6. {
  7. Properties
  8. {
  9. _Color ("Main Color", Color) = (1,1,1,1)
  10. _MainTex ("Base (RGB)", 2D) = "white" {}
  11. }
  12. SubShader
  13. {
  14. Tags { "RenderType" = "Opaque" }
  15. LOD 200
  16.  
  17. CGPROGRAM
  18. #pragma surface surf Lambert vertex:vert //addshadow
  19.  
  20. //Global properities to be set by BendControllerRadial
  21. uniform half3 _CurveOrigin;
  22. uniform fixed3 _ReferenceDirection;
  23. uniform half _Curvature;
  24. uniform fixed3 _Scale;
  25. uniform half _FlatMargin;
  26. uniform half _HorizonWaveFrequency;
  27.  
  28.  
  29. sampler2D _MainTex;
  30. fixed4 _Color;
  31.  
  32. //uniform float _Curvature;
  33.  
  34. struct Input
  35. {
  36. float2 uv_MainTex;
  37. };
  38.  
  39. half4 Bend(half4 v)
  40. {
  41. half4 wpos = mul(unity_ObjectToWorld, v);
  42.  
  43. half2 xzDist = (wpos.xz - _CurveOrigin.xz) / _Scale.xz;
  44. half dist = length(xzDist);
  45.  
  46. half2 direction = lerp(_ReferenceDirection.xz, xzDist, min(dist, 1));
  47.  
  48. half theta = acos(clamp(dot(normalize(direction), _ReferenceDirection), -1, 1));
  49.  
  50. dist = max(0, dist - _FlatMargin);
  51.  
  52. wpos.y -= dist * dist * _Curvature * cos(theta * _HorizonWaveFrequency);
  53.  
  54. wpos = mul(unity_WorldToObject, wpos);
  55.  
  56. return wpos;
  57.  
  58. }
  59. void vert(inout appdata_full v)
  60. {
  61. /*float4 worldSpace = mul(unity_ObjectToWorld, v.vertex);
  62. worldSpace.xyz -= _WorldSpaceCameraPos.xyz;
  63. worldSpace = float4(0.0f, (worldSpace.x * worldSpace.x) * -_Curvature, 0.0f, 0.0f);
  64.  
  65. v.vertex = mul(unity_WorldToObject, worldSpace);*/
  66.  
  67. half4 vpos = Bend(v.vertex);
  68.  
  69. v.vertex = vpos;
  70. }
  71.  
  72.  
  73. void surf(Input IN, inout SurfaceOutput o)
  74. {
  75. fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color;
  76. o.Albedo = c.rgb;
  77. o.Alpha = c.a;
  78. }
  79.  
  80. ENDCG
  81. }
  82. Fallback "Mobile/Diffuse"
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement