Stable version

This commit is contained in:
Kasutaja
2023-04-30 14:23:57 +03:00
parent cdbdbc28c4
commit 294d6117e3
1861 changed files with 1697361 additions and 6747 deletions

View File

@@ -0,0 +1,176 @@
//--------------------------------------------------------------------------------------------------------------------------------
// Cartoon FX
// (c) 2012-2020 Jean Moreno
//--------------------------------------------------------------------------------------------------------------------------------
Shader "Cartoon FX/Remaster/Particle Screen Distortion"
{
Properties
{
[Toggle(_ALPHATEST_ON)] _UseAlphaClip ("Alpha Clipping (Cutout)", Float) = 0
//# IF_KEYWORD _ALPHATEST_ON
_Cutoff ("Cutoff Threshold", Range(0.001,1)) = 0.1
//# END_IF
//# --------------------------------------------------------
[Toggle(_FADING_ON)] _UseSP ("Soft Particles", Float) = 0
//# IF_KEYWORD _FADING_ON
_SoftParticlesFadeDistanceNear ("Near Fade", Float) = 0
_SoftParticlesFadeDistanceFar ("Far Fade", Float) = 1
//# END_IF
//#
[Toggle(_CFXR_EDGE_FADING)] _UseEF ("Edge Fade", Float) = 0
//# IF_KEYWORD _CFXR_EDGE_FADING
_EdgeFadePow ("Edge Fade Power", Float) = 1
//# END_IF
//# ========================================================
//# Texture
//#
[NoScaleOffset] _ScreenDistortionTex ("Distortion Texture", 2D) = "bump" {}
_ScreenDistortionScale ("Distortion Scale", Range(-0.5, 0.5)) = 0.1
//# ========================================================
//# Debug
//#
[Toggle(_DEBUG_VISUALIZE_DISTORTION)] _DebugVisualize ("Visualize Distortion Particles", Float) = 0
}
Category
{
Tags
{
"Queue"="Transparent"
"IgnoreProjector"="True"
"RenderType"="Transparent"
"PreviewType"="Plane"
}
Blend SrcAlpha OneMinusSrcAlpha, One One
ZWrite Off
Cull Off
//====================================================================================================================================
// Universal Rendering Pipeline
Subshader
{
Pass
{
Name "BASE_URP"
Tags { "LightMode"="UniversalForward" }
CGPROGRAM
#pragma vertex vertex_program
#pragma fragment fragment_program
#pragma target 2.0
// #pragma multi_compile_instancing
// #pragma instancing_options procedural:ParticleInstancingSetup
#pragma multi_compile_fog
//#pragma multi_compile_fwdbase
//#pragma multi_compile SHADOWS_SCREEN
// Using the same keywords as Unity's Standard Particle shader to minimize project-wide keyword usage
#pragma shader_feature_local _ _FADING_ON
#pragma shader_feature_local _ _ALPHATEST_ON
#pragma shader_feature_local _ _DEBUG_VISUALIZE_DISTORTION
#define CFXR_URP
#define CFXR_SCREEN_DISTORTION_SHADER
#include "CFXR_PASSES.cginc"
ENDCG
}
// Same as above with 'Universal2D' instead and DISABLE_SOFT_PARTICLES keyword
Pass
{
Name "BASE_URP"
Tags { "LightMode"="Universal2D" }
CGPROGRAM
#pragma vertex vertex_program
#pragma fragment fragment_program
#pragma target 2.0
// #pragma multi_compile_instancing
// #pragma instancing_options procedural:ParticleInstancingSetup
#pragma multi_compile_fog
//#pragma multi_compile_fwdbase
//#pragma multi_compile SHADOWS_SCREEN
// Using the same keywords as Unity's Standard Particle shader to minimize project-wide keyword usage
#pragma shader_feature_local _ _FADING_ON
#pragma shader_feature_local _ _ALPHATEST_ON
#pragma shader_feature_local _ _DEBUG_VISUALIZE_DISTORTION
#define CFXR_URP
#define DISABLE_SOFT_PARTICLES
#define CFXR_SCREEN_DISTORTION_SHADER
#include "CFXR_PASSES.cginc"
ENDCG
}
}
//====================================================================================================================================
// Built-in Rendering Pipeline
SubShader
{
GrabPass
{
Tags { "LightMode" = "Always" }
"_GrabTexture"
}
Pass
{
Name "BASE"
Tags { "LightMode"="ForwardBase" }
CGPROGRAM
#pragma vertex vertex_program
#pragma fragment fragment_program
//vertInstancingSetup writes to global, not allowed with DXC
// #pragma never_use_dxc
// #pragma target 2.5
// #pragma multi_compile_instancing
// #pragma instancing_options procedural:vertInstancingSetup
#pragma multi_compile_particles
#pragma multi_compile_fog
//#pragma multi_compile_fwdbase
//#pragma multi_compile SHADOWS_SCREEN
// Using the same keywords as Unity's Standard Particle shader to minimize project-wide keyword usage
#pragma shader_feature_local _ _FADING_ON
#pragma shader_feature_local _ _ALPHATEST_ON
#pragma shader_feature_local _ _DEBUG_VISUALIZE_DISTORTION
#include "UnityStandardParticleInstancing.cginc"
#define CFXR_SCREEN_DISTORTION_SHADER
#include "CFXR_PASSES.cginc"
ENDCG
}
}
}
CustomEditor "CartoonFX.MaterialInspector"
}

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 9f1e1c035a8fc0b4cab1d282789b282b
timeCreated: 1487089074
licenseType: Store
ShaderImporter:
defaultTextures: []
userData: USER,FTC1_RO_VCR,FTC2_RO_VCR,FTC0_RO,FTC_RSS,FGLOBAL_MASK,FTC1_RO,FTC2_RO,FTC2,FTC3,FTC1,FTEX0,FTC0_RO_TEXCOORD,FTC0,FTC1_RO_TEXCOORD,FTC2_RO_TEXCOORD,FTC0_SCROLL,FTC1_SCROLL,FTC2_SCROLL,KTC0_RO_SOURCE:v.color.r,KTC0_RSS_SOURCE:v.color.r,KTC_RSS_SOURCE:v.color.r,KTC1_RO_SOURCE:v.color.g,KTC2_RO_SOURCE:v.color.b,KTC3_RO_SOURCE:v.color.r,KTC0_RO_VC_CHANNEL:r,KTC0_RO_TEXCOORD_CHANNEL:x,KTC0_RO_TEXCOORD_NB:1,KTC1_RO_TEXCOORD_NB:1,KTC1_RO_TEXCOORD_CHANNEL:y,KTC2_RO_TEXCOORD_NB:3,ch8844A936,cSM:30,cCF:UnifiedParticleShaderTemplate
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,274 @@
//--------------------------------------------------------------------------------------------------------------------------------
// Cartoon FX
// (c) 2012-2020 Jean Moreno
//--------------------------------------------------------------------------------------------------------------------------------
Shader "Cartoon FX/Remaster/Particle Procedural Glow"
{
Properties
{
//# Blending
//#
[Enum(UnityEngine.Rendering.BlendMode)] _SrcBlend ("Blend Source", Float) = 5
[Enum(UnityEngine.Rendering.BlendMode)] _DstBlend ("Blend Destination", Float) = 10
//# --------------------------------------------------------
[Toggle(_CFXR_DISSOLVE)] _UseDissolve ("Enable Dissolve", Float) = 0
//# IF_KEYWORD _CFXR_DISSOLVE
[NoScaleOffset] _DissolveTex ("Dissolve Texture", 2D) = "gray" {}
_DissolveSmooth ("Dissolve Smoothing", Range(0.0001,0.5)) = 0.1
[ToggleNoKeyword] _InvertDissolveTex ("Invert Dissolve Texture", Float) = 0
//# END_IF
//# --------------------------------------------------------
//# Procedural Circle
//#
[KeywordEnum(P0, P2, P4, P8)] _CFXR_GLOW_POW ("Apply Power of", Float) = 0
_GlowMin ("Circle Min", Float) = 0
_GlowMax ("Circle Max", Float) = 1
//#
_MaxValue ("Max Value", Float) = 10
//# --------------------------------------------------------
[Toggle(_CFXR_HDR_BOOST)] _HdrBoost ("Enable HDR Multiplier", Float) = 0
//# IF_KEYWORD _CFXR_HDR_BOOST
_HdrMultiply ("HDR Multiplier", Float) = 2
//# END_IF
//# --------------------------------------------------------
[Toggle(_FADING_ON)] _UseSP ("Soft Particles", Float) = 0
//# IF_KEYWORD _FADING_ON
_SoftParticlesFadeDistanceNear ("Near Fade", Float) = 0
_SoftParticlesFadeDistanceFar ("Far Fade", Float) = 1
//# END_IF
//# ========================================================
//# Shadows
//#
[KeywordEnum(Off,On,CustomTexture)] _CFXR_DITHERED_SHADOWS ("Dithered Shadows", Float) = 0
//# IF_KEYWORD _CFXR_DITHERED_SHADOWS_ON || _CFXR_DITHERED_SHADOWS_CUSTOMTEXTURE
_ShadowStrength ("Shadows Strength Max", Range(0,1)) = 1.0
//# IF_KEYWORD _CFXR_DITHERED_SHADOWS_CUSTOMTEXTURE
_DitherCustom ("Dithering 3D Texture", 3D) = "black" {}
//# END_IF
//# END_IF
}
Category
{
Tags
{
"Queue"="Transparent"
"IgnoreProjector"="True"
"RenderType"="Transparent"
"PreviewType"="Plane"
}
Blend [_SrcBlend] [_DstBlend], One One
Cull Off
ZWrite Off
//====================================================================================================================================
// Universal Rendering Pipeline
SubShader
{
Pass
{
Name "BASE"
Tags { "LightMode"="UniversalForward" }
CGPROGRAM
#pragma vertex vertex_program
#pragma fragment fragment_program
#pragma target 2.0
// #pragma multi_compile_instancing
// #pragma instancing_options procedural:ParticleInstancingSetup
#pragma multi_compile_fog
#pragma shader_feature_local _ _CFXR_GLOW_POW_P2 _CFXR_GLOW_POW_P4 _CFXR_GLOW_POW_P8
#pragma shader_feature_local _ _CFXR_HDR_BOOST
#pragma shader_feature_local _ _CFXR_DISSOLVE
#pragma shader_feature_local _FADING_ON
#pragma shader_feature_local _ _ALPHATEST_ON
#pragma shader_feature_local _ _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON _ALPHAMODULATE_ON _CFXR_ADDITIVE
#define CFXR_URP
#define CFXR_GLOW_SHADER
#include "CFXR_PASSES.cginc"
ENDCG
}
// Same as above with 'Universal2D' instead and DISABLE_SOFT_PARTICLES keyword
Pass
{
Name "BASE"
Tags { "LightMode"="Universal2D" }
CGPROGRAM
#pragma vertex vertex_program
#pragma fragment fragment_program
#pragma target 2.0
// #pragma multi_compile_instancing
// #pragma instancing_options procedural:ParticleInstancingSetup
#pragma multi_compile_fog
#pragma shader_feature_local _ _CFXR_GLOW_POW_P2 _CFXR_GLOW_POW_P4 _CFXR_GLOW_POW_P8
#pragma shader_feature_local _ _CFXR_HDR_BOOST
#pragma shader_feature_local _ _CFXR_DISSOLVE
#pragma shader_feature_local _FADING_ON
#pragma shader_feature_local _ _ALPHATEST_ON
#pragma shader_feature_local _ _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON _ALPHAMODULATE_ON _CFXR_ADDITIVE
#define CFXR_URP
#define DISABLE_SOFT_PARTICLES
#define CFXR_GLOW_SHADER
#include "CFXR_PASSES.cginc"
ENDCG
}
//--------------------------------------------------------------------------------------------------------------------------------
Pass
{
Name "ShadowCaster"
Tags { "LightMode" = "ShadowCaster" }
BlendOp Add
Blend One Zero
ZWrite On
Cull Off
CGPROGRAM
#pragma vertex vertex_program
#pragma fragment fragment_program
#pragma shader_feature_local _ _CFXR_GLOW_POW_P2 _CFXR_GLOW_POW_P4 _CFXR_GLOW_POW_P8
#pragma shader_feature_local _ _CFXR_DISSOLVE
#pragma shader_feature_local _FADING_ON
#pragma shader_feature_local _ _ALPHATEST_ON _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON _ALPHAMODULATE_ON
#pragma multi_compile_shadowcaster
#pragma shader_feature_local _ _CFXR_DITHERED_SHADOWS_ON _CFXR_DITHERED_SHADOWS_CUSTOMTEXTURE
#if (_CFXR_DITHERED_SHADOWS_ON || _CFXR_DITHERED_SHADOWS_CUSTOMTEXTURE) && !defined(SHADER_API_GLES)
#pragma target 3.0 //needed for VPOS
#endif
#define CFXR_URP
#define PASS_SHADOW_CASTER
#define CFXR_GLOW_SHADER
#include "CFXR_PASSES.cginc"
ENDCG
}
}
//====================================================================================================================================
// Built-in Rendering Pipeline
SubShader
{
Pass
{
Name "BASE"
Tags { "LightMode"="ForwardBase" }
CGPROGRAM
#pragma vertex vertex_program
#pragma fragment fragment_program
//vertInstancingSetup writes to global, not allowed with DXC
// #pragma never_use_dxc
// #pragma target 2.5
// #pragma multi_compile_instancing
// #pragma instancing_options procedural:vertInstancingSetup
#pragma multi_compile_particles
#pragma multi_compile_fog
#pragma shader_feature_local _ _CFXR_GLOW_POW_P2 _CFXR_GLOW_POW_P4 _CFXR_GLOW_POW_P8
#pragma shader_feature_local _ _CFXR_HDR_BOOST
#pragma shader_feature_local _ _CFXR_DISSOLVE
#pragma shader_feature_local _FADING_ON
#pragma shader_feature_local _ _ALPHATEST_ON
#pragma shader_feature_local _ _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON _ALPHAMODULATE_ON _CFXR_ADDITIVE
#include "UnityStandardParticleInstancing.cginc"
#define CFXR_GLOW_SHADER
#include "CFXR_PASSES.cginc"
ENDCG
}
//--------------------------------------------------------------------------------------------------------------------------------
Pass
{
Name "ShadowCaster"
Tags { "LightMode" = "ShadowCaster" }
BlendOp Add
Blend One Zero
ZWrite On
Cull Off
CGPROGRAM
#pragma vertex vertex_program
#pragma fragment fragment_program
//vertInstancingSetup writes to global, not allowed with DXC
// #pragma never_use_dxc
// #pragma target 2.5
// #pragma multi_compile_instancing
// #pragma instancing_options procedural:vertInstancingSetup
#pragma shader_feature_local _ _CFXR_GLOW_POW_P2 _CFXR_GLOW_POW_P4 _CFXR_GLOW_POW_P8
#pragma shader_feature_local _ _CFXR_DISSOLVE
#pragma shader_feature_local _FADING_ON
#pragma shader_feature_local _ _ALPHATEST_ON _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON _ALPHAMODULATE_ON
#pragma multi_compile_shadowcaster
#pragma shader_feature_local _ _CFXR_DITHERED_SHADOWS_ON _CFXR_DITHERED_SHADOWS_CUSTOMTEXTURE
#if (_CFXR_DITHERED_SHADOWS_ON || _CFXR_DITHERED_SHADOWS_CUSTOMTEXTURE) && !defined(SHADER_API_GLES)
#pragma target 3.0 //needed for VPOS
#endif
#include "UnityStandardParticleInstancing.cginc"
#define PASS_SHADOW_CASTER
#define CFXR_GLOW_SHADER
#include "CFXR_PASSES.cginc"
ENDCG
}
}
}
CustomEditor "CartoonFX.MaterialInspector"
}

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 714e760b98304b44292e04841e05f258
timeCreated: 1487089074
licenseType: Store
ShaderImporter:
defaultTextures: []
userData: USER,FTC1_RO_VCR,FTC2_RO_VCR,FTC0_RO,FTC_RSS,FGLOBAL_MASK,FTC1_RO,FTC2_RO,FTC2,FTC3,FTC1,FTEX0,FTC0_RO_TEXCOORD,FTC0,FTC1_RO_TEXCOORD,FTC2_RO_TEXCOORD,FTC0_SCROLL,FTC1_SCROLL,FTC2_SCROLL,KTC0_RO_SOURCE:v.color.r,KTC0_RSS_SOURCE:v.color.r,KTC_RSS_SOURCE:v.color.r,KTC1_RO_SOURCE:v.color.g,KTC2_RO_SOURCE:v.color.b,KTC3_RO_SOURCE:v.color.r,KTC0_RO_VC_CHANNEL:r,KTC0_RO_TEXCOORD_CHANNEL:x,KTC0_RO_TEXCOORD_NB:1,KTC1_RO_TEXCOORD_NB:1,KTC1_RO_TEXCOORD_CHANNEL:y,KTC2_RO_TEXCOORD_NB:3,ch8844A936,cSM:30,cCF:UnifiedParticleShaderTemplate
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,276 @@
//--------------------------------------------------------------------------------------------------------------------------------
// Cartoon FX
// (c) 2012-2020 Jean Moreno
//--------------------------------------------------------------------------------------------------------------------------------
Shader "Cartoon FX/Remaster/Particle Procedural Ring"
{
Properties
{
//# Blending
//#
[Enum(UnityEngine.Rendering.BlendMode)] _SrcBlend ("Blend Source", Float) = 5
[Enum(UnityEngine.Rendering.BlendMode)] _DstBlend ("Blend Destination", Float) = 10
//# --------------------------------------------------------
[Toggle(_CFXR_DISSOLVE)] _UseDissolve ("Enable Dissolve", Float) = 0
//# IF_KEYWORD _CFXR_DISSOLVE
[NoScaleOffset] _DissolveTex ("Dissolve Texture", 2D) = "gray" {}
_DissolveSmooth ("Dissolve Smoothing", Range(0.0001,0.5)) = 0.1
[ToggleNoKeyword] _InvertDissolveTex ("Invert Dissolve Texture", Float) = 0
//# END_IF
//# --------------------------------------------------------
//# Textures
//#
_MainTex ("Texture", 2D) = "white" {}
[Toggle(_CFXR_SINGLE_CHANNEL)] _SingleChannel ("Single Channel Texture", Float) = 0
//# --------------------------------------------------------
//# Ring
//#
[Toggle(_CFXR_RADIAL_UV)] _UseRadialUV ("Enable Radial UVs", Float) = 0
_RingTopOffset ("Ring Offset", float) = 0.05
[Toggle(_CFXR_WORLD_SPACE_RING)] _WorldSpaceRing ("World Space", Float) = 0
//# --------------------------------------------------------
[Toggle(_CFXR_HDR_BOOST)] _HdrBoost ("Enable HDR Multiplier", Float) = 0
//# IF_KEYWORD _CFXR_HDR_BOOST
_HdrMultiply ("HDR Multiplier", Float) = 2
//# END_IF
//# --------------------------------------------------------
[Toggle(_FADING_ON)] _UseSP ("Soft Particles", Float) = 0
//# IF_KEYWORD _FADING_ON
_SoftParticlesFadeDistanceNear ("Near Fade", Float) = 0
_SoftParticlesFadeDistanceFar ("Far Fade", Float) = 1
//# END_IF
//# ========================================================
//# Shadows
//#
[KeywordEnum(Off,On,CustomTexture)] _CFXR_DITHERED_SHADOWS ("Dithered Shadows", Float) = 0
//# IF_KEYWORD _CFXR_DITHERED_SHADOWS_ON || _CFXR_DITHERED_SHADOWS_CUSTOMTEXTURE
_ShadowStrength ("Shadows Strength Max", Range(0,1)) = 1.0
//# IF_KEYWORD _CFXR_DITHERED_SHADOWS_CUSTOMTEXTURE
_DitherCustom ("Dithering 3D Texture", 3D) = "black" {}
//# END_IF
//# END_IF
}
Category
{
Tags
{
"Queue"="Transparent"
"IgnoreProjector"="True"
"RenderType"="Transparent"
}
Blend [_SrcBlend] [_DstBlend]
Cull Off
ZWrite Off
//====================================================================================================================================
// Universal Rendering Pipeline
SubShader
{
Pass
{
Name "BASE"
Tags { "LightMode"="UniversalForward" }
CGPROGRAM
#pragma vertex vertex_program
#pragma fragment fragment_program
#pragma target 2.0
// #pragma multi_compile_instancing
#pragma multi_compile_fog
#pragma shader_feature_local _ _CFXR_SINGLE_CHANNEL
#pragma shader_feature_local _ _CFXR_RADIAL_UV
#pragma shader_feature_local _ _CFXR_WORLD_SPACE_RING
#pragma shader_feature_local _ _CFXR_DISSOLVE
#pragma shader_feature_local _ _CFXR_HDR_BOOST
// Using the same keywords as Unity's Standard Particle shader to minimize project-wide keyword usage
#pragma shader_feature_local _ _FADING_ON
#pragma shader_feature_local _ _ALPHATEST_ON
#pragma shader_feature_local _ _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON _ALPHAMODULATE_ON _CFXR_ADDITIVE
#define CFXR_URP
#define CFXR_PROCEDURAL_RING_SHADER
#include "CFXR_PASSES.cginc"
ENDCG
}
// Same as above with 'Universal2D' instead and DISABLE_SOFT_PARTICLES keyword
Pass
{
Name "BASE"
Tags { "LightMode"="Universal2D" }
CGPROGRAM
#pragma vertex vertex_program
#pragma fragment fragment_program
#pragma target 2.0
// #pragma multi_compile_instancing
#pragma multi_compile_fog
#pragma shader_feature_local _ _CFXR_SINGLE_CHANNEL
#pragma shader_feature_local _ _CFXR_RADIAL_UV
#pragma shader_feature_local _ _CFXR_WORLD_SPACE_RING
#pragma shader_feature_local _ _CFXR_DISSOLVE
#pragma shader_feature_local _ _CFXR_HDR_BOOST
// Using the same keywords as Unity's Standard Particle shader to minimize project-wide keyword usage
#pragma shader_feature_local _ _FADING_ON
#pragma shader_feature_local _ _ALPHATEST_ON
#pragma shader_feature_local _ _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON _ALPHAMODULATE_ON _CFXR_ADDITIVE
#define CFXR_URP
#define DISABLE_SOFT_PARTICLES
#define CFXR_PROCEDURAL_RING_SHADER
#include "CFXR_PASSES.cginc"
ENDCG
}
//--------------------------------------------------------------------------------------------------------------------------------
Pass
{
Name "ShadowCaster"
Tags { "LightMode" = "ShadowCaster" }
BlendOp Add
Blend One Zero
ZWrite On
Cull Off
CGPROGRAM
#pragma vertex vertex_program
#pragma fragment fragment_program
#pragma shader_feature_local _ _CFXR_SINGLE_CHANNEL
#pragma shader_feature_local _ _CFXR_RADIAL_UV
#pragma shader_feature_local _ _CFXR_WORLD_SPACE_RING
#pragma shader_feature_local _ _CFXR_DISSOLVE
#pragma shader_feature_local _ _ALPHATEST_ON
#pragma shader_feature_local _ _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON _ALPHAMODULATE_ON _CFXR_ADDITIVE
#pragma multi_compile_shadowcaster
#pragma shader_feature_local _ _CFXR_DITHERED_SHADOWS_ON _CFXR_DITHERED_SHADOWS_CUSTOMTEXTURE
#if (_CFXR_DITHERED_SHADOWS_ON || _CFXR_DITHERED_SHADOWS_CUSTOMTEXTURE) && !defined(SHADER_API_GLES)
#pragma target 3.0 //needed for VPOS
#endif
#define CFXR_URP
#define PASS_SHADOW_CASTER
#define CFXR_PROCEDURAL_RING_SHADER
#include "CFXR_PASSES.cginc"
ENDCG
}
}
//====================================================================================================================================
// Built-in Rendering Pipeline
SubShader
{
Pass
{
Name "BASE"
Tags { "LightMode"="ForwardBase" }
CGPROGRAM
#pragma vertex vertex_program
#pragma fragment fragment_program
#pragma target 2.0
#pragma multi_compile_particles
// #pragma multi_compile_instancing
#pragma multi_compile_fog
#pragma shader_feature_local _ _CFXR_SINGLE_CHANNEL
#pragma shader_feature_local _ _CFXR_RADIAL_UV
#pragma shader_feature_local _ _CFXR_WORLD_SPACE_RING
#pragma shader_feature_local _ _CFXR_DISSOLVE
#pragma shader_feature_local _ _CFXR_HDR_BOOST
// Using the same keywords as Unity's Standard Particle shader to minimize project-wide keyword usage
#pragma shader_feature_local _ _FADING_ON
#pragma shader_feature_local _ _ALPHATEST_ON
#pragma shader_feature_local _ _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON _ALPHAMODULATE_ON _CFXR_ADDITIVE
#define CFXR_PROCEDURAL_RING_SHADER
#include "CFXR_PASSES.cginc"
ENDCG
}
//--------------------------------------------------------------------------------------------------------------------------------
Pass
{
Name "ShadowCaster"
Tags { "LightMode" = "ShadowCaster" }
BlendOp Add
Blend One Zero
ZWrite On
Cull Off
CGPROGRAM
#pragma vertex vertex_program
#pragma fragment fragment_program
#pragma shader_feature_local _ _CFXR_SINGLE_CHANNEL
#pragma shader_feature_local _ _CFXR_RADIAL_UV
#pragma shader_feature_local _ _CFXR_WORLD_SPACE_RING
#pragma shader_feature_local _ _CFXR_DISSOLVE
#pragma shader_feature_local _ _ALPHATEST_ON
#pragma shader_feature_local _ _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON _ALPHAMODULATE_ON _CFXR_ADDITIVE
#pragma multi_compile_shadowcaster
#pragma shader_feature_local _ _CFXR_DITHERED_SHADOWS_ON _CFXR_DITHERED_SHADOWS_CUSTOMTEXTURE
#if (_CFXR_DITHERED_SHADOWS_ON || _CFXR_DITHERED_SHADOWS_CUSTOMTEXTURE) && !defined(SHADER_API_GLES)
#pragma target 3.0 //needed for VPOS
#endif
#define PASS_SHADOW_CASTER
#define CFXR_PROCEDURAL_RING_SHADER
#include "CFXR_PASSES.cginc"
ENDCG
}
}
}
CustomEditor "CartoonFX.MaterialInspector"
}

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 3dda44a7d9cec71439b5b8e20fcbccfb
timeCreated: 1487089074
licenseType: Store
ShaderImporter:
defaultTextures: []
userData: USER,FTC1_RO_VCR,FTC2_RO_VCR,FTC0_RO,FTC_RSS,FGLOBAL_MASK,FTC1_RO,FTC2_RO,FTC2,FTC3,FTC1,FTEX0,FTC0_RO_TEXCOORD,FTC0,FTC1_RO_TEXCOORD,FTC2_RO_TEXCOORD,FTC0_SCROLL,FTC1_SCROLL,FTC2_SCROLL,KTC0_RO_SOURCE:v.color.r,KTC0_RSS_SOURCE:v.color.r,KTC_RSS_SOURCE:v.color.r,KTC1_RO_SOURCE:v.color.g,KTC2_RO_SOURCE:v.color.b,KTC3_RO_SOURCE:v.color.r,KTC0_RO_VC_CHANNEL:r,KTC0_RO_TEXCOORD_CHANNEL:x,KTC0_RO_TEXCOORD_NB:1,KTC1_RO_TEXCOORD_NB:1,KTC1_RO_TEXCOORD_CHANNEL:y,KTC2_RO_TEXCOORD_NB:3,ch8844A936,cSM:30,cCF:UnifiedParticleShaderTemplate
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,449 @@
//--------------------------------------------------------------------------------------------------------------------------------
// Cartoon FX
// (c) 2012-2020 Jean Moreno
//--------------------------------------------------------------------------------------------------------------------------------
Shader "Cartoon FX/Remaster/Particle Ubershader"
{
Properties
{
//# Blending
//#
[Enum(UnityEngine.Rendering.BlendMode)] _SrcBlend ("Blend Source", Float) = 5
[Enum(UnityEngine.Rendering.BlendMode)] _DstBlend ("Blend Destination", Float) = 10
[KeywordEnumNoPrefix(Alpha Blending, _ALPHABLEND_ON, Alpha Blending Premultiplied, _ALPHAPREMULTIPLY_ON, Multiplicative, _ALPHAMODULATE_ON, Additive, _CFXR_ADDITIVE)] _BlendingType ("Blending Type", Float) = 0
//#
[ToggleNoKeyword] _ZWrite ("Depth Write", Float) = 0
[Toggle(_ALPHATEST_ON)] _UseAlphaClip ("Alpha Clipping (Cutout)", Float) = 0
//# IF_KEYWORD _ALPHATEST_ON
_Cutoff ("Cutoff Threshold", Range(0.001,1)) = 0.1
//# END_IF
//# --------------------------------------------------------
[Toggle(_FADING_ON)] _UseSP ("Soft Particles", Float) = 0
//# IF_KEYWORD _FADING_ON
_SoftParticlesFadeDistanceNear ("Near Fade", Float) = 0
_SoftParticlesFadeDistanceFar ("Far Fade", Float) = 1
//# END_IF
//#
[Toggle(_CFXR_EDGE_FADING)] _UseEF ("Edge Fade", Float) = 0
//# IF_KEYWORD _CFXR_EDGE_FADING
_EdgeFadePow ("Edge Fade Power", Float) = 1
//# END_IF
//#
//# ========================================================
//# Effects
//#
[Toggle(_CFXR_DISSOLVE)] _UseDissolve ("Enable Dissolve", Float) = 0
//# IF_KEYWORD _CFXR_DISSOLVE
_DissolveTex ("Dissolve Texture", 2D) = "gray" {}
_DissolveSmooth ("Dissolve Smoothing", Range(0.0001,0.5)) = 0.1
[ToggleNoKeyword] _InvertDissolveTex ("Invert Dissolve Texture", Float) = 0
[ToggleNoKeyword] _DoubleDissolve ("Double Dissolve", Float) = 0
[Toggle(_CFXR_DISSOLVE_ALONG_UV_X)] _UseDissolveOffsetUV ("Dissolve offset along X", Float) = 0
//# IF_KEYWORD _CFXR_DISSOLVE_ALONG_UV_X
_DissolveScroll ("UV Scrolling", Vector) = (0,0,0,0)
//# END_IF
//# END_IF
//# --------------------------------------------------------
[Toggle(_CFXR_UV_DISTORTION)] _UseUVDistortion ("Enable UV Distortion", Float) = 0
//# IF_KEYWORD _CFXR_UV_DISTORTION
[NoScaleOffset] _DistortTex ("Distortion Texture", 2D) = "gray" {}
_DistortScrolling ("Scroll (XY) Tile (ZW)", Vector) = (0,0,1,1)
[Toggle(_CFXR_UV2_DISTORTION)] _UseUV2Distortion ("Use UV2", Float) = 0
_Distort ("Distortion Strength", Range(0,2.0)) = 0.1
[ToggleNoKeyword] _FadeAlongU ("Fade along Y", Float) = 0
[Toggle(_CFXR_UV_DISTORTION_ADD)] _UVDistortionAdd ("Add to base UV", Float) = 0
//# END_IF
//# ========================================================
//# Colors
//#
[NoScaleOffset] _MainTex ("Texture", 2D) = "white" {}
[Toggle(_CFXR_SINGLE_CHANNEL)] _SingleChannel ("Single Channel Texture", Float) = 0
//# --------------------------------------------------------
[KeywordEnum(Off,1x,2x)] _CFXR_OVERLAYTEX ("Enable Overlay Texture", Float) = 0
//# IF_KEYWORD _CFXR_OVERLAYTEX_1X || _CFXR_OVERLAYTEX_2X
[KeywordEnum(RGBA,RGB,A)] _CFXR_OVERLAYBLEND ("Overlay Blend Channels", Float) = 0
[NoScaleOffset] _OverlayTex ("Overlay Texture", 2D) = "white" {}
_OverlayTex_Scroll ("Overlay Scrolling / Scale", Vector) = (0.1,0.1,1,1)
//# END_IF
//# --------------------------------------------------------
[Toggle(_FLIPBOOK_BLENDING)] _UseFB ("Flipbook Blending", Float) = 0
//# --------------------------------------------------------
[Toggle(_CFXR_SECONDCOLOR_LERP)] _UseSecondColor ("Secondary Vertex Color (TEXCOORD2)", Float) = 0
//# IF_KEYWORD _CFXR_SECONDCOLOR_LERP
[NoScaleOffset] _SecondColorTex ("Second Color Map", 2D) = "black" {}
_SecondColorSmooth ("Second Color Smoothing", Range(0.0001,0.5)) = 0.2
//# END_IF
//# --------------------------------------------------------
[Toggle(_CFXR_FONT_COLORS)] _UseFontColor ("Use Font Colors", Float) = 0
// //# --------------------------------------------------------
//
// [Toggle(_CFXR_GRADIENTMAP)] _UseGradientMap ("Gradient Map", Float) = 0
// //# IF_KEYWORD _CFXR_GRADIENTMAP
// [NoScaleOffset] _GradientMap ("Gradient Map", 2D) = "black" {}
// //# END_IF
//# --------------------------------------------------------
[Toggle(_CFXR_HDR_BOOST)] _HdrBoost ("Enable HDR Multiplier", Float) = 0
//# IF_KEYWORD _CFXR_HDR_BOOST
_HdrMultiply ("HDR Multiplier", Float) = 2
//# END_IF
//# --------------------------------------------------------
//# Lighting
//#
[KeywordEnumNoPrefix(Off, _, Direct, _CFXR_LIGHTING_DIRECT, Indirect, _CFXR_LIGHTING_INDIRECT, Both, _CFXR_LIGHTING_ALL)] _UseLighting ("Mode", Float) = 0
//# IF_KEYWORD _CFXR_LIGHTING_DIRECT || _CFXR_LIGHTING_ALL
_DirectLightingRamp ("Direct Lighting Ramp", Range(0,1)) = 1.0
//# END_IF
//#
//# IF_KEYWORD _CFXR_LIGHTING_DIRECT || _CFXR_LIGHTING_INDIRECT || _CFXR_LIGHTING_ALL
[Toggle(_NORMALMAP)] _UseNormalMap ("Enable Normal Map", Float) = 0
//# IF_KEYWORD _NORMALMAP
[NoScaleOffset] _BumpMap ("Normal Map", 2D) = "bump" {}
_BumpScale ("Normal Scale", Range(-1, 1)) = 1.0
//# END_IF
//#
[Toggle(_EMISSION)] _UseEmission ("Enable Emission (TEXCOORD2)", Float) = 0
//#
[Toggle(_CFXR_LIGHTING_WPOS_OFFSET)] _UseLightingWorldPosOffset ("Enable World Pos. Offset", Float) = 0
//# IF_KEYWORD _CFXR_LIGHTING_WPOS_OFFSET
_LightingWorldPosStrength ("Offset Strength", Range(0,1)) = 0.2
//# END_IF
//#
[Toggle(_CFXR_LIGHTING_BACK)] _UseBackLighting ("Enable Backlighting", Float) = 0
//# IF_KEYWORD _CFXR_LIGHTING_BACK
_DirLightScreenAtten ("Dir. Light Screen Attenuation", Range(0, 5)) = 1.0
_BacklightTransmittance ("Backlight Transmittance", Range(0, 2)) = 1.0
//# END_IF
//#
//# IF_KEYWORD _CFXR_LIGHTING_INDIRECT || _CFXR_LIGHTING_ALL
_IndirectLightingMix ("Indirect Lighting Mix", Range(0,1)) = 0.5
//# END_IF
_ShadowColor ("Shadow Color", Color) = (0,0,0,1)
//#
//# END_IF
//# ========================================================
//# Shadows
//#
[KeywordEnum(Off,On,CustomTexture)] _CFXR_DITHERED_SHADOWS ("Dithered Shadows", Float) = 0
//# IF_KEYWORD _CFXR_DITHERED_SHADOWS_ON || _CFXR_DITHERED_SHADOWS_CUSTOMTEXTURE
_ShadowStrength ("Shadows Strength Max", Range(0,1)) = 1.0
//# IF_KEYWORD _CFXR_DITHERED_SHADOWS_CUSTOMTEXTURE
_DitherCustom ("Dithering 3D Texture", 3D) = "black" {}
//# END_IF
//# END_IF
// _ReceivedShadowsStrength ("Received Shadows Strength", Range(0,1)) = 0.5
}
Category
{
Tags
{
"Queue"="Transparent"
"IgnoreProjector"="True"
"RenderType"="Transparent"
"PreviewType"="Plane"
}
Blend [_SrcBlend] [_DstBlend], One One
ZWrite [_ZWrite]
Cull Off
//====================================================================================================================================
// Universal Rendering Pipeline
Subshader
{
Pass
{
Name "BASE_URP"
Tags { "LightMode"="UniversalForward" }
CGPROGRAM
#pragma vertex vertex_program
#pragma fragment fragment_program
#pragma target 2.0
// #pragma multi_compile_instancing
// #pragma instancing_options procedural:ParticleInstancingSetup
#pragma multi_compile_fog
//#pragma multi_compile_fwdbase
//#pragma multi_compile SHADOWS_SCREEN
#pragma shader_feature_local _ _CFXR_SINGLE_CHANNEL
#pragma shader_feature_local _ _CFXR_DISSOLVE
#pragma shader_feature_local _ _CFXR_DISSOLVE_ALONG_UV_X
#pragma shader_feature_local _ _CFXR_UV_DISTORTION
#pragma shader_feature_local _ _CFXR_UV2_DISTORTION
#pragma shader_feature_local _ _CFXR_UV_DISTORTION_ADD
// #pragma shader_feature_local _ _CFXR_GRADIENTMAP
#pragma shader_feature_local _ _CFXR_SECONDCOLOR_LERP _CFXR_FONT_COLORS
#pragma shader_feature_local _ _CFXR_OVERLAYTEX_1X _CFXR_OVERLAYTEX_2X
#pragma shader_feature_local _ _CFXR_OVERLAYBLEND_A _CFXR_OVERLAYBLEND_RGB
#pragma shader_feature_local _ _CFXR_HDR_BOOST
#pragma shader_feature_local _ _CFXR_EDGE_FADING
#pragma shader_feature_local _ _CFXR_LIGHTING_DIRECT _CFXR_LIGHTING_INDIRECT _CFXR_LIGHTING_ALL
#pragma shader_feature_local _ _CFXR_LIGHTING_WPOS_OFFSET
#pragma shader_feature_local _ _CFXR_LIGHTING_BACK
// Using the same keywords as Unity's Standard Particle shader to minimize project-wide keyword usage
#pragma shader_feature_local _ _NORMALMAP
#pragma shader_feature_local _ _EMISSION
#pragma shader_feature_local _ _FLIPBOOK_BLENDING
#pragma shader_feature_local _ _FADING_ON
#pragma shader_feature_local _ _ALPHATEST_ON
#pragma shader_feature_local _ _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON _ALPHAMODULATE_ON _CFXR_ADDITIVE
#define CFXR_URP
#define CFXR_UBERSHADER
#include "CFXR_PASSES.cginc"
ENDCG
}
// Same as above with 'Universal2D' instead and DISABLE_SOFT_PARTICLES keyword
Pass
{
Name "BASE_URP"
Tags { "LightMode"="Universal2D" }
CGPROGRAM
#pragma vertex vertex_program
#pragma fragment fragment_program
#pragma target 2.0
// #pragma multi_compile_instancing
// #pragma instancing_options procedural:ParticleInstancingSetup
#pragma multi_compile_fog
//#pragma multi_compile_fwdbase
//#pragma multi_compile SHADOWS_SCREEN
#pragma shader_feature_local _ _CFXR_SINGLE_CHANNEL
#pragma shader_feature_local _ _CFXR_DISSOLVE
#pragma shader_feature_local _ _CFXR_DISSOLVE_ALONG_UV_X
#pragma shader_feature_local _ _CFXR_UV_DISTORTION
#pragma shader_feature_local _ _CFXR_UV2_DISTORTION
#pragma shader_feature_local _ _CFXR_UV_DISTORTION_ADD
// #pragma shader_feature_local _ _CFXR_GRADIENTMAP
#pragma shader_feature_local _ _CFXR_SECONDCOLOR_LERP _CFXR_FONT_COLORS
#pragma shader_feature_local _ _CFXR_OVERLAYTEX_1X _CFXR_OVERLAYTEX_2X
#pragma shader_feature_local _ _CFXR_OVERLAYBLEND_A _CFXR_OVERLAYBLEND_RGB
#pragma shader_feature_local _ _CFXR_HDR_BOOST
#pragma shader_feature_local _ _CFXR_EDGE_FADING
#pragma shader_feature_local _ _CFXR_LIGHTING_DIRECT _CFXR_LIGHTING_INDIRECT _CFXR_LIGHTING_ALL
#pragma shader_feature_local _ _CFXR_LIGHTING_WPOS_OFFSET
#pragma shader_feature_local _ _CFXR_LIGHTING_BACK
// Using the same keywords as Unity's Standard Particle shader to minimize project-wide keyword usage
#pragma shader_feature_local _ _NORMALMAP
#pragma shader_feature_local _ _EMISSION
#pragma shader_feature_local _ _FLIPBOOK_BLENDING
#pragma shader_feature_local _ _FADING_ON
#pragma shader_feature_local _ _ALPHATEST_ON
#pragma shader_feature_local _ _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON _ALPHAMODULATE_ON _CFXR_ADDITIVE
#define CFXR_UPR
#define DISABLE_SOFT_PARTICLES
#define CFXR_UBERSHADER
#include "CFXR_PASSES.cginc"
ENDCG
}
//--------------------------------------------------------------------------------------------------------------------------------
Pass
{
Name "ShadowCaster"
Tags { "LightMode" = "ShadowCaster" }
BlendOp Add
Blend One Zero
ZWrite On
Cull Off
CGPROGRAM
#pragma vertex vertex_program
#pragma fragment fragment_program
#pragma shader_feature_local _ _CFXR_SINGLE_CHANNEL
#pragma shader_feature_local _ _CFXR_DISSOLVE
#pragma shader_feature_local _ _CFXR_DISSOLVE_ALONG_UV_X
#pragma shader_feature_local _ _CFXR_UV_DISTORTION
#pragma shader_feature_local _ _CFXR_UV2_DISTORTION
#pragma shader_feature_local _ _CFXR_UV_DISTORTION_ADD
#pragma shader_feature_local _ _CFXR_OVERLAYTEX_1X _CFXR_OVERLAYTEX_2X
#pragma shader_feature_local _ _CFXR_OVERLAYBLEND_A _CFXR_OVERLAYBLEND_RGB
#pragma shader_feature_local _ _FLIPBOOK_BLENDING
#pragma shader_feature_local _ _ALPHATEST_ON
#pragma shader_feature_local _ _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON _ALPHAMODULATE_ON _CFXR_ADDITIVE
#pragma multi_compile_shadowcaster
#pragma shader_feature_local _ _CFXR_DITHERED_SHADOWS_ON _CFXR_DITHERED_SHADOWS_CUSTOMTEXTURE
#if (_CFXR_DITHERED_SHADOWS_ON || _CFXR_DITHERED_SHADOWS_CUSTOMTEXTURE) && !defined(SHADER_API_GLES)
#pragma target 3.0 //needed for VPOS
#endif
#define CFXR_UPR
#define PASS_SHADOW_CASTER
#define CFXR_UBERSHADER
#include "CFXR_PASSES.cginc"
ENDCG
}
}
//====================================================================================================================================
// Built-in Rendering Pipeline
SubShader
{
Pass
{
Name "BASE"
Tags { "LightMode"="ForwardBase" }
CGPROGRAM
#pragma vertex vertex_program
#pragma fragment fragment_program
//vertInstancingSetup writes to global, not allowed with DXC
// #pragma never_use_dxc
// #pragma target 2.5
// #pragma multi_compile_instancing
// #pragma instancing_options procedural:vertInstancingSetup
#pragma multi_compile_particles
#pragma multi_compile_fog
//#pragma multi_compile_fwdbase
//#pragma multi_compile SHADOWS_SCREEN
#pragma shader_feature_local _ _CFXR_SINGLE_CHANNEL
#pragma shader_feature_local _ _CFXR_DISSOLVE
#pragma shader_feature_local _ _CFXR_DISSOLVE_ALONG_UV_X
#pragma shader_feature_local _ _CFXR_UV_DISTORTION
#pragma shader_feature_local _ _CFXR_UV2_DISTORTION
#pragma shader_feature_local _ _CFXR_UV_DISTORTION_ADD
// #pragma shader_feature_local _ _CFXR_GRADIENTMAP
#pragma shader_feature_local _ _CFXR_SECONDCOLOR_LERP _CFXR_FONT_COLORS
#pragma shader_feature_local _ _CFXR_OVERLAYTEX_1X _CFXR_OVERLAYTEX_2X
#pragma shader_feature_local _ _CFXR_OVERLAYBLEND_A _CFXR_OVERLAYBLEND_RGB
#pragma shader_feature_local _ _CFXR_HDR_BOOST
#pragma shader_feature_local _ _CFXR_EDGE_FADING
#pragma shader_feature_local _ _CFXR_LIGHTING_DIRECT _CFXR_LIGHTING_INDIRECT _CFXR_LIGHTING_ALL
#pragma shader_feature_local _ _CFXR_LIGHTING_WPOS_OFFSET
#pragma shader_feature_local _ _CFXR_LIGHTING_BACK
// Using the same keywords as Unity's Standard Particle shader to minimize project-wide keyword usage
#pragma shader_feature_local _ _NORMALMAP
#pragma shader_feature_local _ _EMISSION
#pragma shader_feature_local _ _FLIPBOOK_BLENDING
#pragma shader_feature_local _ _FADING_ON
#pragma shader_feature_local _ _ALPHATEST_ON
#pragma shader_feature_local _ _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON _ALPHAMODULATE_ON _CFXR_ADDITIVE
#include "UnityStandardParticleInstancing.cginc"
#define CFXR_UBERSHADER
#include "CFXR_PASSES.cginc"
ENDCG
}
//--------------------------------------------------------------------------------------------------------------------------------
Pass
{
Name "ShadowCaster"
Tags { "LightMode" = "ShadowCaster" }
BlendOp Add
Blend One Zero
ZWrite On
Cull Off
CGPROGRAM
#pragma vertex vertex_program
#pragma fragment fragment_program
//vertInstancingSetup writes to global, not allowed with DXC
// #pragma never_use_dxc
// #pragma target 2.5
// #pragma multi_compile_instancing
// #pragma instancing_options procedural:vertInstancingSetup
#pragma shader_feature_local _ _CFXR_SINGLE_CHANNEL
#pragma shader_feature_local _ _CFXR_DISSOLVE
#pragma shader_feature_local _ _CFXR_DISSOLVE_ALONG_UV_X
#pragma shader_feature_local _ _CFXR_UV_DISTORTION
#pragma shader_feature_local _ _CFXR_UV2_DISTORTION
#pragma shader_feature_local _ _CFXR_UV_DISTORTION_ADD
#pragma shader_feature_local _ _CFXR_OVERLAYTEX_1X _CFXR_OVERLAYTEX_2X
#pragma shader_feature_local _ _CFXR_OVERLAYBLEND_A _CFXR_OVERLAYBLEND_RGB
#pragma shader_feature_local _ _FLIPBOOK_BLENDING
#pragma shader_feature_local _ _ALPHATEST_ON
#pragma shader_feature_local _ _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON _ALPHAMODULATE_ON _CFXR_ADDITIVE
#pragma multi_compile_shadowcaster
#pragma shader_feature_local _ _CFXR_DITHERED_SHADOWS_ON _CFXR_DITHERED_SHADOWS_CUSTOMTEXTURE
#if (_CFXR_DITHERED_SHADOWS_ON || _CFXR_DITHERED_SHADOWS_CUSTOMTEXTURE) && !defined(SHADER_API_GLES)
#pragma target 3.0 //needed for VPOS
#endif
#include "UnityStandardParticleInstancing.cginc"
#define PASS_SHADOW_CASTER
#define CFXR_UBERSHADER
#include "CFXR_PASSES.cginc"
ENDCG
}
}
}
CustomEditor "CartoonFX.MaterialInspector"
}

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: e198026df304af84a85675be636192ea
timeCreated: 1487089074
licenseType: Store
ShaderImporter:
defaultTextures: []
userData: USER,FTC1_RO_VCR,FTC2_RO_VCR,FTC0_RO,FTC_RSS,FGLOBAL_MASK,FTC1_RO,FTC2_RO,FTC2,FTC3,FTC1,FTEX0,FTC0_RO_TEXCOORD,FTC0,FTC1_RO_TEXCOORD,FTC2_RO_TEXCOORD,FTC0_SCROLL,FTC1_SCROLL,FTC2_SCROLL,KTC0_RO_SOURCE:v.color.r,KTC0_RSS_SOURCE:v.color.r,KTC_RSS_SOURCE:v.color.r,KTC1_RO_SOURCE:v.color.g,KTC2_RO_SOURCE:v.color.b,KTC3_RO_SOURCE:v.color.r,KTC0_RO_VC_CHANNEL:r,KTC0_RO_TEXCOORD_CHANNEL:x,KTC0_RO_TEXCOORD_NB:1,KTC1_RO_TEXCOORD_NB:1,KTC1_RO_TEXCOORD_CHANNEL:y,KTC2_RO_TEXCOORD_NB:3,ch8844A936,cSM:30,cCF:UnifiedParticleShaderTemplate
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,360 @@
//--------------------------------------------------------------------------------------------------------------------------------
// Cartoon FX
// (c) 2012-2020 Jean Moreno
//--------------------------------------------------------------------------------------------------------------------------------
#if defined(UNITY_PARTICLE_INSTANCING_ENABLED)
#pragma exclude_renderers gles
#endif
#if defined(GLOBAL_DISABLE_SOFT_PARTICLES) && !defined(DISABLE_SOFT_PARTICLES)
#define DISABLE_SOFT_PARTICLES
#endif
#if defined(CFXR_URP)
float LinearEyeDepthURP(float depth, float4 zBufferParam)
{
return 1.0 / (zBufferParam.z * depth + zBufferParam.w);
}
float SoftParticles(float near, float far, float4 projection)
{
float sceneZ = SAMPLE_DEPTH_TEXTURE_PROJ(_CameraDepthTexture, UNITY_PROJ_COORD(projection)).r;
#if defined(SOFT_PARTICLES_ORTHOGRAPHIC)
// orthographic camera
#if defined(UNITY_REVERSED_Z)
sceneZ = 1.0f - sceneZ;
#endif
sceneZ = (sceneZ * _ProjectionParams.z) + _ProjectionParams.y;
#else
// perspective camera
sceneZ = LinearEyeDepthURP(sceneZ, _ZBufferParams);
#endif
float fade = saturate (far * ((sceneZ - near) - projection.z));
return fade;
}
#else
float SoftParticles(float near, float far, float4 projection)
{
float sceneZ = (SAMPLE_DEPTH_TEXTURE_PROJ(_CameraDepthTexture, UNITY_PROJ_COORD(projection)));
#if defined(SOFT_PARTICLES_ORTHOGRAPHIC)
// orthographic camera
#if defined(UNITY_REVERSED_Z)
sceneZ = 1.0f - sceneZ;
#endif
sceneZ = (sceneZ * _ProjectionParams.z) + _ProjectionParams.y;
#else
// perspective camera
sceneZ = LinearEyeDepth(sceneZ);
#endif
float fade = saturate (far * ((sceneZ - near) - projection.z));
return fade;
}
#endif
float LinearToGammaSpaceApprox(float value)
{
return max(1.055h * pow(value, 0.416666667h) - 0.055h, 0.h);
}
// Same as UnityStandardUtils.cginc, but without the SHADER_TARGET limitation
half3 UnpackScaleNormal_CFXR(half4 packednormal, half bumpScale)
{
#if defined(UNITY_NO_DXT5nm)
half3 normal = packednormal.xyz * 2 - 1;
// #if (SHADER_TARGET >= 30)
// SM2.0: instruction count limitation
// SM2.0: normal scaler is not supported
normal.xy *= bumpScale;
// #endif
return normal;
#else
// This do the trick
packednormal.x *= packednormal.w;
half3 normal;
normal.xy = (packednormal.xy * 2 - 1);
// #if (SHADER_TARGET >= 30)
// SM2.0: instruction count limitation
// SM2.0: normal scaler is not supported
normal.xy *= bumpScale;
// #endif
normal.z = sqrt(1.0 - saturate(dot(normal.xy, normal.xy)));
return normal;
#endif
}
//Macros
// Project Position
#if !defined(PASS_SHADOW_CASTER) && !defined(GLOBAL_DISABLE_SOFT_PARTICLES) && !defined(DISABLE_SOFT_PARTICLES) && ( (defined(SOFTPARTICLES_ON) || defined(CFXR_URP) || defined(SOFT_PARTICLES_ORTHOGRAPHIC)) && defined(_FADING_ON) )
#define vertProjPos(o, clipPos) \
o.projPos = ComputeScreenPos(clipPos); \
COMPUTE_EYEDEPTH(o.projPos.z);
#else
#define vertProjPos(o, clipPos)
#endif
// Soft Particles
#if !defined(PASS_SHADOW_CASTER) && !defined(GLOBAL_DISABLE_SOFT_PARTICLES) && !defined(DISABLE_SOFT_PARTICLES) && ((defined(SOFTPARTICLES_ON) || defined(CFXR_URP) || defined(SOFT_PARTICLES_ORTHOGRAPHIC)) && defined(_FADING_ON))
#define fragSoftParticlesFade(i, color) \
color *= SoftParticles(_SoftParticlesFadeDistanceNear, _SoftParticlesFadeDistanceFar, i.projPos);
#else
#define fragSoftParticlesFade(i, color)
#endif
// Edge fade (note: particle meshes are already in world space)
#if !defined(PASS_SHADOW_CASTER) && defined(_CFXR_EDGE_FADING)
#define vertEdgeFade(v, color) \
float3 viewDir = UnityWorldSpaceViewDir(v.vertex); \
float ndv = abs(dot(normalize(viewDir), v.normal.xyz)); \
color *= saturate(pow(ndv, _EdgeFadePow));
#else
#define vertEdgeFade(v, color)
#endif
// Fog
#if _ALPHABLEND_ON
#define applyFog(i, color, alpha) UNITY_APPLY_FOG_COLOR(i.fogCoord, color, unity_FogColor);
#elif _ALPHAPREMULTIPLY_ON
#define applyFog(i, color, alpha) UNITY_APPLY_FOG_COLOR(i.fogCoord, color, alpha * unity_FogColor);
#elif _CFXR_ADDITIVE
#define applyFog(i, color, alpha) UNITY_APPLY_FOG_COLOR(i.fogCoord, color, half4(0, 0, 0, 0));
#elif _ALPHAMODULATE_ON
#define applyFog(i, color, alpha) UNITY_APPLY_FOG_COLOR(i.fogCoord, color, half4(1, 1, 1, 1));
#else
#define applyFog(i, color, alpha) UNITY_APPLY_FOG_COLOR(i.fogCoord, color, unity_FogColor);
#endif
// Vertex program
#if defined(PASS_SHADOW_CASTER)
void vert(appdata v, v2f_shadowCaster o, out float4 opos)
#else
v2f vert(appdata v, v2f o)
#endif
{
UNITY_TRANSFER_FOG(o, o.pos);
vertProjPos(o, o.pos);
vertEdgeFade(v, o.color.a);
#if defined(PASS_SHADOW_CASTER)
TRANSFER_SHADOW_CASTER_NOPOS(o, opos);
#else
return o;
#endif
}
// Fragment program
#if defined(PASS_SHADOW_CASTER)
float4 frag(v2f_shadowCaster i, UNITY_VPOS_TYPE vpos, half3 particleColor, half particleAlpha, half dissolve, half dissolveTime, half doubleDissolveWidth) : SV_Target
#else
half4 frag(v2f i, half3 particleColor, half particleAlpha, half dissolve, half dissolveTime, half doubleDissolveWidth) : SV_Target
#endif
{
#if _CFXR_DISSOLVE
// Dissolve
half time = lerp(-_DissolveSmooth, 1+_DissolveSmooth, dissolveTime);
particleAlpha *= smoothstep(dissolve - _DissolveSmooth, dissolve + _DissolveSmooth, time);
if (doubleDissolveWidth > 0)
{
half dissolveSubtract = smoothstep(dissolve - _DissolveSmooth, dissolve + _DissolveSmooth, time - doubleDissolveWidth);
particleAlpha = saturate(particleAlpha - dissolveSubtract);
}
#endif
//Blending
#if _ALPHAPREMULTIPLY_ON
particleColor *= particleAlpha;
#endif
#if _ALPHAMODULATE_ON
particleColor.rgb = lerp(float3(1,1,1), particleColor.rgb, particleAlpha);
#endif
#if _ALPHATEST_ON
clip(particleAlpha - _Cutoff);
#endif
#if !defined(PASS_SHADOW_CASTER)
// Fog & Soft Particles
applyFog(i, particleColor, particleAlpha);
fragSoftParticlesFade(i, particleAlpha);
#endif
// Prevent alpha from exceeding 1
particleAlpha = min(particleAlpha, 1.0);
#if !defined(PASS_SHADOW_CASTER)
return float4(particleColor, particleAlpha);
#else
//--------------------------------------------------------------------------------------------------------------------------------
// Shadow Caster Pass
#if _CFXR_ADDITIVE
half alpha = max(particleColor.r, max(particleColor.g, particleColor.b)) * particleAlpha;
#else
half alpha = particleAlpha;
#endif
#if (_CFXR_DITHERED_SHADOWS_ON || _CFXR_DITHERED_SHADOWS_CUSTOMTEXTURE) && !defined(SHADER_API_GLES)
alpha = min(alpha, _ShadowStrength);
// Use dither mask for alpha blended shadows, based on pixel position xy
// and alpha level. Our dither texture is 4x4x16.
#if _CFXR_DITHERED_SHADOWS_CUSTOMTEXTURE
half texSize = _DitherCustom_TexelSize.z;
alpha = tex3D(_DitherCustom, float3(vpos.xy*(1 / texSize), alpha*(1 - (1 / (texSize*texSize))))).a;
#else
alpha = tex3D(_DitherMaskLOD, float3(vpos.xy*0.25, alpha*0.9375)).a;
#endif
#endif
clip(alpha - 0.01);
SHADOW_CASTER_FRAGMENT(i)
#endif
}
// ================================================================================================================================
// ParticlesInstancing.hlsl
// ================================================================================================================================
#if defined(CFXR_URP)
#if defined(UNITY_PROCEDURAL_INSTANCING_ENABLED) && !defined(SHADER_TARGET_SURFACE_ANALYSIS)
#define UNITY_PARTICLE_INSTANCING_ENABLED
#endif
#if defined(UNITY_PARTICLE_INSTANCING_ENABLED)
#ifndef UNITY_PARTICLE_INSTANCE_DATA
#define UNITY_PARTICLE_INSTANCE_DATA DefaultParticleInstanceData
#endif
struct DefaultParticleInstanceData
{
float3x4 transform;
uint color;
float animFrame;
};
StructuredBuffer<UNITY_PARTICLE_INSTANCE_DATA> unity_ParticleInstanceData;
float4 unity_ParticleUVShiftData;
float unity_ParticleUseMeshColors;
void ParticleInstancingMatrices(out float4x4 objectToWorld, out float4x4 worldToObject)
{
UNITY_PARTICLE_INSTANCE_DATA data = unity_ParticleInstanceData[unity_InstanceID];
// transform matrix
objectToWorld._11_21_31_41 = float4(data.transform._11_21_31, 0.0f);
objectToWorld._12_22_32_42 = float4(data.transform._12_22_32, 0.0f);
objectToWorld._13_23_33_43 = float4(data.transform._13_23_33, 0.0f);
objectToWorld._14_24_34_44 = float4(data.transform._14_24_34, 1.0f);
// inverse transform matrix (TODO: replace with a library implementation if/when available)
float3x3 worldToObject3x3;
worldToObject3x3[0] = objectToWorld[1].yzx * objectToWorld[2].zxy - objectToWorld[1].zxy * objectToWorld[2].yzx;
worldToObject3x3[1] = objectToWorld[0].zxy * objectToWorld[2].yzx - objectToWorld[0].yzx * objectToWorld[2].zxy;
worldToObject3x3[2] = objectToWorld[0].yzx * objectToWorld[1].zxy - objectToWorld[0].zxy * objectToWorld[1].yzx;
float det = dot(objectToWorld[0].xyz, worldToObject3x3[0]);
worldToObject3x3 = transpose(worldToObject3x3);
worldToObject3x3 *= rcp(det);
float3 worldToObjectPosition = mul(worldToObject3x3, -objectToWorld._14_24_34);
worldToObject._11_21_31_41 = float4(worldToObject3x3._11_21_31, 0.0f);
worldToObject._12_22_32_42 = float4(worldToObject3x3._12_22_32, 0.0f);
worldToObject._13_23_33_43 = float4(worldToObject3x3._13_23_33, 0.0f);
worldToObject._14_24_34_44 = float4(worldToObjectPosition, 1.0f);
}
void ParticleInstancingSetup()
{
ParticleInstancingMatrices(unity_ObjectToWorld, unity_WorldToObject);
}
#else
void ParticleInstancingSetup() {}
#endif
#endif
// ================================================================================================================================
// Instancing functions
// ================================================================================================================================
float4 UnpackFromR8G8B8A8(uint rgba)
{
return float4(rgba & 255, (rgba >> 8) & 255, (rgba >> 16) & 255, (rgba >> 24) & 255) * (1.0 / 255);
}
half4 GetParticleColor(half4 color)
{
#if defined(UNITY_PARTICLE_INSTANCING_ENABLED)
#if !defined(UNITY_PARTICLE_INSTANCE_DATA_NO_COLOR)
UNITY_PARTICLE_INSTANCE_DATA data = unity_ParticleInstanceData[unity_InstanceID];
color = lerp(half4(1.0, 1.0, 1.0, 1.0), color, unity_ParticleUseMeshColors);
color *= UnpackFromR8G8B8A8(data.color);
#endif
#endif
return color;
}
void GetParticleTexcoords(out float2 outputTexcoord, out float2 outputTexcoord2, out float outputBlend, in float4 inputTexcoords, in float inputBlend)
{
#if defined(UNITY_PARTICLE_INSTANCING_ENABLED)
if (unity_ParticleUVShiftData.x != 0.0)
{
UNITY_PARTICLE_INSTANCE_DATA data = unity_ParticleInstanceData[unity_InstanceID];
float numTilesX = unity_ParticleUVShiftData.y;
float2 animScale = unity_ParticleUVShiftData.zw;
#ifdef UNITY_PARTICLE_INSTANCE_DATA_NO_ANIM_FRAME
float sheetIndex = 0.0;
#else
float sheetIndex = data.animFrame;
#endif
float index0 = floor(sheetIndex);
float vIdx0 = floor(index0 / numTilesX);
float uIdx0 = floor(index0 - vIdx0 * numTilesX);
float2 offset0 = float2(uIdx0 * animScale.x, (1.0 - animScale.y) - vIdx0 * animScale.y); // Copied from built-in as is and it looks like upside-down flip
outputTexcoord = inputTexcoords.xy * animScale.xy + offset0.xy;
#ifdef _FLIPBOOKBLENDING_ON
float index1 = floor(sheetIndex + 1.0);
float vIdx1 = floor(index1 / numTilesX);
float uIdx1 = floor(index1 - vIdx1 * numTilesX);
float2 offset1 = float2(uIdx1 * animScale.x, (1.0 - animScale.y) - vIdx1 * animScale.y);
outputTexcoord2.xy = inputTexcoords.xy * animScale.xy + offset1.xy;
outputBlend = frac(sheetIndex);
#endif
}
else
#endif
{
outputTexcoord = inputTexcoords.xy;
#ifdef _FLIPBOOKBLENDING_ON
outputTexcoord2.xy = inputTexcoords.zw;
outputBlend = inputBlend;
#endif
}
#ifndef _FLIPBOOKBLENDING_ON
outputTexcoord2.xy = inputTexcoords.xy;
outputBlend = 0.5;
#endif
}
void GetParticleTexcoords(out float2 outputTexcoord, in float2 inputTexcoord)
{
float2 dummyTexcoord2 = 0.0;
float dummyBlend = 0.0;
GetParticleTexcoords(outputTexcoord, dummyTexcoord2, dummyBlend, inputTexcoord.xyxy, 0.0);
}

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: b3dab2eb6bcf5df42a6c45d4638e0f46
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 0abf89ecb90eb024cbbc2a2dee76edf1
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,24 @@
//--------------------------------------------------------------------------------------------------------------------------------
// Cartoon FX
// (c) 2012-2020 Jean Moreno
//--------------------------------------------------------------------------------------------------------------------------------
// Global settings for the Cartoon FX Remaster shaders
//--------------------------------------------------------------------------------------------------------------------------------
/* Uncomment this line if you want to globally disable soft particles */
// #define GLOBAL_DISABLE_SOFT_PARTICLES
/* Uncomment this line to do Soft Particles depth calculation in Orthographic mode */
// #define SOFT_PARTICLES_ORTHOGRAPHIC
/* Change this value if you want to globally scale the HDR effects */
#define GLOBAL_HDR_MULTIPLIER 1
/* Comment this line if you want to disable point lights for lit particles */
#define ENABLE_POINT_LIGHTS
//--------------------------------------------------------------------------------------------------------------------------------

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 12c0fc6ff46c9b64a99fb4b921970883
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,232 @@
//--------------------------------------------------------------------------------------------------------------------------------
// Cartoon FX
// (c) 2012-2020 Jean Moreno
//--------------------------------------------------------------------------------------------------------------------------------
// Copy of URP specific variables needed for lighting
// ================================================================================================================================
// Input.hlsl:
// ================================================================================================================================
#if defined(SHADER_API_MOBILE) || (defined(SHADER_API_GLCORE) && !defined(SHADER_API_SWITCH)) || defined(SHADER_API_GLES) || defined(SHADER_API_GLES3) // Workaround for bug on Nintendo Switch where SHADER_API_GLCORE is mistakenly defined
#define MAX_VISIBLE_LIGHTS 32
#else
#define MAX_VISIBLE_LIGHTS 256
#endif
// --------------------------------
float4 _MainLightPosition;
half4 _MainLightColor;
// --------------------------------
half4 _AdditionalLightsCount;
#if USE_STRUCTURED_BUFFER_FOR_LIGHT_DATA
StructuredBuffer<LightData> _AdditionalLightsBuffer;
StructuredBuffer<int> _AdditionalLightsIndices;
#else
// GLES3 causes a performance regression in some devices when using CBUFFER.
#ifndef SHADER_API_GLES3
CBUFFER_START(AdditionalLights)
#endif
float4 _AdditionalLightsPosition[MAX_VISIBLE_LIGHTS];
half4 _AdditionalLightsColor[MAX_VISIBLE_LIGHTS];
half4 _AdditionalLightsAttenuation[MAX_VISIBLE_LIGHTS];
half4 _AdditionalLightsSpotDir[MAX_VISIBLE_LIGHTS];
half4 _AdditionalLightsOcclusionProbes[MAX_VISIBLE_LIGHTS];
#ifndef SHADER_API_GLES3
CBUFFER_END
#endif
#endif
// ================================================================================================================================
// UnityInput.hlsl:
// ================================================================================================================================
half4 unity_LightData;
half4 unity_LightIndices[2];
// --------------------------------
// ================================================================================================================================
// Macros.hlsl
// ================================================================================================================================
#define HALF_MIN 6.103515625e-5 // 2^-14, the same value for 10, 11 and 16-bit: https://www.khronos.org/opengl/wiki/Small_Float_Formats
// ================================================================================================================================
// Lighting.hlsl
// ================================================================================================================================
// Abstraction over Light shading data.
struct Light
{
half3 direction;
half3 color;
half distanceAttenuation;
half shadowAttenuation;
};
// Matches Unity Vanila attenuation
// Attenuation smoothly decreases to light range.
float DistanceAttenuation(float distanceSqr, half2 distanceAttenuation)
{
// We use a shared distance attenuation for additional directional and puctual lights
// for directional lights attenuation will be 1
float lightAtten = rcp(distanceSqr);
#if SHADER_HINT_NICE_QUALITY
// Use the smoothing factor also used in the Unity lightmapper.
half factor = distanceSqr * distanceAttenuation.x;
half smoothFactor = saturate(1.0h - factor * factor);
smoothFactor = smoothFactor * smoothFactor;
#else
// We need to smoothly fade attenuation to light range. We start fading linearly at 80% of light range
// Therefore:
// fadeDistance = (0.8 * 0.8 * lightRangeSq)
// smoothFactor = (lightRangeSqr - distanceSqr) / (lightRangeSqr - fadeDistance)
// We can rewrite that to fit a MAD by doing
// distanceSqr * (1.0 / (fadeDistanceSqr - lightRangeSqr)) + (-lightRangeSqr / (fadeDistanceSqr - lightRangeSqr)
// distanceSqr * distanceAttenuation.y + distanceAttenuation.z
half smoothFactor = saturate(distanceSqr * distanceAttenuation.x + distanceAttenuation.y);
#endif
return lightAtten * smoothFactor;
}
half AngleAttenuation(half3 spotDirection, half3 lightDirection, half2 spotAttenuation)
{
// Spot Attenuation with a linear falloff can be defined as
// (SdotL - cosOuterAngle) / (cosInnerAngle - cosOuterAngle)
// This can be rewritten as
// invAngleRange = 1.0 / (cosInnerAngle - cosOuterAngle)
// SdotL * invAngleRange + (-cosOuterAngle * invAngleRange)
// SdotL * spotAttenuation.x + spotAttenuation.y
// If we precompute the terms in a MAD instruction
half SdotL = dot(spotDirection, lightDirection);
half atten = saturate(SdotL * spotAttenuation.x + spotAttenuation.y);
return atten * atten;
}
// Fills a light struct given a perObjectLightIndex
Light GetAdditionalPerObjectLight(int perObjectLightIndex, float3 positionWS)
{
// Abstraction over Light input constants
#if USE_STRUCTURED_BUFFER_FOR_LIGHT_DATA
float4 lightPositionWS = _AdditionalLightsBuffer[perObjectLightIndex].position;
half3 color = _AdditionalLightsBuffer[perObjectLightIndex].color.rgb;
half4 distanceAndSpotAttenuation = _AdditionalLightsBuffer[perObjectLightIndex].attenuation;
half4 spotDirection = _AdditionalLightsBuffer[perObjectLightIndex].spotDirection;
half4 lightOcclusionProbeInfo = _AdditionalLightsBuffer[perObjectLightIndex].occlusionProbeChannels;
#else
float4 lightPositionWS = _AdditionalLightsPosition[perObjectLightIndex];
half3 color = _AdditionalLightsColor[perObjectLightIndex].rgb;
half4 distanceAndSpotAttenuation = _AdditionalLightsAttenuation[perObjectLightIndex];
half4 spotDirection = _AdditionalLightsSpotDir[perObjectLightIndex];
half4 lightOcclusionProbeInfo = _AdditionalLightsOcclusionProbes[perObjectLightIndex];
#endif
// Directional lights store direction in lightPosition.xyz and have .w set to 0.0.
// This way the following code will work for both directional and punctual lights.
float3 lightVector = lightPositionWS.xyz - positionWS * lightPositionWS.w;
float distanceSqr = max(dot(lightVector, lightVector), HALF_MIN);
half3 lightDirection = half3(lightVector * rsqrt(distanceSqr));
half attenuation = DistanceAttenuation(distanceSqr, distanceAndSpotAttenuation.xy) * AngleAttenuation(spotDirection.xyz, lightDirection, distanceAndSpotAttenuation.zw);
Light light;
light.direction = lightDirection;
light.distanceAttenuation = attenuation;
/// light.shadowAttenuation = AdditionalLightRealtimeShadow(perObjectLightIndex, positionWS);
light.shadowAttenuation = 1;
light.color = color;
// In case we're using light probes, we can sample the attenuation from the `unity_ProbesOcclusion`
#if defined(LIGHTMAP_ON) || defined(_MIXED_LIGHTING_SUBTRACTIVE)
// First find the probe channel from the light.
// Then sample `unity_ProbesOcclusion` for the baked occlusion.
// If the light is not baked, the channel is -1, and we need to apply no occlusion.
// probeChannel is the index in 'unity_ProbesOcclusion' that holds the proper occlusion value.
int probeChannel = lightOcclusionProbeInfo.x;
// lightProbeContribution is set to 0 if we are indeed using a probe, otherwise set to 1.
half lightProbeContribution = lightOcclusionProbeInfo.y;
half probeOcclusionValue = unity_ProbesOcclusion[probeChannel];
light.distanceAttenuation *= max(probeOcclusionValue, lightProbeContribution);
#endif
return light;
}
uint GetPerObjectLightIndexOffset()
{
#if USE_STRUCTURED_BUFFER_FOR_LIGHT_DATA
return unity_LightData.x;
#else
return 0;
#endif
}
// Returns a per-object index given a loop index.
// This abstract the underlying data implementation for storing lights/light indices
int GetPerObjectLightIndex(uint index)
{
/////////////////////////////////////////////////////////////////////////////////////////////
// Structured Buffer Path /
// /
// Lights and light indices are stored in StructuredBuffer. We can just index them. /
// Currently all non-mobile platforms take this path :( /
// There are limitation in mobile GPUs to use SSBO (performance / no vertex shader support) /
/////////////////////////////////////////////////////////////////////////////////////////////
#if USE_STRUCTURED_BUFFER_FOR_LIGHT_DATA
uint offset = unity_LightData.x;
return _AdditionalLightsIndices[offset + index];
/////////////////////////////////////////////////////////////////////////////////////////////
// UBO path /
// /
// We store 8 light indices in float4 unity_LightIndices[2]; /
// Due to memory alignment unity doesn't support int[] or float[] /
// Even trying to reinterpret cast the unity_LightIndices to float[] won't work /
// it will cast to float4[] and create extra register pressure. :( /
/////////////////////////////////////////////////////////////////////////////////////////////
#elif !defined(SHADER_API_GLES)
// since index is uint shader compiler will implement
// div & mod as bitfield ops (shift and mask).
// TODO: Can we index a float4? Currently compiler is
// replacing unity_LightIndicesX[i] with a dp4 with identity matrix.
// u_xlat16_40 = dot(unity_LightIndices[int(u_xlatu13)], ImmCB_0_0_0[u_xlati1]);
// This increases both arithmetic and register pressure.
return unity_LightIndices[index / 4][index % 4];
#else
// Fallback to GLES2. No bitfield magic here :(.
// We limit to 4 indices per object and only sample unity_4LightIndices0.
// Conditional moves are branch free even on mali-400
// small arithmetic cost but no extra register pressure from ImmCB_0_0_0 matrix.
half2 lightIndex2 = (index < 2.0h) ? unity_LightIndices[0].xy : unity_LightIndices[0].zw;
half i_rem = (index < 2.0h) ? index : index - 2.0h;
return (i_rem < 1.0h) ? lightIndex2.x : lightIndex2.y;
#endif
}
// Fills a light struct given a loop i index. This will convert the i
// index to a perObjectLightIndex
Light GetAdditionalLight(uint i, float3 positionWS)
{
int perObjectLightIndex = GetPerObjectLightIndex(i);
return GetAdditionalPerObjectLight(perObjectLightIndex, positionWS);
}
int GetAdditionalLightsCount()
{
// TODO: we need to expose in SRP api an ability for the pipeline cap the amount of lights
// in the culling. This way we could do the loop branch with an uniform
// This would be helpful to support baking exceeding lights in SH as well
return min(_AdditionalLightsCount.x, unity_LightData.y);
}

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 3eab241579cd5514388d88f452714385
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant: