You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
116 lines
2.8 KiB
116 lines
2.8 KiB
Shader "Fluvio/Particles/No GrabPass/Additive Lit" { |
|
Properties { |
|
_TintColor("Tint Color", Color) = (1, 1, 1, 1) |
|
_MainTex ("Base (RGB)", 2D) = "gray" {} |
|
_BumpMap ("Distort (in RG channels)", 2D) = "blue" {} |
|
_GrabTex ("Refraction Texture", 2D) = "gray" {} |
|
_Distort ("Distort", Float) = 0.1 |
|
_Power ("Light Power", Range(0.0,5)) = 1 |
|
_WaveMod ("Wave Speed (XY) Wave Strength (ZW)", Vector) = (2, 6, .02, .025) |
|
_InvFade ("Soft Particles Factor", Range(0.01,3.0)) = 1.0 |
|
_Cutoff ("Shadow Alpha cutoff", Range(0,1)) = 0.5 |
|
} |
|
|
|
CGINCLUDE |
|
|
|
#include "FluidParticleShader-Lighting.cginc" |
|
#include "UnityCG.cginc" |
|
|
|
uniform half4 _TintColor; |
|
uniform sampler2D _BumpMap; |
|
uniform half _Distort; |
|
uniform half4 _WaveMod; |
|
|
|
sampler2D _GrabTex; |
|
|
|
half4 fragB ( v2fB i ) : COLOR |
|
{ |
|
#ifdef SOFTPARTICLES_ON |
|
float sceneZ = LinearEyeDepth (UNITY_SAMPLE_DEPTH(tex2Dproj(_CameraDepthTexture, UNITY_PROJ_COORD(i.uvScreen)))); |
|
float partZ = i.uvScreen.z; |
|
float fade = saturate (_InvFade * (sceneZ-partZ)); |
|
#endif |
|
|
|
half4 off = half4(sin(_Time.y * _WaveMod.x) * _WaveMod.z, cos(_Time.y * _WaveMod.y) * _WaveMod.w, 0.5, 0.5); |
|
half4 normal = tex2D (_BumpMap, i.uv) - off - 0.5; |
|
i.uvScreen.xy += normal.xy * _Distort; |
|
|
|
half4 mainTex = tex2D (_MainTex, i.uv); |
|
half4 tint = mainTex * _TintColor; |
|
half4 l = half4(i.light.xyz, 0); |
|
half4 screen = l + tex2Dproj (_GrabTex, UNITY_PROJ_COORD (i.uvScreen)) + (tint * i.color * tint.a); |
|
screen.a = mainTex.a * i.color.a; |
|
|
|
#ifdef SOFTPARTICLES_ON |
|
screen.a *= fade; |
|
#endif |
|
|
|
return screen; |
|
} |
|
|
|
ENDCG |
|
|
|
SubShader { |
|
Tags {"Queue"="Transparent+100" "RenderType"="Transparent"} |
|
|
|
Pass { |
|
Cull Off |
|
ZWrite Off |
|
ZTest LEqual |
|
Blend SrcAlpha OneMinusSrcAlpha |
|
Tags {"LightMode"="Vertex"} |
|
|
|
CGPROGRAM |
|
|
|
#pragma vertex vertB |
|
#pragma fragment fragB |
|
#pragma fragmentoption ARB_precision_hint_fastest |
|
#pragma multi_compile_particles |
|
|
|
ENDCG |
|
|
|
} |
|
|
|
// Pass to render object as a shadow caster |
|
Pass { |
|
Name "Caster" |
|
Tags { "LightMode" = "ShadowCaster" } |
|
Offset 1, 1 |
|
|
|
Fog {Mode Off} |
|
ZWrite On ZTest LEqual Cull Off |
|
|
|
CGPROGRAM |
|
#pragma vertex vert |
|
#pragma fragment frag |
|
#pragma multi_compile_shadowcaster |
|
#pragma fragmentoption ARB_precision_hint_fastest |
|
#include "UnityCG.cginc" |
|
|
|
struct v2f { |
|
V2F_SHADOW_CASTER; |
|
float2 uv : TEXCOORD1; |
|
}; |
|
|
|
v2f vert( appdata_base v ) |
|
{ |
|
v2f o; |
|
TRANSFER_SHADOW_CASTER(o) |
|
o.uv = TRANSFORM_TEX(v.texcoord, _MainTex); |
|
return o; |
|
} |
|
|
|
uniform fixed _Cutoff; |
|
|
|
float4 frag( v2f i ) : COLOR |
|
{ |
|
fixed4 texcol = tex2D( _MainTex, i.uv ); |
|
clip( texcol.a - _Cutoff ); |
|
|
|
SHADOW_CASTER_FRAGMENT(i) |
|
} |
|
ENDCG |
|
} |
|
} |
|
Fallback "Fluvio/Mobile/Particles/Additive" |
|
}
|
|
|