Advertisement
Guest User

Untitled

a guest
Jan 9th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. // Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
  2.  
  3. Shader "Hidden/BlackHoleShader"
  4. {
  5. Properties
  6. {
  7. _MainTex ("Texture", 2D) = "white" {}
  8. }
  9. SubShader
  10. {
  11. // No culling or depth
  12. Cull Off ZWrite Off ZTest Always
  13.  
  14. Pass
  15. {
  16. CGPROGRAM
  17. #pragma vertex vert
  18. #pragma fragment frag
  19. #pragma fragmentoption ARB_precision_hint_fastest
  20.  
  21. #include "UnityCG.cginc"
  22.  
  23.  
  24. uniform sampler2D _MainTex;
  25. uniform float2 _Position;
  26. uniform float _Rad;
  27. uniform float _Ratio;
  28. uniform float _Distance;
  29.  
  30. struct v2f {
  31. float4 pos : POSITION;
  32. float2 uv : TEXCOORD0;
  33. };
  34.  
  35. v2f vert (appdata_img v){
  36. v2f o;
  37. o.pos = UnityObjectToClipPos(v.vertex);
  38. o.uv = v.texcoord;
  39. return o;
  40. }
  41.  
  42. fixed4 frag (v2f i) : COLOR {
  43. float2 offset = i.uv - _Position;
  44. float2 ratio = { _Ratio, 1 };
  45. float rad = length(offset/ratio);
  46. float deformation = 1 / pow(rad * pow(_Distance, 0.5), 2) * _Rad * 0.1;
  47.  
  48. offset = offset * (1 - deformation);
  49. offset += _Position;
  50.  
  51. half4 res = tex2D(_MainTex, offset);
  52.  
  53. if (rad * _Distance < _Rad) {
  54. //res = half4( 0, 0, 0, 0 );
  55. }
  56.  
  57. return res;
  58. }
  59.  
  60.  
  61. ENDCG
  62. }
  63. }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement