Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Shader "Jove/Forward/Particles/Unlit"
- {
- Properties
- {
- _Color ("Color", Color) = (1.0,1.0,1.0,1.0)
- _MainTex ("Particle Texture", 2D) = "white" {}
- _Absorption ("Absorbtion", Range(0.0, 1.0)) = 1.0
- _Addition ("Addition", Float) = 1.0
- _InvFade ("Soft Particles Factor", Range(0.01,3.0)) = 1.0
- }
- SubShader
- {
- Tags
- {
- "RenderType" = "Transparent"
- "Queue" = "Transparent"
- "IgnoreProjector" = "True"
- }
- Pass
- {
- Cull Off
- ZWrite Off
- Fog { Mode Off }
- ColorMask RGB
- Blend One OneMinusSrcAlpha
- CGPROGRAM
- #pragma vertex vert
- #pragma fragment frag
- #pragma target 4.0
- #include "Includes/JoveCG.cginc"
- #include "UnityCG.cginc"
- sampler2D _MainTex;
- float4 _Color;
- float _Absorption;
- float _Addition;
- float _InvFade;
- struct appdata_t {
- float4 vertex : POSITION;
- float4 color : COLOR;
- float2 texcoord : TEXCOORD0;
- };
- struct v2f {
- float4 pos : SV_POSITION;
- float4 color : COLOR;
- float2 texcoord : TEXCOORD0;
- #if (SOFT_PARTICLES == SOFT_PARTICLES_ON)
- float4 clipPos : TEXCOORD1;
- #endif
- };
- float4 _MainTex_ST;
- v2f vert (appdata_t v)
- {
- v2f o;
- o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
- o.color = v.color * _Color;
- o.texcoord = TRANSFORM_TEX(v.texcoord,_MainTex);
- #if (SOFT_PARTICLES == SOFT_PARTICLES_ON)
- o.clipPos = o.pos;
- #endif
- return o;
- }
- float4 frag (v2f i) : SV_Target
- {
- #if (SOFT_PARTICLES == SOFT_PARTICLES_ON)
- float2 screenUV = i.clipPos.xy / i.clipPos.w;
- screenUV.x = screenUV.x * 0.5f + 0.5f;
- screenUV.y = 0.5f - screenUV.y * 0.5f;
- float sceneZ = SampleDepth(screenUV);
- float partZ = i.clipPos.z;
- float fade = saturate (_InvFade * (sceneZ-partZ));
- #else
- float fade = 1.0;
- #endif
- float4 clr = i.color * tex2D(_MainTex, i.texcoord);
- float alpha = fade * clr.a;
- return float4(clr.rgb * alpha * _Addition, alpha * _Absorption);
- }
- ENDCG
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement