166 lines
5.6 KiB
Plaintext
166 lines
5.6 KiB
Plaintext
Shader "NatureManufacture/Particles/Volcano_Distortion"
|
|
{
|
|
Properties
|
|
{
|
|
Particle_Color_RGB_Alpha_A("Particle Color (RGB) Alpha(A)", Color) = (1,1,1,1)
|
|
_ParticleMask("Alpha Mask (A)", 2D) = "white" {}
|
|
_ParticleMaskTilingOffset("Particle Mask Tiling and Offset", Vector) = (1,1,0,0)
|
|
_ParticleNormal("Refraction Normal", 2D) = "bump" {}
|
|
_NormalTilingOffset("Normal Tiling and Offset", Vector) = (1,1,0,0)
|
|
_Distortion("Distortion Power", Range( 0.001 , 1)) = 0.015
|
|
[HideInInspector] _texcoord( "", 2D ) = "white" {}
|
|
[HideInInspector] __dirty( "", Int ) = 1
|
|
}
|
|
|
|
SubShader
|
|
{
|
|
Tags{ "RenderType" = "Transparent" "Queue" = "Transparent+0" "IgnoreProjector" = "True" "IsEmissive" = "true" }
|
|
Cull Back
|
|
GrabPass{ }
|
|
CGINCLUDE
|
|
#include "UnityStandardUtils.cginc"
|
|
#include "UnityPBSLighting.cginc"
|
|
#include "Lighting.cginc"
|
|
#pragma target 3.0
|
|
#if defined(UNITY_STEREO_INSTANCING_ENABLED) || defined(UNITY_STEREO_MULTIVIEW_ENABLED)
|
|
#define ASE_DECLARE_SCREENSPACE_TEXTURE(tex) UNITY_DECLARE_SCREENSPACE_TEXTURE(tex);
|
|
#else
|
|
#define ASE_DECLARE_SCREENSPACE_TEXTURE(tex) UNITY_DECLARE_SCREENSPACE_TEXTURE(tex)
|
|
#endif
|
|
struct Input
|
|
{
|
|
float4 screenPos;
|
|
float2 uv_texcoord;
|
|
float4 vertexColor : COLOR;
|
|
};
|
|
|
|
uniform float4 Particle_Color_RGB_Alpha_A;
|
|
ASE_DECLARE_SCREENSPACE_TEXTURE( _GrabTexture )
|
|
uniform sampler2D _ParticleNormal;
|
|
uniform float4 _NormalTilingOffset;
|
|
uniform float _Distortion;
|
|
uniform sampler2D _ParticleMask;
|
|
uniform float4 _ParticleMaskTilingOffset;
|
|
|
|
|
|
inline float4 ASE_ComputeGrabScreenPos( float4 pos )
|
|
{
|
|
#if UNITY_UV_STARTS_AT_TOP
|
|
float scale = -1.0;
|
|
#else
|
|
float scale = 1.0;
|
|
#endif
|
|
float4 o = pos;
|
|
o.y = pos.w * 0.5f;
|
|
o.y = ( pos.y - o.y ) * _ProjectionParams.x * scale + o.y;
|
|
return o;
|
|
}
|
|
|
|
|
|
inline half4 LightingUnlit( SurfaceOutput s, half3 lightDir, half atten )
|
|
{
|
|
return half4 ( 0, 0, 0, s.Alpha );
|
|
}
|
|
|
|
void surf( Input i , inout SurfaceOutput o )
|
|
{
|
|
float3 appendResult309 = (float3(Particle_Color_RGB_Alpha_A.rgb));
|
|
float4 ase_screenPos = float4( i.screenPos.xyz , i.screenPos.w + 0.00000000001 );
|
|
float4 ase_grabScreenPos = ASE_ComputeGrabScreenPos( ase_screenPos );
|
|
float4 ase_grabScreenPosNorm = ase_grabScreenPos / ase_grabScreenPos.w;
|
|
float2 appendResult320 = (float2(_NormalTilingOffset.x , _NormalTilingOffset.y));
|
|
float2 appendResult321 = (float2(_NormalTilingOffset.z , _NormalTilingOffset.w));
|
|
float2 uv_TexCoord319 = i.uv_texcoord * appendResult320 + appendResult321;
|
|
float2 appendResult317 = (float2(( ase_grabScreenPosNorm + float4( UnpackScaleNormal( tex2D( _ParticleNormal, uv_TexCoord319 ), _Distortion ) , 0.0 ) ).xy));
|
|
float4 screenColor311 = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_GrabTexture,appendResult317);
|
|
float3 appendResult312 = (float3(screenColor311.rgb));
|
|
float3 appendResult327 = (float3(i.vertexColor.rgb));
|
|
o.Emission = ( ( appendResult309 * appendResult312 ) * appendResult327 );
|
|
float2 appendResult332 = (float2(_ParticleMaskTilingOffset.x , _ParticleMaskTilingOffset.y));
|
|
float2 appendResult333 = (float2(_ParticleMaskTilingOffset.z , _ParticleMaskTilingOffset.w));
|
|
float2 uv_TexCoord330 = i.uv_texcoord * appendResult332 + appendResult333;
|
|
o.Alpha = ( ( Particle_Color_RGB_Alpha_A.a * tex2D( _ParticleMask, uv_TexCoord330 ).a ) * i.vertexColor.a );
|
|
}
|
|
|
|
ENDCG
|
|
CGPROGRAM
|
|
#pragma surface surf Unlit alpha:fade keepalpha fullforwardshadows
|
|
|
|
ENDCG
|
|
Pass
|
|
{
|
|
Name "ShadowCaster"
|
|
Tags{ "LightMode" = "ShadowCaster" }
|
|
ZWrite On
|
|
CGPROGRAM
|
|
#pragma vertex vert
|
|
#pragma fragment frag
|
|
#pragma target 3.0
|
|
#pragma multi_compile_shadowcaster
|
|
#pragma multi_compile UNITY_PASS_SHADOWCASTER
|
|
#pragma skip_variants FOG_LINEAR FOG_EXP FOG_EXP2
|
|
#include "HLSLSupport.cginc"
|
|
#if ( SHADER_API_D3D11 || SHADER_API_GLCORE || SHADER_API_GLES || SHADER_API_GLES3 || SHADER_API_METAL || SHADER_API_VULKAN )
|
|
#define CAN_SKIP_VPOS
|
|
#endif
|
|
#include "UnityCG.cginc"
|
|
#include "Lighting.cginc"
|
|
#include "UnityPBSLighting.cginc"
|
|
sampler3D _DitherMaskLOD;
|
|
struct v2f
|
|
{
|
|
V2F_SHADOW_CASTER;
|
|
float2 customPack1 : TEXCOORD1;
|
|
float3 worldPos : TEXCOORD2;
|
|
float4 screenPos : TEXCOORD3;
|
|
half4 color : COLOR0;
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
UNITY_VERTEX_OUTPUT_STEREO
|
|
};
|
|
v2f vert( appdata_full v )
|
|
{
|
|
v2f o;
|
|
UNITY_SETUP_INSTANCE_ID( v );
|
|
UNITY_INITIALIZE_OUTPUT( v2f, o );
|
|
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO( o );
|
|
UNITY_TRANSFER_INSTANCE_ID( v, o );
|
|
Input customInputData;
|
|
float3 worldPos = mul( unity_ObjectToWorld, v.vertex ).xyz;
|
|
half3 worldNormal = UnityObjectToWorldNormal( v.normal );
|
|
o.customPack1.xy = customInputData.uv_texcoord;
|
|
o.customPack1.xy = v.texcoord;
|
|
o.worldPos = worldPos;
|
|
TRANSFER_SHADOW_CASTER_NORMALOFFSET( o )
|
|
o.screenPos = ComputeScreenPos( o.pos );
|
|
o.color = v.color;
|
|
return o;
|
|
}
|
|
half4 frag( v2f IN
|
|
#if !defined( CAN_SKIP_VPOS )
|
|
, UNITY_VPOS_TYPE vpos : VPOS
|
|
#endif
|
|
) : SV_Target
|
|
{
|
|
UNITY_SETUP_INSTANCE_ID( IN );
|
|
Input surfIN;
|
|
UNITY_INITIALIZE_OUTPUT( Input, surfIN );
|
|
surfIN.uv_texcoord = IN.customPack1.xy;
|
|
float3 worldPos = IN.worldPos;
|
|
half3 worldViewDir = normalize( UnityWorldSpaceViewDir( worldPos ) );
|
|
surfIN.screenPos = IN.screenPos;
|
|
surfIN.vertexColor = IN.color;
|
|
SurfaceOutput o;
|
|
UNITY_INITIALIZE_OUTPUT( SurfaceOutput, o )
|
|
surf( surfIN, o );
|
|
#if defined( CAN_SKIP_VPOS )
|
|
float2 vpos = IN.pos;
|
|
#endif
|
|
half alphaRef = tex3D( _DitherMaskLOD, float3( vpos.xy * 0.25, o.Alpha * 0.9375 ) ).a;
|
|
clip( alphaRef - 0.01 );
|
|
SHADOW_CASTER_FRAGMENT( IN )
|
|
}
|
|
ENDCG
|
|
}
|
|
}
|
|
Fallback "Diffuse"
|
|
} |