Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Shader "NPR/Trippy Plasma Skull"
- {
- Properties
- {
- _MainTex ("Texture", 2D) = "white" {}
- _Tint("Colour Tint", Color) = (1,1,1,1)
- _Speed("Speed", Range(1, 100)) = 10
- _Scale1("Scale 1", Range(0.1, 10)) = 2
- _Scale2("Scale 2", Range(0.1, 10)) = 2
- _Scale3("Scale 3", Range(0.1, 10)) = 2
- _Scale4("Scale 4", Range(0.1, 10)) = 2
- }
- SubShader
- {
- Tags { "RenderType"="Opaque" "LightMode" = "ForwardBase"}
- LOD 100
- Pass
- {
- CGPROGRAM
- #pragma vertex vert
- #pragma fragment frag
- #include "UnityCG.cginc"
- #include "Lighting.cginc"
- struct appdata
- {
- float4 vertex : POSITION;
- float2 uv : TEXCOORD0;
- float3 normal : NORMAL;
- };
- struct v2f
- {
- float2 uv : TEXCOORD0;
- float3 diffusecolor : COLOR;
- float4 vertex : SV_POSITION;
- float3 worldPos : TEXCOORD1;
- float3 worldNormal : TEXCOORD2;
- };
- sampler2D _MainTex;
- float4 _MainTex_ST;
- float2 uv_MainTex;
- float3 worldPos;
- float4 _Tint;
- float _Speed;
- float _Scale1;
- float _Scale2;
- float _Scale3;
- float _Scale4;
- fixed4 _Diffuse;
- v2f vert (appdata v)
- {
- v2f o;
- o.vertex = UnityObjectToClipPos(v.vertex);
- o.worldPos = mul(unity_ObjectToWorld, v.vertex);
- o.worldNormal = mul(v.normal, (float3x3)unity_WorldToObject);
- o.uv = TRANSFORM_TEX(v.uv, _MainTex);
- return o;
- }
- fixed4 frag (v2f i) : SV_Target
- {
- const float PI = 3.141592653589793238462;
- float timePassed = _Time.x * _Speed;
- //screen coordinates: small values for the sin
- float xpos = i.vertex.x * 0.001;
- float ypos = i.vertex.y * 0.001;
- //vertical
- float plasmaColour = sin(i.worldPos.x * _Scale1 + timePassed);
- //horizontal
- plasmaColour += sin(i.worldPos.z * _Scale2 + timePassed);
- //diagonal
- plasmaColour += sin(_Scale3 * worldPos.x * sin(timePassed / 2.0) + worldPos.z * cos(timePassed / 3) + timePassed);
- //circular
- float plasmaColour1 = pow(xpos + 0.5 * sin(timePassed / 5), 2);
- float plasmaColour2 = pow(ypos + 0.5 * sin(timePassed / 5), 2);
- plasmaColour += sin(sqrt(_Scale4 * (plasmaColour1 + plasmaColour2) + 1 + timePassed));
- //get ambient term
- float4 ambient = UNITY_LIGHTMODEL_AMBIENT.xyzw;
- float worldNormal = normalize(i.worldNormal);
- fixed4 worldLightDir = normalize(_WorldSpaceLightPos0.xyzw);
- //compute diffuse term
- fixed4 diffuse = _LightColor0.rgba *_Diffuse.rgba * saturate(dot(worldNormal, worldLightDir));
- fixed3 diffuseColor = ambient + diffuse;
- float finalColor = tex2D(_MainTex, i.uv) * _Tint * diffuseColor;
- // vertical color
- finalColor.r = sin(plasmaColour / 4.0 * PI);
- return finalColor;
- }
- ENDCG
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement