Advertisement
Guest User

Untitled

a guest
Aug 31st, 2016
606
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. Shader "Maikel/FX/ClipSpaceShockwave"
  2. {
  3. Properties
  4. {
  5. _MainTex ("Texture", 2D) = "white" {}
  6. _Amplitude ("Amplitude", Range(0,1)) = 0
  7. }
  8. SubShader
  9. {
  10. Tags { "RenderType"="Opaque" }
  11. LOD 100
  12.  
  13. Pass
  14. {
  15. CGPROGRAM
  16. #pragma vertex vert
  17. #pragma fragment frag
  18.  
  19. #include "UnityCG.cginc"
  20.  
  21. struct appdata
  22. {
  23. float4 vertex : POSITION;
  24. float2 uv : TEXCOORD0;
  25. };
  26.  
  27. struct v2f
  28. {
  29. float2 uv : TEXCOORD0;
  30. float4 vertex : SV_POSITION;
  31.  
  32.  
  33. };
  34.  
  35. sampler2D _MainTex;
  36. float4 _MainTex_ST;
  37. float _Radius;
  38. float _Amplitude;
  39. float2 _ShockwavePos;
  40.  
  41. v2f vert (appdata v)
  42. {
  43. v2f o;
  44. o.vertex = v.vertex;
  45. o.uv = o.vertex * 0.5 + 0.5;
  46.  
  47. float2 diff=float2(o.uv.x-_ShockwavePos.x,o.uv.y-_ShockwavePos.y);
  48. float dist=sqrt(diff.x*diff.x+diff.y*diff.y);
  49. float2 uv_displaced = float2(o.uv.x,o.uv.y);
  50. float wavesize=0.2f;
  51. if (dist>_Radius) {
  52. if (dist<_Radius+wavesize) {
  53. float angle=(dist-_Radius)*2*3.141592654/wavesize;
  54. float cossin=(1-cos(angle))*0.5;
  55. uv_displaced.x-= cossin*diff.x* _Amplitude/dist;
  56. uv_displaced.y-= cossin*diff.y* _Amplitude/dist;
  57. }
  58. }
  59.  
  60. o.uv = uv_displaced;
  61.  
  62. return o;
  63. }
  64.  
  65. fixed4 frag (v2f i) : SV_Target
  66. {
  67. fixed4 col = tex2D(_MainTex, i.uv);
  68. return col;
  69. }
  70. ENDCG
  71. }
  72. }
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement