Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2021
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.08 KB | None | 0 0
  1. Shader "NPR/Trippy Plasma Skull"
  2. {
  3. Properties
  4. {
  5. _MainTex ("Texture", 2D) = "white" {}
  6. _Tint("Colour Tint", Color) = (1,1,1,1)
  7. _Speed("Speed", Range(1, 100)) = 10
  8. _Scale1("Scale 1", Range(0.1, 10)) = 2
  9. _Scale2("Scale 2", Range(0.1, 10)) = 2
  10. _Scale3("Scale 3", Range(0.1, 10)) = 2
  11. _Scale4("Scale 4", Range(0.1, 10)) = 2
  12. }
  13. SubShader
  14. {
  15. Tags { "RenderType"="Opaque" "LightMode" = "ForwardBase"}
  16. LOD 100
  17.  
  18. Pass
  19. {
  20. CGPROGRAM
  21. #pragma vertex vert
  22. #pragma fragment frag
  23.  
  24. #include "UnityCG.cginc"
  25. #include "Lighting.cginc"
  26.  
  27. struct appdata
  28. {
  29. float4 vertex : POSITION;
  30. float2 uv : TEXCOORD0;
  31. float3 normal : NORMAL;
  32. };
  33.  
  34. struct v2f
  35. {
  36. float2 uv : TEXCOORD0;
  37. float3 diffusecolor : COLOR;
  38. float4 vertex : SV_POSITION;
  39. float3 worldPos : TEXCOORD1;
  40. float3 worldNormal : TEXCOORD2;
  41. };
  42.  
  43. sampler2D _MainTex;
  44. float4 _MainTex_ST;
  45. float2 uv_MainTex;
  46. float3 worldPos;
  47. float4 _Tint;
  48. float _Speed;
  49. float _Scale1;
  50. float _Scale2;
  51. float _Scale3;
  52. float _Scale4;
  53. fixed4 _Diffuse;
  54.  
  55. v2f vert (appdata v)
  56. {
  57. v2f o;
  58. o.vertex = UnityObjectToClipPos(v.vertex);
  59. o.worldPos = mul(unity_ObjectToWorld, v.vertex);
  60. o.worldNormal = mul(v.normal, (float3x3)unity_WorldToObject);
  61. o.uv = TRANSFORM_TEX(v.uv, _MainTex);
  62. return o;
  63. }
  64.  
  65. fixed4 frag (v2f i) : SV_Target
  66. {
  67. const float PI = 3.141592653589793238462;
  68. float timePassed = _Time.x * _Speed;
  69.  
  70. //screen coordinates: small values for the sin
  71. float xpos = i.vertex.x * 0.001;
  72. float ypos = i.vertex.y * 0.001;
  73.  
  74. //vertical
  75. float plasmaColour = sin(i.worldPos.x * _Scale1 + timePassed);
  76.  
  77. //horizontal
  78. plasmaColour += sin(i.worldPos.z * _Scale2 + timePassed);
  79.  
  80. //diagonal
  81. plasmaColour += sin(_Scale3 * worldPos.x * sin(timePassed / 2.0) + worldPos.z * cos(timePassed / 3) + timePassed);
  82.  
  83. //circular
  84. float plasmaColour1 = pow(xpos + 0.5 * sin(timePassed / 5), 2);
  85. float plasmaColour2 = pow(ypos + 0.5 * sin(timePassed / 5), 2);
  86. plasmaColour += sin(sqrt(_Scale4 * (plasmaColour1 + plasmaColour2) + 1 + timePassed));
  87.  
  88. //get ambient term
  89. float4 ambient = UNITY_LIGHTMODEL_AMBIENT.xyzw;
  90. float worldNormal = normalize(i.worldNormal);
  91.  
  92. fixed4 worldLightDir = normalize(_WorldSpaceLightPos0.xyzw);
  93. //compute diffuse term
  94. fixed4 diffuse = _LightColor0.rgba *_Diffuse.rgba * saturate(dot(worldNormal, worldLightDir));
  95. fixed3 diffuseColor = ambient + diffuse;
  96.  
  97. float finalColor = tex2D(_MainTex, i.uv) * _Tint * diffuseColor;
  98.  
  99. // vertical color
  100. finalColor.r = sin(plasmaColour / 4.0 * PI);
  101.  
  102. return finalColor;
  103. }
  104. ENDCG
  105. }
  106. }
  107. }
  108.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement