This commit is contained in:
2026-11-24 15:51:02 +01:00
parent cca4d73e41
commit f4aa17114a
22092 changed files with 5042406 additions and 0 deletions
@@ -0,0 +1,107 @@
#ifndef UNIVERSAL_PARTICLES_LIT_DEPTH_NORMALS_PASS_INCLUDED
#define UNIVERSAL_PARTICLES_LIT_DEPTH_NORMALS_PASS_INCLUDED
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
VaryingsDepthNormalsParticle DepthNormalsVertex(AttributesDepthNormalsParticle input)
{
VaryingsDepthNormalsParticle output = (VaryingsDepthNormalsParticle)0;
UNITY_SETUP_INSTANCE_ID(input);
UNITY_TRANSFER_INSTANCE_ID(input, output);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
VertexPositionInputs vertexInput = GetParticleVertexPositionInputs(input.vertex.xyz);
VertexNormalInputs normalInput = GetParticleVertexNormalInputs(input.normal, input.tangent);
half3 viewDirWS = GetWorldSpaceNormalizeViewDir(vertexInput.positionWS);
#if defined(_NORMALMAP)
output.normalWS = half4(normalInput.normalWS, viewDirWS.x);
output.tangentWS = half4(normalInput.tangentWS, viewDirWS.y);
output.bitangentWS = half4(normalInput.bitangentWS, viewDirWS.z);
#else
output.normalWS = normalInput.normalWS;
output.viewDirWS = viewDirWS;
#endif
output.clipPos = vertexInput.positionCS;
#if defined(_ALPHATEST_ON)
output.color = GetParticleColor(input.color);
#endif
#if defined(_ALPHATEST_ON) || defined(_NORMALMAP)
#if defined(_FLIPBOOKBLENDING_ON)
#if defined(UNITY_PARTICLE_INSTANCING_ENABLED)
GetParticleTexcoords(output.texcoord, output.texcoord2AndBlend, input.texcoords.xyxy, 0.0);
#else
GetParticleTexcoords(output.texcoord, output.texcoord2AndBlend, input.texcoords, input.texcoordBlend);
#endif
#else
GetParticleTexcoords(output.texcoord, input.texcoords.xy);
#endif
#endif
return output;
}
half4 DepthNormalsFragment(VaryingsDepthNormalsParticle input) : SV_TARGET
{
UNITY_SETUP_INSTANCE_ID(input);
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);
// Inputs...
#if defined(_ALPHATEST_ON) || defined(_NORMALMAP) || defined(_WRITE_SMOOTHNESS)
float2 uv = input.texcoord;
#if defined(_FLIPBOOKBLENDING_ON)
float3 blendUv = input.texcoord2AndBlend;
#else
float3 blendUv = float3(0,0,0);
#endif
#endif
// Check if we need to discard...
#if defined(_ALPHATEST_ON)
half4 vertexColor = input.color;
half4 baseColor = _BaseColor;
half4 albedo = BlendTexture(UnityBuildTexture2DStructNoScaleNoTexelSize(_BaseMap), uv, blendUv) * baseColor;
half4 colorAddSubDiff = half4(0, 0, 0, 0);
#if defined(_COLORADDSUBDIFF_ON)
colorAddSubDiff = _BaseColorAddSubDiff;
#endif
albedo = MixParticleColor(albedo, vertexColor, colorAddSubDiff);
AlphaDiscard(albedo.a, _Cutoff);
#endif
// Normals...
#ifdef _NORMALMAP
half3 normalTS = SampleNormalTS(uv, blendUv, UnityBuildTexture2DStructNoScaleNoTexelSize(_BumpMap), _BumpScale);
float3 normalWS = TransformTangentToWorld(normalTS, half3x3(input.tangentWS.xyz, input.bitangentWS.xyz, input.normalWS.xyz));
#else
float3 normalWS = input.normalWS;
#endif
half outputAlpha = 0;
#if defined(_WRITE_SMOOTHNESS)
#if defined(_METALLICSPECGLOSSMAP)
outputAlpha = BlendTexture(UnityBuildTexture2DStructNoScaleNoTexelSize(_MetallicGlossMap), uv, blendUv).a * _Smoothness;
#else
outputAlpha = _Smoothness;
#endif
#endif
// Output...
#if defined(_GBUFFER_NORMALS_OCT)
float2 octNormalWS = PackNormalOctQuadEncode(normalWS); // values between [-1, +1], must use fp32 on some platforms
float2 remappedOctNormalWS = saturate(octNormalWS * 0.5 + 0.5); // values between [ 0, 1]
half3 packedNormalWS = PackFloat2To888(remappedOctNormalWS); // values between [ 0, 1]
return half4(packedNormalWS, outputAlpha);
#else
return half4(NormalizeNormalPerPixel(normalWS), outputAlpha);
#endif
}
#endif // UNIVERSAL_PARTICLES_LIT_DEPTH_NORMALS_PASS_INCLUDED
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 637c27b6fe6224a06b2b066769d0a6e6
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,63 @@
#ifndef UNIVERSAL_PARTICLES_LIT_DEPTH_ONLY_PASS_INCLUDED
#define UNIVERSAL_PARTICLES_LIT_DEPTH_ONLY_PASS_INCLUDED
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
VaryingsDepthOnlyParticle DepthOnlyVertex(AttributesDepthOnlyParticle input)
{
VaryingsDepthOnlyParticle output = (VaryingsDepthOnlyParticle)0;
UNITY_SETUP_INSTANCE_ID(input);
UNITY_TRANSFER_INSTANCE_ID(input, output);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
VertexPositionInputs vertexInput = GetParticleVertexPositionInputs(input.vertex.xyz);
output.clipPos = vertexInput.positionCS;
#if defined(_ALPHATEST_ON)
output.color = GetParticleColor(input.color);
#if defined(_FLIPBOOKBLENDING_ON)
#if defined(UNITY_PARTICLE_INSTANCING_ENABLED)
GetParticleTexcoords(output.texcoord, output.texcoord2AndBlend, input.texcoords.xyxy, 0.0);
#else
GetParticleTexcoords(output.texcoord, output.texcoord2AndBlend, input.texcoords, input.texcoordBlend);
#endif
#else
GetParticleTexcoords(output.texcoord, input.texcoords.xy);
#endif
#endif
return output;
}
half DepthOnlyFragment(VaryingsDepthOnlyParticle input) : SV_TARGET
{
UNITY_SETUP_INSTANCE_ID(input);
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);
// Check if we need to discard...
#if defined(_ALPHATEST_ON)
float2 uv = input.texcoord;
half4 vertexColor = input.color;
half4 baseColor = _BaseColor;
#if defined(_FLIPBOOKBLENDING_ON)
float3 blendUv = input.texcoord2AndBlend;
#else
float3 blendUv = float3(0,0,0);
#endif
half4 albedo = BlendTexture(UnityBuildTexture2DStructNoScaleNoTexelSize(_BaseMap), uv, blendUv) * baseColor;
half4 colorAddSubDiff = half4(0, 0, 0, 0);
#if defined (_COLORADDSUBDIFF_ON)
colorAddSubDiff = _BaseColorAddSubDiff;
#endif
albedo = MixParticleColor(albedo, vertexColor, colorAddSubDiff);
AlphaDiscard(albedo.a, _Cutoff);
#endif
return input.clipPos.z;
}
#endif // UNIVERSAL_PARTICLES_LIT_DEPTH_ONLY_PASS_INCLUDED
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: e9795406c7fc049d2b125cce47405fa9
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,72 @@
#ifndef UNIVERSAL_PARTICLES_EDITOR_PASS_INCLUDED
#define UNIVERSAL_PARTICLES_EDITOR_PASS_INCLUDED
#include "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesInput.hlsl"
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Particles.hlsl"
float _ObjectId;
float _PassValue;
float4 _SelectionID;
///////////////////////////////////////////////////////////////////////////////
// Vertex and Fragment functions //
///////////////////////////////////////////////////////////////////////////////
VaryingsParticle vertParticleEditor(AttributesParticle input)
{
VaryingsParticle output = (VaryingsParticle)0;
UNITY_SETUP_INSTANCE_ID(input);
UNITY_TRANSFER_INSTANCE_ID(input, output);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
VertexPositionInputs vertexInput = GetParticleVertexPositionInputs(input.positionOS.xyz);
output.clipPos = vertexInput.positionCS;
output.color = GetParticleColor(input.color);
#if defined(_FLIPBOOKBLENDING_ON) && !defined(UNITY_PARTICLE_INSTANCING_ENABLED)
GetParticleTexcoords(output.texcoord, output.texcoord2AndBlend, input.texcoords, input.texcoordBlend);
#else
GetParticleTexcoords(output.texcoord, input.texcoords.xy);
#endif
return output;
}
void fragParticleSceneClip(VaryingsParticle input)
{
UNITY_SETUP_INSTANCE_ID(input);
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);
float2 uv = input.texcoord;
float3 blendUv = float3(0, 0, 0);
#if defined(_FLIPBOOKBLENDING_ON)
blendUv = input.texcoord2AndBlend;
#endif
float4 projectedPosition = float4(0, 0, 0, 0);
half4 albedo = SampleAlbedo(uv, blendUv, _BaseColor, input.color, projectedPosition, UnityBuildTexture2DStructNoScaleNoTexelSize(_BaseMap));
half alpha = albedo.a;
#ifdef _ALPHATEST_ON
clip(alpha - _Cutoff);
#endif
}
half4 fragParticleSceneHighlight(VaryingsParticle input) : SV_Target
{
fragParticleSceneClip(input);
return float4(_ObjectId, _PassValue, 1, 1);
}
half4 fragParticleScenePicking(VaryingsParticle input) : SV_Target
{
fragParticleSceneClip(input);
return _SelectionID;
}
#endif // UNIVERSAL_PARTICLES_EDITOR_PASS_INCLUDED
@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: b75058dfffdae7a41bf0373f3d2f264c
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
preprocessorOverride: 0
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,188 @@
#ifndef UNIVERSAL_PARTICLES_INPUT_INCLUDED
#define UNIVERSAL_PARTICLES_INPUT_INCLUDED
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
struct AttributesParticle
{
float4 positionOS : POSITION;
half4 color : COLOR;
#if defined(_FLIPBOOKBLENDING_ON) && !defined(UNITY_PARTICLE_INSTANCING_ENABLED)
float4 texcoords : TEXCOORD0;
float texcoordBlend : TEXCOORD1;
#else
float2 texcoords : TEXCOORD0;
#endif
#if !defined(PARTICLES_EDITOR_META_PASS)
float3 normalOS : NORMAL;
float4 tangentOS : TANGENT;
#endif
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct VaryingsParticle
{
float4 clipPos : SV_POSITION;
float2 texcoord : TEXCOORD0;
half4 color : COLOR;
#if defined(_FLIPBOOKBLENDING_ON)
float3 texcoord2AndBlend : TEXCOORD5;
#endif
#if !defined(PARTICLES_EDITOR_META_PASS)
float4 positionWS : TEXCOORD1;
#ifdef _NORMALMAP
half4 normalWS : TEXCOORD2; // xyz: normal, w: viewDir.x
half4 tangentWS : TEXCOORD3; // xyz: tangent, w: viewDir.y
half4 bitangentWS : TEXCOORD4; // xyz: bitangent, w: viewDir.z
#else
half3 normalWS : TEXCOORD2;
half3 viewDirWS : TEXCOORD3;
#endif
#if defined(_SOFTPARTICLES_ON) || defined(_FADING_ON) || defined(_DISTORTION_ON)
float4 projectedPosition: TEXCOORD6;
#endif
#if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
float4 shadowCoord : TEXCOORD7;
#endif
half3 vertexSH : TEXCOORD8; // SH
#ifdef USE_APV_PROBE_OCCLUSION
float4 probeOcclusion : TEXCOORD9;
#endif
#endif
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
};
struct AttributesShadowCasterParticle
{
float4 positionOS : POSITION;
float3 normalOS : NORMAL;
#if defined(_ALPHATEST_ON)
half4 color : COLOR;
#if defined(_FLIPBOOKBLENDING_ON) && !defined(UNITY_PARTICLE_INSTANCING_ENABLED)
float4 texcoords : TEXCOORD0;
float texcoordBlend : TEXCOORD1;
#else
float2 texcoords : TEXCOORD0;
#endif
#endif
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct VaryingsShadowCasterParticle
{
float4 positionCS : SV_POSITION;
#if defined(_ALPHATEST_ON)
half4 color : COLOR;
float2 texcoord : TEXCOORD0;
#if defined(_FLIPBOOKBLENDING_ON)
float3 texcoord2AndBlend : TEXCOORD5;
#endif
#endif
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
};
struct AttributesDepthOnlyParticle
{
float4 vertex : POSITION;
#if defined(_ALPHATEST_ON)
half4 color : COLOR;
#if defined(_FLIPBOOKBLENDING_ON) && !defined(UNITY_PARTICLE_INSTANCING_ENABLED)
float4 texcoords : TEXCOORD0;
float texcoordBlend : TEXCOORD1;
#else
float2 texcoords : TEXCOORD0;
#endif
#endif
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct VaryingsDepthOnlyParticle
{
float4 clipPos : SV_POSITION;
#if defined(_ALPHATEST_ON)
float2 texcoord : TEXCOORD0;
half4 color : COLOR;
#if defined(_FLIPBOOKBLENDING_ON)
float3 texcoord2AndBlend : TEXCOORD5;
#endif
#endif
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
};
struct AttributesDepthNormalsParticle
{
float4 vertex : POSITION;
#if defined(_ALPHATEST_ON)
half4 color : COLOR;
#endif
#if defined(_ALPHATEST_ON) || defined(_NORMALMAP)
#if defined(_FLIPBOOKBLENDING_ON) && !defined(UNITY_PARTICLE_INSTANCING_ENABLED)
float4 texcoords : TEXCOORD0;
float texcoordBlend : TEXCOORD1;
#else
float2 texcoords : TEXCOORD0;
#endif
#endif
float3 normal : NORMAL;
float4 tangent : TANGENT;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct VaryingsDepthNormalsParticle
{
float4 clipPos : SV_POSITION;
#if defined(_ALPHATEST_ON)
half4 color : COLOR;
#endif
#if defined(_ALPHATEST_ON) || defined(_NORMALMAP) || defined(_WRITE_SMOOTHNESS)
float2 texcoord : TEXCOORD0;
#if defined(_FLIPBOOKBLENDING_ON)
float3 texcoord2AndBlend : TEXCOORD5;
#endif
#endif
#if defined(_NORMALMAP)
float4 normalWS : TEXCOORD2; // xyz: normal, w: viewDir.x
float4 tangentWS : TEXCOORD3; // xyz: tangent, w: viewDir.y
float4 bitangentWS : TEXCOORD4; // xyz: bitangent, w: viewDir.z
#else
float3 normalWS : TEXCOORD2;
float3 viewDirWS : TEXCOORD3;
#endif
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
};
#endif // UNIVERSAL_PARTICLES_INPUT_INCLUDED
@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 1acd75ff24dbc43cca235408192130b7
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
preprocessorOverride: 0
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,507 @@
Shader "Universal Render Pipeline/Particles/Lit"
{
Properties
{
[MainTexture] _BaseMap("Base Map", 2D) = "white" {}
[MainColor] _BaseColor("Base Color", Color) = (1,1,1,1)
_Cutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5
_MetallicGlossMap("Metallic Map", 2D) = "white" {}
[Gamma] _Metallic("Metallic", Range(0.0, 1.0)) = 0.0
_Smoothness("Smoothness", Range(0.0, 1.0)) = 0.5
_BumpScale("Scale", Float) = 1.0
_BumpMap("Normal Map", 2D) = "bump" {}
[HDR] _EmissionColor("Color", Color) = (0,0,0)
_EmissionMap("Emission", 2D) = "white" {}
[ToggleUI] _ReceiveShadows("Receive Shadows", Float) = 1.0
// -------------------------------------
// Particle specific
_SoftParticlesNearFadeDistance("Soft Particles Near Fade", Float) = 0.0
_SoftParticlesFarFadeDistance("Soft Particles Far Fade", Float) = 1.0
_CameraNearFadeDistance("Camera Near Fade", Float) = 1.0
_CameraFarFadeDistance("Camera Far Fade", Float) = 2.0
_DistortionBlend("Distortion Blend", Range(0.0, 1.0)) = 0.5
_DistortionStrength("Distortion Strength", Float) = 1.0
// -------------------------------------
// Hidden properties - Generic
_Surface("__surface", Float) = 0.0
_Blend("__mode", Float) = 0.0
_Cull("__cull", Float) = 2.0
[ToggleUI] _AlphaClip("__clip", Float) = 0.0
[HideInInspector] _BlendOp("__blendop", Float) = 0.0
[HideInInspector] _SrcBlend("__src", Float) = 1.0
[HideInInspector] _DstBlend("__dst", Float) = 0.0
[HideInInspector] _SrcBlendAlpha("__srcA", Float) = 1.0
[HideInInspector] _DstBlendAlpha("__dstA", Float) = 0.0
[HideInInspector] _ZWrite("__zw", Float) = 1.0
[HideInInspector] _BlendModePreserveSpecular("_BlendModePreserveSpecular", Float) = 1.0
[HideInInspector] _AlphaToMask("__alphaToMask", Float) = 0.0
// Particle specific
_ColorMode("_ColorMode", Float) = 0.0
[HideInInspector] _BaseColorAddSubDiff("_ColorMode", Vector) = (0,0,0,0)
[ToggleOff] _FlipbookBlending("__flipbookblending", Float) = 0.0
[ToggleUI] _SoftParticlesEnabled("__softparticlesenabled", Float) = 0.0
[ToggleUI] _CameraFadingEnabled("__camerafadingenabled", Float) = 0.0
[ToggleUI] _DistortionEnabled("__distortionenabled", Float) = 0.0
[HideInInspector] _SoftParticleFadeParams("__softparticlefadeparams", Vector) = (0,0,0,0)
[HideInInspector] _CameraFadeParams("__camerafadeparams", Vector) = (0,0,0,0)
[HideInInspector] _DistortionStrengthScaled("Distortion Strength Scaled", Float) = 0.1
// Editmode props
_QueueOffset("Queue offset", Float) = 0.0
// ObsoleteProperties
[HideInInspector] _FlipbookMode("flipbook", Float) = 0
[HideInInspector] _Glossiness("gloss", Float) = 0
[HideInInspector] _Mode("mode", Float) = 0
[HideInInspector] _Color("color", Color) = (1,1,1,1)
}
HLSLINCLUDE
ENDHLSL
SubShader
{
Tags
{
"RenderType" = "Opaque"
"IgnoreProjector" = "True"
"PreviewType" = "Plane"
"PerformanceChecks" = "False"
"RenderPipeline" = "UniversalPipeline"
"UniversalMaterialType" = "Lit"
}
// ------------------------------------------------------------------
// Forward pass.
Pass
{
// Lightmode matches the ShaderPassName set in UniversalRenderPipeline.cs. SRPDefaultUnlit and passes with
// no LightMode tag are also rendered by Universal Render Pipeline
Name "ForwardLit"
Tags
{
"LightMode" = "UniversalForward"
}
// -------------------------------------
// Render State Commands
BlendOp[_BlendOp]
Blend[_SrcBlend][_DstBlend], [_SrcBlendAlpha][_DstBlendAlpha]
ZWrite[_ZWrite]
Cull[_Cull]
AlphaToMask[_AlphaToMask]
HLSLPROGRAM
#pragma target 2.0
// -------------------------------------
// Shader Stages
#pragma vertex ParticlesLitVertex
#pragma fragment ParticlesLitFragment
// -------------------------------------
// Material Keywords
#pragma shader_feature_local _NORMALMAP
#pragma shader_feature_local _RECEIVE_SHADOWS_OFF
#pragma shader_feature_local_fragment _SURFACE_TYPE_TRANSPARENT
#pragma shader_feature_local_fragment _EMISSION
#pragma shader_feature_local_fragment _METALLICSPECGLOSSMAP
// -------------------------------------
// Particle Keywords
#pragma shader_feature_local _FLIPBOOKBLENDING_ON
#pragma shader_feature_local _SOFTPARTICLES_ON
#pragma shader_feature_local _FADING_ON
#pragma shader_feature_local _DISTORTION_ON
#pragma shader_feature_local_fragment _ _ALPHAPREMULTIPLY_ON _ALPHAMODULATE_ON
#pragma shader_feature_local_fragment _ _ALPHATEST_ON
#pragma shader_feature_local_fragment _ _COLOROVERLAY_ON _COLORCOLOR_ON _COLORADDSUBDIFF_ON
// -------------------------------------
// Universal Pipeline keywords
#pragma multi_compile _ _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE _MAIN_LIGHT_SHADOWS_SCREEN
#pragma multi_compile _ _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS
#pragma multi_compile_fragment _ _ADDITIONAL_LIGHT_SHADOWS
#pragma multi_compile_fragment _ _REFLECTION_PROBE_BLENDING
#pragma multi_compile_fragment _ _REFLECTION_PROBE_BOX_PROJECTION
#pragma multi_compile_fragment _ _REFLECTION_PROBE_ATLAS
#pragma multi_compile_fragment _ _SCREEN_SPACE_REFLECTION
#pragma multi_compile_fragment _ _SHADOWS_SOFT _SHADOWS_SOFT_LOW _SHADOWS_SOFT_MEDIUM _SHADOWS_SOFT_HIGH
#pragma multi_compile_fragment _ _SCREEN_SPACE_OCCLUSION
#pragma multi_compile_fragment _ _LIGHT_COOKIES
#pragma multi_compile _ _LIGHT_LAYERS
#pragma multi_compile _ _CLUSTER_LIGHT_LOOP
#pragma multi_compile _ EVALUATE_SH_MIXED EVALUATE_SH_VERTEX
#if defined(UNITY_PLATFORM_META_QUEST)
#pragma multi_compile _ META_QUEST_ORTHO_PROJ
#pragma multi_compile _ META_QUEST_NO_SPOTLIGHTS_LIGHT_LOOP
#endif
#include_with_pragmas "Packages/com.unity.render-pipelines.core/ShaderLibrary/FoveatedRenderingKeywords.hlsl"
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Fog.hlsl"
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ProbeVolumeVariants.hlsl"
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/RenderingLayers.hlsl"
// -------------------------------------
// Unity defined keywords
#pragma multi_compile _ LIGHTMAP_SHADOW_MIXING
#pragma multi_compile_instancing
#pragma multi_compile_fragment _ DEBUG_DISPLAY
#pragma instancing_options procedural:ParticleInstancingSetup
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl"
// -------------------------------------
// Includes
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesLitInput.hlsl"
#include "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesLitForwardPass.hlsl"
ENDHLSL
}
// ------------------------------------------------------------------
// GBuffer pass.
Pass
{
// Lightmode matches the ShaderPassName set in UniversalRenderPipeline.cs. SRPDefaultUnlit and passes with
// no LightMode tag are also rendered by Universal Render Pipeline
Name "GBuffer"
Tags
{
"LightMode" = "UniversalGBuffer"
}
// -------------------------------------
// Render State Commands
ZWrite[_ZWrite]
Cull[_Cull]
HLSLPROGRAM
#pragma target 4.5
// Deferred Rendering Path does not support the OpenGL-based graphics API:
// Desktop OpenGL, OpenGL ES 3.0, WebGL 2.0.
#pragma exclude_renderers gles3 glcore
// -------------------------------------
// Shader Stages
#pragma vertex ParticlesGBufferVertex
#pragma fragment ParticlesGBufferFragment
// -------------------------------------
// Material Keywords
#pragma shader_feature_local _NORMALMAP
#pragma shader_feature_local_fragment _EMISSION
#pragma shader_feature_local_fragment _METALLICSPECGLOSSMAP
#pragma shader_feature_local _RECEIVE_SHADOWS_OFF
// -------------------------------------
// Particle Keywords
//#pragma shader_feature _ _ALPHAPREMULTIPLY_ON _ALPHAMODULATE_ON
#pragma shader_feature_local_fragment _ALPHATEST_ON
#pragma shader_feature_local_fragment _ _COLOROVERLAY_ON _COLORCOLOR_ON _COLORADDSUBDIFF_ON
#pragma shader_feature_local _FLIPBOOKBLENDING_ON
//#pragma shader_feature _SOFTPARTICLES_ON
//#pragma shader_feature _FADING_ON
//#pragma shader_feature _DISTORTION_ON
// -------------------------------------
// Universal Pipeline keywords
#pragma multi_compile _ _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE _MAIN_LIGHT_SHADOWS_SCREEN
//#pragma multi_compile _ _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS
//#pragma multi_compile _ _ADDITIONAL_LIGHT_SHADOWS
#pragma multi_compile_fragment _ _REFLECTION_PROBE_BLENDING
#pragma multi_compile_fragment _ _REFLECTION_PROBE_BOX_PROJECTION
#pragma multi_compile_fragment _ _SCREEN_SPACE_REFLECTION
#pragma multi_compile_fragment _ _SHADOWS_SOFT _SHADOWS_SOFT_LOW _SHADOWS_SOFT_MEDIUM _SHADOWS_SOFT_HIGH
#pragma multi_compile_fragment _ _GBUFFER_NORMALS_OCT
#pragma multi_compile_fragment _ _RENDER_PASS_ENABLED
#pragma multi_compile _ _CLUSTER_LIGHT_LOOP
#pragma multi_compile _ EVALUATE_SH_MIXED EVALUATE_SH_VERTEX
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/RenderingLayers.hlsl"
// -------------------------------------
// Unity defined keywords
#pragma multi_compile _ LIGHTMAP_SHADOW_MIXING
#pragma multi_compile_instancing
#pragma instancing_options procedural:ParticleInstancingSetup
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl"
// -------------------------------------
// Includes
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesLitInput.hlsl"
#include "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesLitGbufferPass.hlsl"
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/GBufferOutputFormat.hlsl"
ENDHLSL
}
// ------------------------------------------------------------------
// Depth Only pass.
Pass
{
Name "DepthOnly"
Tags
{
"LightMode" = "DepthOnly"
}
// -------------------------------------
// Render State Commands
ZWrite On
ColorMask R
Cull[_Cull]
HLSLPROGRAM
#pragma target 2.0
// -------------------------------------
// Shader Stages
#pragma vertex DepthOnlyVertex
#pragma fragment DepthOnlyFragment
// -------------------------------------
// Material Keywords
#pragma shader_feature_local _ _ALPHATEST_ON
#pragma shader_feature_local _ _FLIPBOOKBLENDING_ON
#pragma shader_feature_local_fragment _ _COLOROVERLAY_ON _COLORCOLOR_ON _COLORADDSUBDIFF_ON
// -------------------------------------
// Unity defined keywords
#pragma multi_compile_instancing
#pragma instancing_options procedural:ParticleInstancingSetup
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl"
// -------------------------------------
// Includes
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesLitInput.hlsl"
#include "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesDepthOnlyPass.hlsl"
ENDHLSL
}
// ------------------------------------------------------------------
// Shadow Caster pass.
Pass
{
Name "ShadowCaster"
Tags
{
"LightMode" = "ShadowCaster"
}
// -------------------------------------
// Render State Commands
ZWrite On
ZTest LEqual
ColorMask 0
Cull[_Cull]
HLSLPROGRAM
#pragma target 2.0
// -------------------------------------
// Shader Stages
#pragma vertex ShadowCasterParticlesVertex
#pragma fragment ShadowCasterParticlesFragment
// -------------------------------------
// Material Keywords
#pragma shader_feature_local _ _ALPHATEST_ON
#pragma shader_feature_local _ _FLIPBOOKBLENDING_ON
#pragma shader_feature_local_fragment _ _COLOROVERLAY_ON _COLORCOLOR_ON _COLORADDSUBDIFF_ON
// -------------------------------------
// Universal Pipeline keywords
#pragma multi_compile_vertex _ _CASTING_PUNCTUAL_LIGHT_SHADOW
// -------------------------------------
// Unity defined keywords
#pragma multi_compile_instancing
#pragma instancing_options procedural:ParticleInstancingSetup
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl"
// -------------------------------------
// Includes
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesLitInput.hlsl"
#include "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesShadowCasterPass.hlsl"
ENDHLSL
}
// This pass is used when drawing to a _CameraNormalsTexture texture
Pass
{
Name "DepthNormals"
Tags
{
"LightMode" = "DepthNormals"
}
// -------------------------------------
// Render State Commands
ZWrite On
Cull[_Cull]
HLSLPROGRAM
#pragma target 2.0
// -------------------------------------
// Shader Stages
#pragma vertex DepthNormalsVertex
#pragma fragment DepthNormalsFragment
// -------------------------------------
// Material Keywords
#pragma shader_feature_local _ _NORMALMAP
#pragma shader_feature_local _ _FLIPBOOKBLENDING_ON
#pragma shader_feature_local _ _ALPHATEST_ON
#pragma shader_feature_local_fragment _ _COLOROVERLAY_ON _COLORCOLOR_ON _COLORADDSUBDIFF_ON
#pragma shader_feature_local_fragment _METALLICSPECGLOSSMAP
// -------------------------------------
// Unity defined keywords
#pragma multi_compile_instancing
#pragma instancing_options procedural:ParticleInstancingSetup
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl"
// -------------------------------------
// Includes
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesLitInput.hlsl"
#include "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesDepthNormalsPass.hlsl"
// -------------------------------------
// Universal Pipeline keywords
#pragma multi_compile _ _WRITE_SMOOTHNESS
#pragma multi_compile_fragment _ _GBUFFER_NORMALS_OCT
ENDHLSL
}
// ------------------------------------------------------------------
// Scene view outline pass.
Pass
{
Name "SceneSelectionPass"
Tags
{
"LightMode" = "SceneSelectionPass"
}
// -------------------------------------
// Render State Commands
BlendOp Add
Blend One Zero
ZWrite On
Cull Off
HLSLPROGRAM
#define PARTICLES_EDITOR_META_PASS
#pragma target 2.0
// -------------------------------------
// Shader Stages
#pragma vertex vertParticleEditor
#pragma fragment fragParticleSceneHighlight
// -------------------------------------
// Particle Keywords
#pragma shader_feature_local_fragment _ALPHATEST_ON
#pragma shader_feature_local _FLIPBOOKBLENDING_ON
// -------------------------------------
// Unity defined keywords
#pragma multi_compile_instancing
#pragma instancing_options procedural:ParticleInstancingSetup
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl"
// -------------------------------------
// Includes
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesLitInput.hlsl"
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesEditorPass.hlsl"
ENDHLSL
}
// ------------------------------------------------------------------
// Scene picking buffer pass.
Pass
{
Name "ScenePickingPass"
Tags
{
"LightMode" = "Picking"
}
// -------------------------------------
// Render State Commands
BlendOp Add
Blend One Zero
ZWrite On
Cull Off
HLSLPROGRAM
#define PARTICLES_EDITOR_META_PASS
#pragma target 2.0
// -------------------------------------
// Shader Stages
#pragma vertex vertParticleEditor
#pragma fragment fragParticleScenePicking
// -------------------------------------
// Particle Keywords
#pragma shader_feature_local_fragment _ALPHATEST_ON
#pragma shader_feature_local _FLIPBOOKBLENDING_ON
// -------------------------------------
// Unity defined keywords
#pragma multi_compile_instancing
#pragma instancing_options procedural:ParticleInstancingSetup
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl"
// -------------------------------------
// Includes
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesLitInput.hlsl"
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesEditorPass.hlsl"
ENDHLSL
}
Pass
{
Name "Universal2D"
Tags
{
"LightMode" = "Universal2D"
}
// -------------------------------------
// Render State Commands
Blend[_SrcBlend][_DstBlend]
ZWrite[_ZWrite]
Cull[_Cull]
HLSLPROGRAM
// -------------------------------------
// Shader Stages
#pragma vertex vert
#pragma fragment frag
// -------------------------------------
// Material Keywords
#pragma shader_feature_local_fragment _ALPHATEST_ON
#pragma shader_feature_local_fragment _ALPHAPREMULTIPLY_ON
// -------------------------------------
// Includes
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesLitInput.hlsl"
#include "Packages/com.unity.render-pipelines.universal/Shaders/Utils/Universal2D.hlsl"
ENDHLSL
}
}
Fallback "Universal Render Pipeline/Particles/Simple Lit"
CustomEditor "UnityEditor.Rendering.Universal.ShaderGUI.ParticlesLitShader"
}
@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: b7839dad95683814aa64166edc107ae2
timeCreated: 1508242080
licenseType: Pro
ShaderImporter:
externalObjects: {}
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,144 @@
#ifndef UNIVERSAL_PARTICLES_FORWARD_LIT_PASS_INCLUDED
#define UNIVERSAL_PARTICLES_FORWARD_LIT_PASS_INCLUDED
#include "ParticlesLitInput.hlsl"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Particles.hlsl"
void InitializeInputData(VaryingsParticle input, half3 normalTS, out InputData inputData)
{
inputData = (InputData)0;
inputData.positionWS = input.positionWS.xyz;
#ifdef _NORMALMAP
half3 viewDirWS = half3(input.normalWS.w, input.tangentWS.w, input.bitangentWS.w);
inputData.tangentToWorld = half3x3(input.tangentWS.xyz, input.bitangentWS.xyz, input.normalWS.xyz);
inputData.normalWS = TransformTangentToWorld(normalTS, inputData.tangentToWorld);
#else
half3 viewDirWS = input.viewDirWS;
inputData.normalWS = input.normalWS;
#endif
inputData.normalWS = NormalizeNormalPerPixel(inputData.normalWS);
viewDirWS = SafeNormalize(viewDirWS);
inputData.viewDirectionWS = viewDirWS;
#if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
inputData.shadowCoord = input.shadowCoord;
#elif defined(MAIN_LIGHT_CALCULATE_SHADOWS)
inputData.shadowCoord = TransformWorldToShadowCoord(inputData.positionWS);
#else
inputData.shadowCoord = float4(0, 0, 0, 0);
#endif
inputData.fogCoord = InitializeInputDataFog(float4(input.positionWS.xyz, 1.0), input.positionWS.w);
inputData.vertexLighting = half3(0.0h, 0.0h, 0.0h);
#if !defined(LIGHTMAP_ON) && (defined(PROBE_VOLUMES_L1) || defined(PROBE_VOLUMES_L2))
inputData.bakedGI = SAMPLE_GI(input.vertexSH,
GetAbsolutePositionWS(inputData.positionWS),
inputData.normalWS,
inputData.viewDirectionWS,
input.clipPos.xy,
input.probeOcclusion,
inputData.shadowMask);
#else
inputData.bakedGI = SampleSHPixel(input.vertexSH, inputData.normalWS);
#endif
inputData.normalizedScreenSpaceUV = GetNormalizedScreenSpaceUV(input.clipPos);
inputData.shadowMask = half4(1, 1, 1, 1);
#if defined(DEBUG_DISPLAY) && defined(USE_APV_PROBE_OCCLUSION)
inputData.probeOcclusion = input.probeOcclusion;
#endif
#if defined(DEBUG_DISPLAY) && !defined(PARTICLES_EDITOR_META_PASS)
inputData.vertexSH = input.vertexSH;
#endif
}
///////////////////////////////////////////////////////////////////////////////
// Vertex and Fragment functions //
///////////////////////////////////////////////////////////////////////////////
VaryingsParticle ParticlesLitVertex(AttributesParticle input)
{
VaryingsParticle output = (VaryingsParticle)0;
UNITY_SETUP_INSTANCE_ID(input);
UNITY_TRANSFER_INSTANCE_ID(input, output);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
VertexPositionInputs vertexInput = GetParticleVertexPositionInputs(input.positionOS.xyz);
VertexNormalInputs normalInput = GetParticleVertexNormalInputs(input.normalOS, input.tangentOS);
half3 viewDirWS = GetWorldSpaceNormalizeViewDir(vertexInput.positionWS);
half3 vertexLight = VertexLighting(vertexInput.positionWS, half3(normalInput.normalWS));
half fogFactor = 0.0;
#if !defined(_FOG_FRAGMENT)
fogFactor = ComputeFogFactor(vertexInput.positionCS.z);
#endif
#ifdef _NORMALMAP
output.normalWS = half4(normalInput.normalWS, viewDirWS.x);
output.tangentWS = half4(normalInput.tangentWS, viewDirWS.y);
output.bitangentWS = half4(normalInput.bitangentWS, viewDirWS.z);
#else
output.normalWS = half3(normalInput.normalWS);
output.viewDirWS = viewDirWS;
#endif
OUTPUT_SH4(vertexInput.positionWS, output.normalWS.xyz, GetWorldSpaceNormalizeViewDir(vertexInput.positionWS), output.vertexSH, output.probeOcclusion);
output.positionWS.xyz = vertexInput.positionWS;
output.positionWS.w = fogFactor;
output.clipPos = vertexInput.positionCS;
output.color = GetParticleColor(input.color);
#if defined(_FLIPBOOKBLENDING_ON)
#if defined(UNITY_PARTICLE_INSTANCING_ENABLED)
GetParticleTexcoords(output.texcoord, output.texcoord2AndBlend, input.texcoords.xyxy, 0.0);
#else
GetParticleTexcoords(output.texcoord, output.texcoord2AndBlend, input.texcoords, input.texcoordBlend);
#endif
#else
GetParticleTexcoords(output.texcoord, input.texcoords.xy);
#endif
#if defined(_SOFTPARTICLES_ON) || defined(_FADING_ON) || defined(_DISTORTION_ON)
output.projectedPosition = vertexInput.positionNDC;
#endif
#if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
output.shadowCoord = GetShadowCoord(vertexInput);
#endif
return output;
}
half4 ParticlesLitFragment(VaryingsParticle input) : SV_Target
{
UNITY_SETUP_INSTANCE_ID(input);
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);
ParticleParams particleParams;
InitParticleParams(input, particleParams);
SurfaceData surfaceData;
InitializeParticleLitSurfaceData(particleParams, surfaceData);
InputData inputData;
InitializeInputData(input, surfaceData.normalTS, inputData);
SETUP_DEBUG_TEXTURE_DATA_FOR_TEX(inputData, input.texcoord, _BaseMap);
half4 color = UniversalFragmentPBR(inputData, surfaceData);
color.rgb = MixFog(color.rgb, inputData.fogCoord);
color.a = OutputAlpha(color.a, IsSurfaceTypeTransparent());
return color;
}
#endif // UNIVERSAL_PARTICLES_FORWARD_LIT_PASS_INCLUDED
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: a8d5c97876fe84413b2f630e2debf75b
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,149 @@
#ifndef UNIVERSAL_PARTICLES_GBUFFER_LIT_PASS_INCLUDED
#define UNIVERSAL_PARTICLES_GBUFFER_LIT_PASS_INCLUDED
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/GBufferOutput.hlsl"
void InitializeInputData(VaryingsParticle input, half3 normalTS, out InputData inputData)
{
inputData = (InputData)0;
inputData.positionWS = input.positionWS.xyz;
inputData.positionCS = input.clipPos;
#ifdef _NORMALMAP
half3 viewDirWS = half3(input.normalWS.w, input.tangentWS.w, input.bitangentWS.w);
inputData.normalWS = TransformTangentToWorld(normalTS,
half3x3(input.tangentWS.xyz, input.bitangentWS.xyz, input.normalWS.xyz));
#else
half3 viewDirWS = input.viewDirWS;
inputData.normalWS = input.normalWS;
#endif
inputData.normalWS = NormalizeNormalPerPixel(inputData.normalWS);
viewDirWS = SafeNormalize(viewDirWS);
inputData.viewDirectionWS = viewDirWS;
#if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
inputData.shadowCoord = input.shadowCoord;
#elif defined(MAIN_LIGHT_CALCULATE_SHADOWS)
inputData.shadowCoord = TransformWorldToShadowCoord(inputData.positionWS);
#else
inputData.shadowCoord = float4(0, 0, 0, 0);
#endif
inputData.fogCoord = 0.0; // not used for deferred shading
inputData.vertexLighting = half3(0.0h, 0.0h, 0.0h);
#if !defined(LIGHTMAP_ON) && (defined(PROBE_VOLUMES_L1) || defined(PROBE_VOLUMES_L2))
inputData.bakedGI = SAMPLE_GI(input.vertexSH,
GetAbsolutePositionWS(inputData.positionWS),
inputData.normalWS,
inputData.viewDirectionWS,
inputData.positionCS.xy,
input.probeOcclusion,
inputData.shadowMask);
#else
inputData.bakedGI = SampleSHPixel(input.vertexSH, inputData.normalWS);
#endif
inputData.normalizedScreenSpaceUV = GetNormalizedScreenSpaceUV(input.clipPos);
inputData.shadowMask = half4(1, 1, 1, 1);
#if defined(DEBUG_DISPLAY) && defined(USE_APV_PROBE_OCCLUSION)
inputData.probeOcclusion = input.probeOcclusion;
#endif
#if defined(DEBUG_DISPLAY) && !defined(PARTICLES_EDITOR_META_PASS)
inputData.vertexSH = input.vertexSH;
#endif
}
///////////////////////////////////////////////////////////////////////////////
// Vertex and Fragment functions //
///////////////////////////////////////////////////////////////////////////////
VaryingsParticle ParticlesGBufferVertex(AttributesParticle input)
{
VaryingsParticle output = (VaryingsParticle)0;
UNITY_SETUP_INSTANCE_ID(input);
UNITY_TRANSFER_INSTANCE_ID(input, output);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
VertexPositionInputs vertexInput = GetParticleVertexPositionInputs(input.positionOS.xyz);
VertexNormalInputs normalInput = GetParticleVertexNormalInputs(input.normalOS, input.tangentOS);
half3 viewDirWS = GetWorldSpaceNormalizeViewDir(vertexInput.positionWS);
half3 vertexLight = VertexLighting(vertexInput.positionWS, half3(normalInput.normalWS));
#ifdef _NORMALMAP
output.normalWS = half4(normalInput.normalWS, viewDirWS.x);
output.tangentWS = half4(normalInput.tangentWS, viewDirWS.y);
output.bitangentWS = half4(normalInput.bitangentWS, viewDirWS.z);
#else
output.normalWS = half3(normalInput.normalWS);
output.viewDirWS = viewDirWS;
#endif
OUTPUT_SH4(vertexInput.positionWS, output.normalWS.xyz, GetWorldSpaceNormalizeViewDir(vertexInput.positionWS), output.vertexSH, output.probeOcclusion);
output.positionWS.xyz = vertexInput.positionWS;
output.clipPos = vertexInput.positionCS;
output.color = GetParticleColor(input.color);
#if defined(_FLIPBOOKBLENDING_ON)
#if defined(UNITY_PARTICLE_INSTANCING_ENABLED)
GetParticleTexcoords(output.texcoord, output.texcoord2AndBlend, input.texcoords.xyxy, 0.0);
#else
GetParticleTexcoords(output.texcoord, output.texcoord2AndBlend, input.texcoords, input.texcoordBlend);
#endif
#else
GetParticleTexcoords(output.texcoord, input.texcoords.xy);
#endif
#if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
output.shadowCoord = GetShadowCoord(vertexInput);
#endif
return output;
}
GBufferFragOutput ParticlesGBufferFragment(VaryingsParticle input)
{
UNITY_SETUP_INSTANCE_ID(input);
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);
float3 blendUv = float3(0, 0, 0);
#if defined(_FLIPBOOKBLENDING_ON)
blendUv = input.texcoord2AndBlend;
#endif
float4 projectedPosition = float4(0,0,0,0);
#if defined(_SOFTPARTICLES_ON) || defined(_FADING_ON) || defined(_DISTORTION_ON)
projectedPosition = input.projectedPosition;
#endif
SurfaceData surfaceData;
InitializeParticleLitSurfaceData(input.texcoord, blendUv, input.color, projectedPosition, surfaceData);
InputData inputData;
InitializeInputData(input, surfaceData.normalTS, inputData);
SETUP_DEBUG_TEXTURE_DATA_FOR_TEX(inputData, input.texcoord, _BaseMap);
// Stripped down version of UniversalFragmentPBR().
// in LitForwardPass GlobalIllumination (and temporarily LightingPhysicallyBased) are called inside UniversalFragmentPBR
// in Deferred rendering we store the sum of these values (and of emission as well) in the GBuffer
BRDFData brdfData;
InitializeBRDFData(surfaceData.albedo, surfaceData.metallic, surfaceData.specular, surfaceData.smoothness, surfaceData.alpha, brdfData);
Light mainLight = GetMainLight(inputData.shadowCoord, inputData.positionWS, inputData.shadowMask);
MixRealtimeAndBakedGI(mainLight, inputData.normalWS, inputData.bakedGI, inputData.shadowMask);
half3 color = GlobalIllumination(brdfData, (BRDFData)0, 0, inputData.bakedGI, surfaceData.occlusion, inputData.positionWS,
inputData.normalWS, inputData.viewDirectionWS, inputData.normalizedScreenSpaceUV);
return PackGBuffersBRDFData(brdfData, inputData, surfaceData.smoothness, surfaceData.emission + color, surfaceData.occlusion);
}
#endif // UNIVERSAL_PARTICLES_GBUFFER_LIT_PASS_INCLUDED
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: cc421706a0b598946982fee0c0d4bf51
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,159 @@
#ifndef UNIVERSAL_PARTICLES_LIT_INPUT_INCLUDED
#define UNIVERSAL_PARTICLES_LIT_INPUT_INCLUDED
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
#include "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesInput.hlsl"
#include "Packages/com.unity.render-pipelines.universal/Shaders/Utils/SurfaceType.hlsl"
// NOTE: Do not ifdef the properties here as SRP batcher can not handle different layouts.
CBUFFER_START(UnityPerMaterial)
float4 _SoftParticleFadeParams;
float4 _CameraFadeParams;
float4 _BaseMap_ST;
float4 _BaseMap_TexelSize;
half4 _BaseColor;
half4 _EmissionColor;
half4 _BaseColorAddSubDiff;
half _Cutoff;
half _Metallic;
half _Smoothness;
half _BumpScale;
half _DistortionStrengthScaled;
half _DistortionBlend;
CBUFFER_END
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Particles.hlsl"
TEXTURE2D(_MetallicGlossMap); SAMPLER(sampler_MetallicGlossMap);
#define SOFT_PARTICLE_NEAR_FADE _SoftParticleFadeParams.x
#define SOFT_PARTICLE_INV_FADE_DISTANCE _SoftParticleFadeParams.y
#define CAMERA_NEAR_FADE _CameraFadeParams.x
#define CAMERA_INV_FADE_DISTANCE _CameraFadeParams.y
half4 SampleAlbedo(float2 uv, float3 blendUv, half4 color, float4 particleColor, float4 projectedPosition, UnityTexture2D albedoMap)
{
half4 albedo = BlendTexture(albedoMap, uv, blendUv) * color;
half4 colorAddSubDiff = half4(0, 0, 0, 0);
#if defined (_COLORADDSUBDIFF_ON)
colorAddSubDiff = _BaseColorAddSubDiff;
#endif
// No distortion Support
albedo = MixParticleColor(albedo, half4(particleColor), colorAddSubDiff);
albedo.a = AlphaDiscard(albedo.a, _Cutoff);
#if defined(_SOFTPARTICLES_ON)
ALBEDO_MUL *= SoftParticles(SOFT_PARTICLE_NEAR_FADE, SOFT_PARTICLE_INV_FADE_DISTANCE, projectedPosition);
#endif
#if defined(_FADING_ON)
ALBEDO_MUL *= CameraFade(CAMERA_NEAR_FADE, CAMERA_INV_FADE_DISTANCE, projectedPosition);
#endif
return albedo;
}
half4 SampleAlbedo(UnityTexture2D albedoMap, ParticleParams params)
{
half4 albedo = BlendTexture(albedoMap, params.uv, params.blendUv) * params.baseColor;
half4 colorAddSubDiff = half4(0, 0, 0, 0);
#if defined (_COLORADDSUBDIFF_ON)
colorAddSubDiff = _BaseColorAddSubDiff;
#endif
// No distortion Support
albedo = MixParticleColor(albedo, half4(params.vertexColor), colorAddSubDiff);
albedo.a = AlphaDiscard(albedo.a, _Cutoff);
#if defined(_SOFTPARTICLES_ON)
ALBEDO_MUL *= SoftParticles(SOFT_PARTICLE_NEAR_FADE, SOFT_PARTICLE_INV_FADE_DISTANCE, params);
#endif
#if defined(_FADING_ON)
ALBEDO_MUL *= CameraFade(CAMERA_NEAR_FADE, CAMERA_INV_FADE_DISTANCE, params.projectedPosition);
#endif
return albedo;
}
inline void InitializeParticleLitSurfaceData(float2 uv, float3 blendUv, float4 particleColor, float4 projectedPosition, out SurfaceData outSurfaceData)
{
half4 albedo = SampleAlbedo(uv, blendUv, _BaseColor, particleColor, projectedPosition, UnityBuildTexture2DStructNoScaleNoTexelSize(_BaseMap));
#if defined(_METALLICSPECGLOSSMAP)
half2 metallicGloss = BlendTexture(UnityBuildTexture2DStructNoScaleNoTexelSize(_MetallicGlossMap), uv, blendUv).ra * half2(1.0, _Smoothness);
#else
half2 metallicGloss = half2(_Metallic, _Smoothness);
#endif
half3 normalTS = SampleNormalTS(uv, blendUv, UnityBuildTexture2DStructNoScaleNoTexelSize(_BumpMap), _BumpScale);
#if defined(_EMISSION)
half3 emission = BlendTexture(UnityBuildTexture2DStructNoScaleNoTexelSize(_EmissionMap), uv, blendUv).rgb * _EmissionColor.rgb;
#else
half3 emission = half3(0, 0, 0);
#endif
#if defined(_DISTORTION_ON)
albedo.rgb = Distortion(albedo, normalTS, _DistortionStrengthScaled, _DistortionBlend, projectedPosition);
#endif
outSurfaceData = (SurfaceData)0;
outSurfaceData.albedo = albedo.rgb;
outSurfaceData.specular = half3(0.0h, 0.0h, 0.0h);
outSurfaceData.normalTS = normalTS;
outSurfaceData.emission = emission;
outSurfaceData.metallic = metallicGloss.r;
outSurfaceData.smoothness = metallicGloss.g;
outSurfaceData.occlusion = 1.0;
outSurfaceData.albedo = AlphaModulate(outSurfaceData.albedo, albedo.a); // Premultiply in UniversalPBR, BRDF init.
outSurfaceData.alpha = albedo.a;
outSurfaceData.clearCoatMask = half(0.0);
outSurfaceData.clearCoatSmoothness = half(1.0);
}
inline void InitializeParticleLitSurfaceData(ParticleParams params, out SurfaceData outSurfaceData)
{
half4 albedo = SampleAlbedo(UnityBuildTexture2DStructNoScaleNoTexelSize(_BaseMap), params);
#if defined(_METALLICSPECGLOSSMAP)
half2 metallicGloss = BlendTexture(UnityBuildTexture2DStructNoScaleNoTexelSize(_MetallicGlossMap), params.uv, params.blendUv).ra * half2(1.0, _Smoothness);
#else
half2 metallicGloss = half2(_Metallic, _Smoothness);
#endif
half3 normalTS = SampleNormalTS(params.uv, params.blendUv, UnityBuildTexture2DStructNoScaleNoTexelSize(_BumpMap), _BumpScale);
#if defined(_EMISSION)
half3 emission = BlendTexture(UnityBuildTexture2DStructNoScaleNoTexelSize(_EmissionMap), params.uv, params.blendUv).rgb * _EmissionColor.rgb;
#else
half3 emission = half3(0, 0, 0);
#endif
#if defined(_DISTORTION_ON)
albedo.rgb = Distortion(albedo, normalTS, _DistortionStrengthScaled, _DistortionBlend, params.projectedPosition);
#endif
outSurfaceData = (SurfaceData)0;
outSurfaceData.albedo = albedo.rgb;
outSurfaceData.specular = half3(0.0h, 0.0h, 0.0h);
outSurfaceData.normalTS = normalTS;
outSurfaceData.emission = emission;
outSurfaceData.metallic = metallicGloss.r;
outSurfaceData.smoothness = metallicGloss.g;
outSurfaceData.occlusion = 1.0;
outSurfaceData.albedo = AlphaModulate(outSurfaceData.albedo, albedo.a);
outSurfaceData.alpha = albedo.a;
outSurfaceData.clearCoatMask = half(0.0);
outSurfaceData.clearCoatSmoothness = half(1.0);
}
#endif // UNIVERSAL_PARTICLES_LIT_INPUT_INCLUDED
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: a3129e299d0744bb7bd42c2cea7cea2b
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,74 @@
#ifndef UNIVERSAL_PARTICLES_SHADOW_CASTER_PASS_INCLUDED
#define UNIVERSAL_PARTICLES_SHADOW_CASTER_PASS_INCLUDED
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Shadows.hlsl"
float3 _LightDirection;
float3 _LightPosition;
VaryingsShadowCasterParticle ShadowCasterParticlesVertex(AttributesShadowCasterParticle input)
{
VaryingsShadowCasterParticle output = (VaryingsShadowCasterParticle)0;
UNITY_SETUP_INSTANCE_ID(input);
UNITY_TRANSFER_INSTANCE_ID(input, output);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
float3 positionWS = GetParticleVertexPositionInputs(input.positionOS.xyz).positionWS;
float3 normalWS = GetParticleVertexNormalInputs(input.normalOS).normalWS;
#if _CASTING_PUNCTUAL_LIGHT_SHADOW
float3 lightDirectionWS = normalize(_LightPosition - positionWS);
#else
float3 lightDirectionWS = _LightDirection;
#endif
float4 positionCS = TransformWorldToHClip(ApplyShadowBias(positionWS, normalWS, lightDirectionWS));
output.positionCS = ApplyShadowClamping(positionCS);
#if defined(_ALPHATEST_ON)
output.color = GetParticleColor(input.color);
#if defined(_FLIPBOOKBLENDING_ON)
#if defined(UNITY_PARTICLE_INSTANCING_ENABLED)
GetParticleTexcoords(output.texcoord, output.texcoord2AndBlend, input.texcoords.xyxy, 0.0);
#else
GetParticleTexcoords(output.texcoord, output.texcoord2AndBlend, input.texcoords, input.texcoordBlend);
#endif
#else
GetParticleTexcoords(output.texcoord, input.texcoords.xy);
#endif
#endif
return output;
}
half4 ShadowCasterParticlesFragment(VaryingsShadowCasterParticle input) : SV_TARGET
{
UNITY_SETUP_INSTANCE_ID(input);
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);
#if defined(_ALPHATEST_ON)
float2 uv = input.texcoord;
half4 vertexColor = input.color;
half4 baseColor = _BaseColor;
#if defined(_FLIPBOOKBLENDING_ON)
float3 blendUv = input.texcoord2AndBlend;
#else
float3 blendUv = float3(0, 0, 0);
#endif
half4 albedo = BlendTexture(UnityBuildTexture2DStructNoScaleNoTexelSize(_BaseMap), uv, blendUv) * baseColor;
half4 colorAddSubDiff = half4(0, 0, 0, 0);
#if defined(_COLORADDSUBDIFF_ON)
colorAddSubDiff = _BaseColorAddSubDiff;
#endif
albedo = MixParticleColor(albedo, vertexColor, colorAddSubDiff);
AlphaDiscard(albedo.a, _Cutoff);
#endif
return 0;
}
#endif // UNIVERSAL_PARTICLES_SHADOW_CASTER_PASS_INCLUDED
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: c6d99c9b40c630447bdf027439419d93
ShaderIncludeImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,512 @@
// ------------------------------------------
// Only directional light is supported for lit particles
// No shadow
// No distortion
Shader "Universal Render Pipeline/Particles/Simple Lit"
{
Properties
{
[MainTexture] _BaseMap("Base Map", 2D) = "white" {}
[MainColor] _BaseColor("Base Color", Color) = (1,1,1,1)
_Cutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5
_SpecGlossMap("Specular", 2D) = "white" {}
_SpecColor("Specular", Color) = (1.0, 1.0, 1.0)
_Smoothness("Smoothness", Range(0.0, 1.0)) = 0.5
_BumpScale("Scale", Float) = 1.0
_BumpMap("Normal Map", 2D) = "bump" {}
[HDR] _EmissionColor("Color", Color) = (0,0,0)
_EmissionMap("Emission", 2D) = "white" {}
_SmoothnessSource("Smoothness Source", Float) = 0.0
_SpecularHighlights("Specular Highlights", Float) = 1.0
[ToggleUI] _ReceiveShadows("Receive Shadows", Float) = 1.0
// -------------------------------------
// Particle specific
_SoftParticlesNearFadeDistance("Soft Particles Near Fade", Float) = 0.0
_SoftParticlesFarFadeDistance("Soft Particles Far Fade", Float) = 1.0
_CameraNearFadeDistance("Camera Near Fade", Float) = 1.0
_CameraFarFadeDistance("Camera Far Fade", Float) = 2.0
_DistortionBlend("Distortion Blend", Range(0.0, 1.0)) = 0.5
_DistortionStrength("Distortion Strength", Float) = 1.0
// -------------------------------------
// Hidden properties - Generic
_Surface("__surface", Float) = 0.0
_Blend("__mode", Float) = 0.0
_Cull("__cull", Float) = 2.0
[ToggleUI] _AlphaClip("__clip", Float) = 0.0
[HideInInspector] _BlendOp("__blendop", Float) = 0.0
[HideInInspector] _SrcBlend("__src", Float) = 1.0
[HideInInspector] _DstBlend("__dst", Float) = 0.0
[HideInInspector] _SrcBlendAlpha("__srcA", Float) = 1.0
[HideInInspector] _DstBlendAlpha("__dstA", Float) = 0.0
[HideInInspector] _ZWrite("__zw", Float) = 1.0
[HideInInspector] _AlphaToMask("__alphaToMask", Float) = 0.0
// Particle specific
_ColorMode("_ColorMode", Float) = 0.0
[HideInInspector] _BaseColorAddSubDiff("_ColorMode", Vector) = (0,0,0,0)
[ToggleOff] _FlipbookBlending("__flipbookblending", Float) = 0.0
[ToggleUI] _SoftParticlesEnabled("__softparticlesenabled", Float) = 0.0
[ToggleUI] _CameraFadingEnabled("__camerafadingenabled", Float) = 0.0
[ToggleUI] _DistortionEnabled("__distortionenabled", Float) = 0.0
[HideInInspector] _SoftParticleFadeParams("__softparticlefadeparams", Vector) = (0,0,0,0)
[HideInInspector] _CameraFadeParams("__camerafadeparams", Vector) = (0,0,0,0)
[HideInInspector] _DistortionStrengthScaled("Distortion Strength Scaled", Float) = 0.1
// Editmode props
_QueueOffset("Queue offset", Float) = 0.0
// ObsoleteProperties
[HideInInspector] _FlipbookMode("flipbook", Float) = 0
[HideInInspector] _Glossiness("gloss", Float) = 0
[HideInInspector] _Mode("mode", Float) = 0
[HideInInspector] _Color("color", Color) = (1,1,1,1)
}
HLSLINCLUDE
ENDHLSL
SubShader
{
Tags
{
"RenderType" = "Opaque"
"IgnoreProjector" = "True"
"PreviewType" = "Plane"
"PerformanceChecks" = "False"
"RenderPipeline" = "UniversalPipeline"
"UniversalMaterialType" = "SimpleLit"
}
// ------------------------------------------------------------------
// Forward pass.
Pass
{
// Lightmode matches the ShaderPassName set in UniversalRenderPipeline.cs. SRPDefaultUnlit and passes with
// no LightMode tag are also rendered by Universal Render Pipeline
Name "ForwardLit"
Tags
{
"LightMode" = "UniversalForward"
}
// -------------------------------------
// Render State Commands
BlendOp[_BlendOp]
Blend[_SrcBlend][_DstBlend], [_SrcBlendAlpha][_DstBlendAlpha]
ZWrite[_ZWrite]
Cull[_Cull]
AlphaToMask[_AlphaToMask]
HLSLPROGRAM
#pragma target 2.0
// -------------------------------------
// Shader Stages
#pragma vertex ParticlesLitVertex
#pragma fragment ParticlesLitFragment
// -------------------------------------
// Material Keywords
#pragma shader_feature_local _NORMALMAP
#pragma shader_feature_local _RECEIVE_SHADOWS_OFF
#pragma shader_feature_local_fragment _SURFACE_TYPE_TRANSPARENT
#pragma shader_feature_local_fragment _EMISSION
#pragma shader_feature_local_fragment _ _SPECGLOSSMAP _SPECULAR_COLOR
#pragma shader_feature_local_fragment _GLOSSINESS_FROM_BASE_ALPHA
// -------------------------------------
// Particle Keywords
#pragma shader_feature_local _FLIPBOOKBLENDING_ON
#pragma shader_feature_local _SOFTPARTICLES_ON
#pragma shader_feature_local _FADING_ON
#pragma shader_feature_local _DISTORTION_ON
#pragma shader_feature_local_fragment _ALPHATEST_ON
#pragma shader_feature_local_fragment _ _ALPHAPREMULTIPLY_ON _ALPHAMODULATE_ON
#pragma shader_feature_local_fragment _ _COLOROVERLAY_ON _COLORCOLOR_ON _COLORADDSUBDIFF_ON
// -------------------------------------
// Universal Pipeline keywords
#pragma multi_compile _ _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE _MAIN_LIGHT_SHADOWS_SCREEN
#pragma multi_compile _ _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS
#pragma multi_compile_fragment _ _ADDITIONAL_LIGHT_SHADOWS
#pragma multi_compile_fragment _ _SHADOWS_SOFT _SHADOWS_SOFT_LOW _SHADOWS_SOFT_MEDIUM _SHADOWS_SOFT_HIGH
#pragma multi_compile_fragment _ _SCREEN_SPACE_OCCLUSION
#pragma multi_compile_fragment _ _LIGHT_COOKIES
#pragma multi_compile _ _LIGHT_LAYERS
#pragma multi_compile _ _CLUSTER_LIGHT_LOOP
#pragma multi_compile _ EVALUATE_SH_MIXED EVALUATE_SH_VERTEX
#if defined(UNITY_PLATFORM_META_QUEST)
#pragma multi_compile _ META_QUEST_ORTHO_PROJ
#pragma multi_compile _ META_QUEST_NO_SPOTLIGHTS_LIGHT_LOOP
#endif
#include_with_pragmas "Packages/com.unity.render-pipelines.core/ShaderLibrary/FoveatedRenderingKeywords.hlsl"
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Fog.hlsl"
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ProbeVolumeVariants.hlsl"
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/RenderingLayers.hlsl"
// -------------------------------------
// Unity defined keywords
#pragma multi_compile _ LIGHTMAP_SHADOW_MIXING
#pragma multi_compile_instancing
#pragma multi_compile_fragment _ DEBUG_DISPLAY
#pragma instancing_options procedural:ParticleInstancingSetup
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl"
// -------------------------------------
// Defines
#define BUMP_SCALE_NOT_SUPPORTED 1
// -------------------------------------
// Includes
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesSimpleLitInput.hlsl"
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesSimpleLitForwardPass.hlsl"
ENDHLSL
}
// ------------------------------------------------------------------
// GBuffer pass.
Pass
{
// Lightmode matches the ShaderPassName set in UniversalRenderPipeline.cs. SRPDefaultUnlit and passes with
// no LightMode tag are also rendered by Universal Render Pipeline
Name "GBuffer"
Tags
{
"LightMode" = "UniversalGBuffer"
}
// -------------------------------------
// Render State Commands
ZWrite[_ZWrite]
Cull[_Cull]
HLSLPROGRAM
#pragma target 4.5
// Deferred Rendering Path does not support the OpenGL-based graphics API:
// Desktop OpenGL, OpenGL ES 3.0, WebGL 2.0.
#pragma exclude_renderers gles3 glcore
// -------------------------------------
// Shader Stages
#pragma vertex ParticlesLitGBufferVertex
#pragma fragment ParticlesLitGBufferFragment
// -------------------------------------
// Material Keywords
#pragma shader_feature_local _NORMALMAP
#pragma shader_feature_local_fragment _EMISSION
#pragma shader_feature_local_fragment _ _SPECGLOSSMAP _SPECULAR_COLOR
#pragma shader_feature_local_fragment _GLOSSINESS_FROM_BASE_ALPHA
#pragma shader_feature_local _RECEIVE_SHADOWS_OFF
// -------------------------------------
// Particle Keywords
//#pragma shader_feature _ _ALPHAPREMULTIPLY_ON _ALPHAMODULATE_ON
#pragma shader_feature_local_fragment _ALPHATEST_ON
#pragma shader_feature_local_fragment _ _COLOROVERLAY_ON _COLORCOLOR_ON _COLORADDSUBDIFF_ON
#pragma shader_feature_local _FLIPBOOKBLENDING_ON
//#pragma shader_feature _SOFTPARTICLES_ON
//#pragma shader_feature _FADING_ON
//#pragma shader_feature _DISTORTION_ON
// -------------------------------------
// Universal Pipeline keywords
#pragma multi_compile _ _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE _MAIN_LIGHT_SHADOWS_SCREEN
//#pragma multi_compile _ _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS
//#pragma multi_compile_fragment _ _ADDITIONAL_LIGHT_SHADOWS
#pragma multi_compile_fragment _ _SHADOWS_SOFT _SHADOWS_SOFT_LOW _SHADOWS_SOFT_MEDIUM _SHADOWS_SOFT_HIGH
#pragma multi_compile_fragment _ _GBUFFER_NORMALS_OCT
#pragma multi_compile_fragment _ _RENDER_PASS_ENABLED
#pragma multi_compile _ EVALUATE_SH_MIXED EVALUATE_SH_VERTEX
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ProbeVolumeVariants.hlsl"
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/RenderingLayers.hlsl"
// -------------------------------------
// Unity defined keywords
#pragma multi_compile _ LIGHTMAP_SHADOW_MIXING
#pragma multi_compile_instancing
#pragma instancing_options procedural:ParticleInstancingSetup
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl"
//--------------------------------------
// Defines
#define BUMP_SCALE_NOT_SUPPORTED 1
// -------------------------------------
// Includes
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesSimpleLitInput.hlsl"
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesSimpleLitGBufferPass.hlsl"
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/GBufferOutputFormat.hlsl"
ENDHLSL
}
// ------------------------------------------------------------------
// Depth Only pass.
Pass
{
Name "DepthOnly"
Tags
{
"LightMode" = "DepthOnly"
}
// -------------------------------------
// Render State Commands
ZWrite On
ColorMask R
Cull[_Cull]
HLSLPROGRAM
#pragma target 2.0
// -------------------------------------
// Shader Stages
#pragma vertex DepthOnlyVertex
#pragma fragment DepthOnlyFragment
// -------------------------------------
// Material Keywords
#pragma shader_feature_local _ _ALPHATEST_ON
#pragma shader_feature_local _ _FLIPBOOKBLENDING_ON
#pragma shader_feature_local_fragment _ _COLOROVERLAY_ON _COLORCOLOR_ON _COLORADDSUBDIFF_ON
// -------------------------------------
// Unity defined keywords
#pragma multi_compile_instancing
#pragma instancing_options procedural:ParticleInstancingSetup
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl"
// -------------------------------------
// Includes
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesSimpleLitInput.hlsl"
#include "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesDepthOnlyPass.hlsl"
ENDHLSL
}
// ------------------------------------------------------------------
// Shadow Caster pass.
Pass
{
Name "ShadowCaster"
Tags
{
"LightMode" = "ShadowCaster"
}
// -------------------------------------
// Render State Commands
ZWrite On
ZTest LEqual
ColorMask 0
Cull[_Cull]
HLSLPROGRAM
#pragma target 2.0
// -------------------------------------
// Shader Stages
#pragma vertex ShadowCasterParticlesVertex
#pragma fragment ShadowCasterParticlesFragment
// -------------------------------------
// Material Keywords
#pragma shader_feature_local _ _ALPHATEST_ON
#pragma shader_feature_local _ _FLIPBOOKBLENDING_ON
#pragma shader_feature_local_fragment _ _COLOROVERLAY_ON _COLORCOLOR_ON _COLORADDSUBDIFF_ON
// -------------------------------------
// Universal Pipeline keywords
#pragma multi_compile_vertex _ _CASTING_PUNCTUAL_LIGHT_SHADOW
// -------------------------------------
// Unity defined keywords
#pragma multi_compile_instancing
#pragma instancing_options procedural:ParticleInstancingSetup
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl"
// -------------------------------------
// Includes
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesSimpleLitInput.hlsl"
#include "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesShadowCasterPass.hlsl"
ENDHLSL
}
// This pass is used when drawing to a _CameraNormalsTexture texture
Pass
{
Name "DepthNormals"
Tags
{
"LightMode" = "DepthNormals"
}
// -------------------------------------
// Render State Commands
ZWrite On
Cull[_Cull]
HLSLPROGRAM
#pragma target 2.0
// -------------------------------------
// Shader Stages
#pragma vertex DepthNormalsVertex
#pragma fragment DepthNormalsFragment
// -------------------------------------
// Material Keywords
#pragma shader_feature_local _ _NORMALMAP
#pragma shader_feature_local _ _FLIPBOOKBLENDING_ON
#pragma shader_feature_local _ _ALPHATEST_ON
#pragma shader_feature_local_fragment _ _COLOROVERLAY_ON _COLORCOLOR_ON _COLORADDSUBDIFF_ON
// -------------------------------------
// Unity defined keywords
#pragma multi_compile_instancing
#pragma instancing_options procedural:ParticleInstancingSetup
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl"
// -------------------------------------
// Includes
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesSimpleLitInput.hlsl"
#include "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesDepthNormalsPass.hlsl"
// Universal Pipeline keywords
#pragma multi_compile_fragment _ _GBUFFER_NORMALS_OCT
ENDHLSL
}
// ------------------------------------------------------------------
// Scene view outline pass.
Pass
{
Name "SceneSelectionPass"
Tags
{
"LightMode" = "SceneSelectionPass"
}
// -------------------------------------
// Render State Commands
BlendOp Add
Blend One Zero
ZWrite On
Cull Off
HLSLPROGRAM
#define PARTICLES_EDITOR_META_PASS
#pragma target 2.0
// -------------------------------------
// Shader Stages
#pragma vertex vertParticleEditor
#pragma fragment fragParticleSceneHighlight
// -------------------------------------
// Particle Keywords
#pragma shader_feature_local_fragment _ALPHATEST_ON
#pragma shader_feature_local _FLIPBOOKBLENDING_ON
// -------------------------------------
// Unity defined keywords
#pragma multi_compile_instancing
#pragma instancing_options procedural:ParticleInstancingSetup
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl"
// -------------------------------------
// Includes
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesSimpleLitInput.hlsl"
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesEditorPass.hlsl"
ENDHLSL
}
// ------------------------------------------------------------------
// Scene picking buffer pass.
Pass
{
Name "ScenePickingPass"
Tags
{
"LightMode" = "Picking"
}
// -------------------------------------
// Render State Commands
BlendOp Add
Blend One Zero
ZWrite On
Cull Off
HLSLPROGRAM
#define PARTICLES_EDITOR_META_PASS
#pragma target 2.0
// -------------------------------------
// Shader Stages
#pragma vertex vertParticleEditor
#pragma fragment fragParticleScenePicking
// -------------------------------------
// Particle Keywords
#pragma shader_feature_local_fragment _ALPHATEST_ON
#pragma shader_feature_local _FLIPBOOKBLENDING_ON
// -------------------------------------
// Unity defined keywords
#pragma multi_compile_instancing
#pragma instancing_options procedural:ParticleInstancingSetup
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl"
// -------------------------------------
// Includes
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesSimpleLitInput.hlsl"
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesEditorPass.hlsl"
ENDHLSL
}
Pass
{
Name "Universal2D"
Tags
{
"LightMode" = "Universal2D"
}
// -------------------------------------
// Render State Commands
Blend[_SrcBlend][_DstBlend]
ZWrite[_ZWrite]
Cull[_Cull]
HLSLPROGRAM
#pragma target 2.0
// -------------------------------------
// Shader Stages
#pragma vertex vert
#pragma fragment frag
// -------------------------------------
// Material Keywords
#pragma shader_feature_local_fragment _ALPHATEST_ON
#pragma shader_feature_local_fragment _ALPHAPREMULTIPLY_ON
// -------------------------------------
// Includes
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesSimpleLitInput.hlsl"
#include "Packages/com.unity.render-pipelines.universal/Shaders/Utils/Universal2D.hlsl"
ENDHLSL
}
}
Fallback "Universal Render Pipeline/Particles/Unlit"
CustomEditor "UnityEditor.Rendering.Universal.ShaderGUI.ParticlesSimpleLitShader"
}
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 8516d7a69675844a7a0b7095af7c46af
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,154 @@
#ifndef UNIVERSAL_PARTICLES_FORWARD_SIMPLE_LIT_PASS_INCLUDED
#define UNIVERSAL_PARTICLES_FORWARD_SIMPLE_LIT_PASS_INCLUDED
#include "ParticlesSimpleLitInput.hlsl"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Particles.hlsl"
void InitializeInputData(VaryingsParticle input, half3 normalTS, out InputData inputData)
{
inputData = (InputData)0;
inputData.positionWS = input.positionWS.xyz;
#ifdef _NORMALMAP
half3 viewDirWS = half3(input.normalWS.w, input.tangentWS.w, input.bitangentWS.w);
inputData.tangentToWorld = half3x3(input.tangentWS.xyz, input.bitangentWS.xyz, input.normalWS.xyz);
inputData.normalWS = TransformTangentToWorld(normalTS, inputData.tangentToWorld);
#else
half3 viewDirWS = input.viewDirWS;
inputData.normalWS = input.normalWS;
#endif
inputData.normalWS = NormalizeNormalPerPixel(inputData.normalWS);
viewDirWS = SafeNormalize(viewDirWS);
inputData.viewDirectionWS = viewDirWS;
#if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
inputData.shadowCoord = input.shadowCoord;
#elif defined(MAIN_LIGHT_CALCULATE_SHADOWS)
inputData.shadowCoord = TransformWorldToShadowCoord(inputData.positionWS);
#else
inputData.shadowCoord = float4(0, 0, 0, 0);
#endif
inputData.fogCoord = InitializeInputDataFog(float4(input.positionWS.xyz, 1.0), input.positionWS.w);
inputData.vertexLighting = half3(0.0h, 0.0h, 0.0h);
#if !defined(LIGHTMAP_ON) && (defined(PROBE_VOLUMES_L1) || defined(PROBE_VOLUMES_L2))
inputData.bakedGI = SAMPLE_GI(input.vertexSH,
GetAbsolutePositionWS(inputData.positionWS),
inputData.normalWS,
inputData.viewDirectionWS,
input.clipPos.xy,
input.probeOcclusion,
inputData.shadowMask);
#else
inputData.bakedGI = SampleSHPixel(input.vertexSH, inputData.normalWS);
#endif
inputData.normalizedScreenSpaceUV = GetNormalizedScreenSpaceUV(input.clipPos);
inputData.shadowMask = half4(1, 1, 1, 1);
#if defined(DEBUG_DISPLAY) && !defined(PARTICLES_EDITOR_META_PASS)
inputData.vertexSH = input.vertexSH;
#endif
#if defined(DEBUG_DISPLAY) && defined(USE_APV_PROBE_OCCLUSION)
inputData.probeOcclusion = input.probeOcclusion;
#endif
}
///////////////////////////////////////////////////////////////////////////////
// Vertex and Fragment functions //
///////////////////////////////////////////////////////////////////////////////
VaryingsParticle ParticlesLitVertex(AttributesParticle input)
{
VaryingsParticle output;
UNITY_SETUP_INSTANCE_ID(input);
UNITY_TRANSFER_INSTANCE_ID(input, output);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
VertexPositionInputs vertexInput = GetParticleVertexPositionInputs(input.positionOS.xyz);
VertexNormalInputs normalInput = GetParticleVertexNormalInputs(input.normalOS, input.tangentOS);
half3 viewDirWS = GetWorldSpaceNormalizeViewDir(vertexInput.positionWS);
#ifdef _NORMALMAP
output.normalWS = half4(normalInput.normalWS, viewDirWS.x);
output.tangentWS = half4(normalInput.tangentWS, viewDirWS.y);
output.bitangentWS = half4(normalInput.bitangentWS, viewDirWS.z);
#else
output.normalWS = half3(normalInput.normalWS);
output.viewDirWS = viewDirWS;
#endif
OUTPUT_SH4(vertexInput.positionWS, output.normalWS.xyz, GetWorldSpaceNormalizeViewDir(vertexInput.positionWS), output.vertexSH, output.probeOcclusion);
half fogFactor = 0.0;
#if !defined(_FOG_FRAGMENT)
fogFactor = ComputeFogFactor(vertexInput.positionCS.z);
#endif
output.positionWS.xyz = vertexInput.positionWS.xyz;
output.positionWS.w = fogFactor;
output.clipPos = vertexInput.positionCS;
output.color = GetParticleColor(input.color);
#if defined(_FLIPBOOKBLENDING_ON)
#if defined(UNITY_PARTICLE_INSTANCING_ENABLED)
GetParticleTexcoords(output.texcoord, output.texcoord2AndBlend, input.texcoords.xyxy, 0.0);
#else
GetParticleTexcoords(output.texcoord, output.texcoord2AndBlend, input.texcoords, input.texcoordBlend);
#endif
#else
GetParticleTexcoords(output.texcoord, input.texcoords.xy);
#endif
#if defined(_SOFTPARTICLES_ON) || defined(_FADING_ON) || defined(_DISTORTION_ON)
output.projectedPosition = vertexInput.positionNDC;
#endif
#if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
output.shadowCoord = GetShadowCoord(vertexInput);
#endif
return output;
}
half4 ParticlesLitFragment(VaryingsParticle input) : SV_Target
{
UNITY_SETUP_INSTANCE_ID(input);
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);
ParticleParams particleParams;
InitParticleParams(input, particleParams);
half3 normalTS = SampleNormalTS(particleParams.uv, particleParams.blendUv, UnityBuildTexture2DStructNoScaleNoTexelSize(_BumpMap));
half4 albedo = SampleAlbedo(UnityBuildTexture2DStructNoScaleNoTexelSize(_BaseMap), particleParams);
half3 diffuse = AlphaModulate(albedo.rgb, albedo.a);
half alpha = albedo.a;
#if defined(_EMISSION)
half3 emission = BlendTexture(UnityBuildTexture2DStructNoScaleNoTexelSize(_EmissionMap), particleParams.uv, particleParams.blendUv).rgb * _EmissionColor.rgb;
#else
half3 emission = half3(0, 0, 0);
#endif
half4 specularGloss = SampleSpecularSmoothness(particleParams.uv, particleParams.blendUv, albedo.a, _SpecColor, UnityBuildTexture2DStructNoScaleNoTexelSize(_SpecGlossMap));
#if defined(_DISTORTION_ON)
diffuse = Distortion(half4(diffuse, alpha), normalTS, _DistortionStrengthScaled, _DistortionBlend, particleParams.projectedPosition);
#endif
InputData inputData;
InitializeInputData(input, normalTS, inputData);
half4 color = UniversalFragmentBlinnPhong(inputData, diffuse, specularGloss, specularGloss.a, emission, alpha, normalTS);
color.rgb = MixFog(color.rgb, inputData.fogCoord);
color.a = OutputAlpha(color.a, IsSurfaceTypeTransparent());
return color;
}
#endif // UNIVERSAL_PARTICLES_FORWARD_SIMPLE_LIT_PASS_INCLUDED
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: d0ccc42c5a0934462a0ff237772dceff
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,163 @@
#ifndef UNIVERSAL_PARTICLES_GBUFFER_SIMPLE_LIT_PASS_INCLUDED
#define UNIVERSAL_PARTICLES_GBUFFER_SIMPLE_LIT_PASS_INCLUDED
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/GBufferOutput.hlsl"
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Particles.hlsl"
void InitializeInputData(VaryingsParticle input, half3 normalTS, out InputData inputData)
{
inputData = (InputData)0;
inputData.positionWS = input.positionWS.xyz;
inputData.positionCS = input.clipPos;
#ifdef _NORMALMAP
half3 viewDirWS = half3(input.normalWS.w, input.tangentWS.w, input.bitangentWS.w);
inputData.normalWS = TransformTangentToWorld(normalTS,
half3x3(input.tangentWS.xyz, input.bitangentWS.xyz, input.normalWS.xyz));
#else
half3 viewDirWS = input.viewDirWS;
inputData.normalWS = input.normalWS;
#endif
inputData.normalWS = NormalizeNormalPerPixel(inputData.normalWS);
viewDirWS = SafeNormalize(viewDirWS);
inputData.viewDirectionWS = viewDirWS;
#if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
inputData.shadowCoord = input.shadowCoord;
#elif defined(MAIN_LIGHT_CALCULATE_SHADOWS)
inputData.shadowCoord = TransformWorldToShadowCoord(inputData.positionWS);
#else
inputData.shadowCoord = float4(0, 0, 0, 0);
#endif
inputData.fogCoord = 0; // not used for deferred shading
inputData.vertexLighting = half3(0.0h, 0.0h, 0.0h);
#if !defined(LIGHTMAP_ON) && (defined(PROBE_VOLUMES_L1) || defined(PROBE_VOLUMES_L2))
inputData.bakedGI = SAMPLE_GI(input.vertexSH,
GetAbsolutePositionWS(inputData.positionWS),
inputData.normalWS,
inputData.viewDirectionWS,
input.clipPos.xy,
input.probeOcclusion,
inputData.shadowMask);
#else
inputData.bakedGI = SampleSHPixel(input.vertexSH, inputData.normalWS);
#endif
inputData.normalizedScreenSpaceUV = GetNormalizedScreenSpaceUV(input.clipPos);
inputData.shadowMask = half4(1, 1, 1, 1);
#if defined(DEBUG_DISPLAY) && !defined(PARTICLES_EDITOR_META_PASS)
inputData.vertexSH = input.vertexSH;
#endif
#if defined(DEBUG_DISPLAY) && defined(USE_APV_PROBE_OCCLUSION)
inputData.probeOcclusion = input.probeOcclusion;
#endif
}
inline void InitializeParticleSimpleLitSurfaceData(VaryingsParticle input, out SurfaceData outSurfaceData)
{
outSurfaceData = (SurfaceData)0;
ParticleParams particleParams;
InitParticleParams(input, particleParams);
outSurfaceData.normalTS = SampleNormalTS(particleParams.uv, particleParams.blendUv, UnityBuildTexture2DStructNoScaleNoTexelSize(_BumpMap));
half4 albedo = SampleAlbedo(UnityBuildTexture2DStructNoScaleNoTexelSize(_BaseMap), particleParams);
outSurfaceData.albedo = AlphaModulate(albedo.rgb, albedo.a);
outSurfaceData.alpha = albedo.a;
#if defined(_EMISSION)
outSurfaceData.emission = BlendTexture(UnityBuildTexture2DStructNoScaleNoTexelSize(_EmissionMap), particleParams.uv, particleParams.blendUv).rgb * _EmissionColor.rgb;
#else
outSurfaceData.emission = half3(0, 0, 0);
#endif
half4 specularGloss = SampleSpecularSmoothness(particleParams.uv, particleParams.blendUv, albedo.a, _SpecColor, UnityBuildTexture2DStructNoScaleNoTexelSize(_SpecGlossMap));
outSurfaceData.specular = specularGloss.rgb;
outSurfaceData.smoothness = specularGloss.a;
#if defined(_DISTORTION_ON)
outSurfaceData.albedo = Distortion(half4(outSurfaceData.albedo, outSurfaceData.alpha), outSurfaceData.normalTS, _DistortionStrengthScaled, _DistortionBlend, projectedPosition);
#endif
outSurfaceData.metallic = 0.0; // unused
outSurfaceData.occlusion = 1.0;
}
///////////////////////////////////////////////////////////////////////////////
// Vertex and Fragment functions //
///////////////////////////////////////////////////////////////////////////////
VaryingsParticle ParticlesLitGBufferVertex(AttributesParticle input)
{
VaryingsParticle output;
UNITY_SETUP_INSTANCE_ID(input);
UNITY_TRANSFER_INSTANCE_ID(input, output);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
VertexPositionInputs vertexInput = GetParticleVertexPositionInputs(input.positionOS.xyz);
VertexNormalInputs normalInput = GetParticleVertexNormalInputs(input.normalOS, input.tangentOS);
half3 viewDirWS = GetWorldSpaceNormalizeViewDir(vertexInput.positionWS);
#ifdef _NORMALMAP
output.normalWS = half4(normalInput.normalWS, viewDirWS.x);
output.tangentWS = half4(normalInput.tangentWS, viewDirWS.y);
output.bitangentWS = half4(normalInput.bitangentWS, viewDirWS.z);
#else
output.normalWS = half3(normalInput.normalWS);
output.viewDirWS = viewDirWS;
#endif
OUTPUT_SH4(vertexInput.positionWS, output.normalWS.xyz, GetWorldSpaceNormalizeViewDir(vertexInput.positionWS), output.vertexSH, output.probeOcclusion);
output.positionWS.xyz = vertexInput.positionWS.xyz;
output.positionWS.w = 0;
output.clipPos = vertexInput.positionCS;
output.color = GetParticleColor(input.color);
#if defined(_FLIPBOOKBLENDING_ON)
#if defined(UNITY_PARTICLE_INSTANCING_ENABLED)
GetParticleTexcoords(output.texcoord, output.texcoord2AndBlend, input.texcoords.xyxy, 0.0);
#else
GetParticleTexcoords(output.texcoord, output.texcoord2AndBlend, input.texcoords, input.texcoordBlend);
#endif
#else
GetParticleTexcoords(output.texcoord, input.texcoords.xy);
#endif
#if defined(_SOFTPARTICLES_ON) || defined(_FADING_ON) || defined(_DISTORTION_ON)
output.projectedPosition = vertexInput.positionNDC;
#endif
#if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
output.shadowCoord = GetShadowCoord(vertexInput);
#endif
return output;
}
GBufferFragOutput ParticlesLitGBufferFragment(VaryingsParticle input)
{
UNITY_SETUP_INSTANCE_ID(input);
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);
SurfaceData surfaceData;
InitializeParticleSimpleLitSurfaceData(input, surfaceData);
InputData inputData;
InitializeInputData(input, surfaceData.normalTS, inputData);
SETUP_DEBUG_TEXTURE_DATA_FOR_TEX(inputData, input.texcoord, _BaseMap);
half4 color = half4(inputData.bakedGI * surfaceData.albedo + surfaceData.emission, surfaceData.alpha);
return PackGBuffersSurfaceData(surfaceData, inputData, color.rgb);
}
#endif // UNIVERSAL_PARTICLES_GBUFFER_SIMPLE_LIT_PASS_INCLUDED
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: ca0e14e5bf6ac934086f42ca329f4ef1
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,98 @@
#ifndef UNIVERSAL_PARTICLES_SIMPLE_LIT_INPUT_INCLUDED
#define UNIVERSAL_PARTICLES_SIMPLE_LIT_INPUT_INCLUDED
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
#include "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesInput.hlsl"
#include "Packages/com.unity.render-pipelines.universal/Shaders/Utils/SurfaceType.hlsl"
// NOTE: Do not ifdef the properties here as SRP batcher can not handle different layouts.
CBUFFER_START(UnityPerMaterial)
float4 _SoftParticleFadeParams;
float4 _CameraFadeParams;
float4 _BaseMap_ST;
float4 _BaseMap_TexelSize;
half4 _BaseColor;
half4 _EmissionColor;
half4 _BaseColorAddSubDiff;
half4 _SpecColor;
half _Cutoff;
half _Smoothness;
half _DistortionStrengthScaled;
half _DistortionBlend;
CBUFFER_END
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Particles.hlsl"
TEXTURE2D(_SpecGlossMap); SAMPLER(sampler_SpecGlossMap);
#define SOFT_PARTICLE_NEAR_FADE _SoftParticleFadeParams.x
#define SOFT_PARTICLE_INV_FADE_DISTANCE _SoftParticleFadeParams.y
#define CAMERA_NEAR_FADE _CameraFadeParams.x
#define CAMERA_INV_FADE_DISTANCE _CameraFadeParams.y
#define _BumpScale 1.0
half4 SampleAlbedo(float2 uv, float3 blendUv, half4 color, float4 particleColor, float4 projectedPosition, UnityTexture2D albedoMap)
{
half4 albedo = BlendTexture(albedoMap, uv, blendUv) * color;
half4 colorAddSubDiff = half4(0, 0, 0, 0);
#if defined (_COLORADDSUBDIFF_ON)
colorAddSubDiff = _BaseColorAddSubDiff;
#endif
albedo = MixParticleColor(albedo, half4(particleColor), colorAddSubDiff);
albedo.a = AlphaDiscard(albedo.a, _Cutoff);
#if defined(_SOFTPARTICLES_ON)
ALBEDO_MUL *= SoftParticles(SOFT_PARTICLE_NEAR_FADE, SOFT_PARTICLE_INV_FADE_DISTANCE, projectedPosition);
#endif
#if defined(_FADING_ON)
ALBEDO_MUL *= CameraFade(CAMERA_NEAR_FADE, CAMERA_INV_FADE_DISTANCE, projectedPosition);
#endif
return albedo;
}
half4 SampleAlbedo(UnityTexture2D albedoMap, ParticleParams params)
{
half4 albedo = BlendTexture(albedoMap, params.uv, params.blendUv) * params.baseColor;
half4 colorAddSubDiff = half4(0, 0, 0, 0);
#if defined (_COLORADDSUBDIFF_ON)
colorAddSubDiff = _BaseColorAddSubDiff;
#endif
albedo = MixParticleColor(albedo, half4(params.vertexColor), colorAddSubDiff);
albedo.a = AlphaDiscard(albedo.a, _Cutoff);
#if defined(_SOFTPARTICLES_ON)
ALBEDO_MUL *= SoftParticles(SOFT_PARTICLE_NEAR_FADE, SOFT_PARTICLE_INV_FADE_DISTANCE, params);
#endif
#if defined(_FADING_ON)
ALBEDO_MUL *= CameraFade(CAMERA_NEAR_FADE, CAMERA_INV_FADE_DISTANCE, params.projectedPosition);
#endif
return albedo;
}
half4 SampleSpecularSmoothness(float2 uv, float3 blendUv, half alpha, half4 specColor, UnityTexture2D specGlossMap)
{
half4 specularGloss = half4(0, 0, 0, 1);
#ifdef _SPECGLOSSMAP
specularGloss = BlendTexture(specGlossMap, uv, blendUv);
#elif defined(_SPECULAR_COLOR)
specularGloss = specColor;
#endif
#ifdef _GLOSSINESS_FROM_BASE_ALPHA
specularGloss.a = alpha;
#endif
return specularGloss;
}
#endif // UNIVERSAL_PARTICLES_SIMPLE_LIT_INPUT_INCLUDED
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 01fa3f8c89aa44160b9a735fc22362d0
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,354 @@
Shader "Universal Render Pipeline/Particles/Unlit"
{
Properties
{
[MainTexture] _BaseMap("Base Map", 2D) = "white" {}
[MainColor] _BaseColor("Base Color", Color) = (1,1,1,1)
_Cutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5
_BumpMap("Normal Map", 2D) = "bump" {}
[HDR] _EmissionColor("Color", Color) = (0,0,0)
_EmissionMap("Emission", 2D) = "white" {}
// -------------------------------------
// Particle specific
_SoftParticlesNearFadeDistance("Soft Particles Near Fade", Float) = 0.0
_SoftParticlesFarFadeDistance("Soft Particles Far Fade", Float) = 1.0
_CameraNearFadeDistance("Camera Near Fade", Float) = 1.0
_CameraFarFadeDistance("Camera Far Fade", Float) = 2.0
_DistortionBlend("Distortion Blend", Range(0.0, 1.0)) = 0.5
_DistortionStrength("Distortion Strength", Float) = 1.0
// -------------------------------------
// Hidden properties - Generic
_Surface("__surface", Float) = 0.0
_Blend("__mode", Float) = 0.0
_Cull("__cull", Float) = 2.0
[ToggleUI] _AlphaClip("__clip", Float) = 0.0
[HideInInspector] _BlendOp("__blendop", Float) = 0.0
[HideInInspector] _SrcBlend("__src", Float) = 1.0
[HideInInspector] _DstBlend("__dst", Float) = 0.0
[HideInInspector] _SrcBlendAlpha("__srcA", Float) = 1.0
[HideInInspector] _DstBlendAlpha("__dstA", Float) = 0.0
[HideInInspector] _ZWrite("__zw", Float) = 1.0
[HideInInspector] _AlphaToMask("__alphaToMask", Float) = 0.0
// Particle specific
_ColorMode("_ColorMode", Float) = 0.0
[HideInInspector] _BaseColorAddSubDiff("_ColorMode", Vector) = (0,0,0,0)
[ToggleOff] _FlipbookBlending("__flipbookblending", Float) = 0.0
[ToggleUI] _SoftParticlesEnabled("__softparticlesenabled", Float) = 0.0
[ToggleUI] _CameraFadingEnabled("__camerafadingenabled", Float) = 0.0
[ToggleUI] _DistortionEnabled("__distortionenabled", Float) = 0.0
[HideInInspector] _SoftParticleFadeParams("__softparticlefadeparams", Vector) = (0,0,0,0)
[HideInInspector] _CameraFadeParams("__camerafadeparams", Vector) = (0,0,0,0)
[HideInInspector] _DistortionStrengthScaled("Distortion Strength Scaled", Float) = 0.1
// Editmode props
_QueueOffset("Queue offset", Float) = 0.0
// ObsoleteProperties
[HideInInspector] _FlipbookMode("flipbook", Float) = 0
[HideInInspector] _Mode("mode", Float) = 0
[HideInInspector] _Color("color", Color) = (1,1,1,1)
}
HLSLINCLUDE
ENDHLSL
SubShader
{
Tags
{
"RenderType" = "Opaque"
"IgnoreProjector" = "True"
"PreviewType" = "Plane"
"PerformanceChecks" = "False"
"RenderPipeline" = "UniversalPipeline"
}
// ------------------------------------------------------------------
// Forward pass.
Pass
{
Name "ForwardLit"
// -------------------------------------
// Render State Commands
BlendOp[_BlendOp]
Blend[_SrcBlend][_DstBlend], [_SrcBlendAlpha][_DstBlendAlpha]
ZWrite[_ZWrite]
Cull[_Cull]
AlphaToMask[_AlphaToMask]
HLSLPROGRAM
#pragma target 2.0
// -------------------------------------
// Shader Stages
#pragma vertex vertParticleUnlit
#pragma fragment fragParticleUnlit
// -------------------------------------
// Material Keywords
#pragma shader_feature_local _NORMALMAP
#pragma shader_feature_local_fragment _EMISSION
// -------------------------------------
// Particle Keywords
#pragma shader_feature_local _FLIPBOOKBLENDING_ON
#pragma shader_feature_local _SOFTPARTICLES_ON
#pragma shader_feature_local _FADING_ON
#pragma shader_feature_local _DISTORTION_ON
#pragma shader_feature_local_fragment _ALPHATEST_ON
#pragma shader_feature_local_fragment _SURFACE_TYPE_TRANSPARENT
#pragma shader_feature_local_fragment _ _ALPHAPREMULTIPLY_ON _ALPHAMODULATE_ON
#pragma shader_feature_local_fragment _ _COLOROVERLAY_ON _COLORCOLOR_ON _COLORADDSUBDIFF_ON
// -------------------------------------
// Unity defined keywords
#pragma multi_compile_instancing
#pragma multi_compile_fragment _ _SCREEN_SPACE_OCCLUSION
#pragma multi_compile_fragment _ DEBUG_DISPLAY
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Fog.hlsl"
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ProbeVolumeVariants.hlsl"
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl"
#pragma instancing_options procedural:ParticleInstancingSetup
// -------------------------------------
// Includes
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesUnlitInput.hlsl"
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesUnlitForwardPass.hlsl"
ENDHLSL
}
// ------------------------------------------------------------------
// Depth Only pass.
Pass
{
Name "DepthOnly"
Tags
{
"LightMode" = "DepthOnly"
}
// -------------------------------------
// Render State Commands
ZWrite On
ColorMask R
Cull[_Cull]
HLSLPROGRAM
#pragma target 2.0
// -------------------------------------
// Shader Stages
#pragma vertex DepthOnlyVertex
#pragma fragment DepthOnlyFragment
// -------------------------------------
// Material Keywords
#pragma shader_feature_local _ _ALPHATEST_ON
#pragma shader_feature_local _ _FLIPBOOKBLENDING_ON
#pragma shader_feature_local_fragment _ _COLOROVERLAY_ON _COLORCOLOR_ON _COLORADDSUBDIFF_ON
// -------------------------------------
// Unity defined keywords
#pragma multi_compile_instancing
#pragma instancing_options procedural:ParticleInstancingSetup
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl"
// -------------------------------------
// Includes
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesUnlitInput.hlsl"
#include "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesDepthOnlyPass.hlsl"
ENDHLSL
}
// ------------------------------------------------------------------
// Shadow Caster pass.
Pass
{
Name "ShadowCaster"
Tags
{
"LightMode" = "ShadowCaster"
}
// -------------------------------------
// Render State Commands
ZWrite On
ZTest LEqual
ColorMask 0
Cull[_Cull]
HLSLPROGRAM
#pragma target 2.0
// -------------------------------------
// Shader Stages
#pragma vertex ShadowCasterParticlesVertex
#pragma fragment ShadowCasterParticlesFragment
// -------------------------------------
// Material Keywords
#pragma shader_feature_local _ _ALPHATEST_ON
#pragma shader_feature_local _ _FLIPBOOKBLENDING_ON
#pragma shader_feature_local_fragment _ _COLOROVERLAY_ON _COLORCOLOR_ON _COLORADDSUBDIFF_ON
// -------------------------------------
// Universal Pipeline keywords
#pragma multi_compile_vertex _ _CASTING_PUNCTUAL_LIGHT_SHADOW
// -------------------------------------
// Unity defined keywords
#pragma multi_compile_instancing
#pragma instancing_options procedural:ParticleInstancingSetup
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl"
// -------------------------------------
// Includes
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesUnlitInput.hlsl"
#include "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesShadowCasterPass.hlsl"
ENDHLSL
}
// This pass is used when drawing to a _CameraNormalsTexture texture with the forward renderer or the depthNormal prepass with the deferred renderer.
Pass
{
Name "DepthNormalsOnly"
Tags
{
"LightMode" = "DepthNormalsOnly"
}
// -------------------------------------
// Render State Commands
ZWrite On
Cull[_Cull]
HLSLPROGRAM
#pragma target 2.0
// -------------------------------------
// Shader Stages
#pragma vertex DepthNormalsVertex
#pragma fragment DepthNormalsFragment
// -------------------------------------
// Material Keywords
#pragma shader_feature_local _ _NORMALMAP
#pragma shader_feature_local _ _ALPHATEST_ON
#pragma shader_feature_local_fragment _ _COLOROVERLAY_ON _COLORCOLOR_ON _COLORADDSUBDIFF_ON
// -------------------------------------
// Unity defined keywords
#pragma multi_compile_fragment _ _GBUFFER_NORMALS_OCT // forward-only variant
//--------------------------------------
// GPU Instancing
#pragma multi_compile_instancing
#pragma instancing_options procedural:ParticleInstancingSetup
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl"
// -------------------------------------
// Includes
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesUnlitInput.hlsl"
#include "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesDepthNormalsPass.hlsl"
ENDHLSL
}
// ------------------------------------------------------------------
// Scene view outline pass.
Pass
{
Name "SceneSelectionPass"
Tags
{
"LightMode" = "SceneSelectionPass"
}
// -------------------------------------
// Render State Commands
BlendOp Add
Blend One Zero
ZWrite On
Cull Off
HLSLPROGRAM
#define PARTICLES_EDITOR_META_PASS
#pragma target 2.0
// -------------------------------------
// Shader Stages
#pragma vertex vertParticleEditor
#pragma fragment fragParticleSceneHighlight
// -------------------------------------
// Particle Keywords
#pragma shader_feature_local_fragment _ALPHATEST_ON
#pragma shader_feature_local _FLIPBOOKBLENDING_ON
// -------------------------------------
// Unity defined keywords
#pragma multi_compile_instancing
#pragma instancing_options procedural:ParticleInstancingSetup
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl"
// -------------------------------------
// Includes
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesUnlitInput.hlsl"
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesEditorPass.hlsl"
ENDHLSL
}
// ------------------------------------------------------------------
// Scene picking buffer pass.
Pass
{
Name "ScenePickingPass"
Tags
{
"LightMode" = "Picking"
}
// -------------------------------------
// Render State Commands
BlendOp Add
Blend One Zero
ZWrite On
Cull Off
HLSLPROGRAM
#define PARTICLES_EDITOR_META_PASS
#pragma target 2.0
// -------------------------------------
// Shader Stages
#pragma vertex vertParticleEditor
#pragma fragment fragParticleScenePicking
// -------------------------------------
// Particle Keywords
#pragma shader_feature_local_fragment _ALPHATEST_ON
#pragma shader_feature_local _FLIPBOOKBLENDING_ON
// -------------------------------------
// Unity defined keywords
#pragma multi_compile_instancing
#pragma instancing_options procedural:ParticleInstancingSetup
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl"
// -------------------------------------
// Includes
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesUnlitInput.hlsl"
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesEditorPass.hlsl"
ENDHLSL
}
}
FallBack "Hidden/Universal Render Pipeline/FallbackError"
CustomEditor "UnityEditor.Rendering.Universal.ShaderGUI.ParticlesUnlitShader"
}
@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 0406db5a14f94604a8c57ccfbc9f3b46
timeCreated: 1509363223
licenseType: Pro
ShaderImporter:
externalObjects: {}
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,167 @@
#ifndef UNIVERSAL_PARTICLES_UNLIT_FORWARD_PASS_INCLUDED
#define UNIVERSAL_PARTICLES_UNLIT_FORWARD_PASS_INCLUDED
#include "ParticlesUnlitInput.hlsl"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Unlit.hlsl"
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Particles.hlsl"
void InitializeInputData(VaryingsParticle input, SurfaceData surfaceData, out InputData inputData)
{
inputData = (InputData)0;
inputData.positionWS = input.positionWS.xyz;
#ifdef _NORMALMAP
half3 viewDirWS = half3(input.normalWS.w, input.tangentWS.w, input.bitangentWS.w);
inputData.tangentToWorld = half3x3(input.tangentWS.xyz, input.bitangentWS.xyz, input.normalWS.xyz);
inputData.normalWS = TransformTangentToWorld(surfaceData.normalTS, inputData.tangentToWorld);
#else
half3 viewDirWS = input.viewDirWS;
inputData.normalWS = input.normalWS;
#endif
inputData.normalWS = NormalizeNormalPerPixel(inputData.normalWS);
viewDirWS = SafeNormalize(viewDirWS);
inputData.viewDirectionWS = viewDirWS;
inputData.fogCoord = InitializeInputDataFog(float4(input.positionWS.xyz, 1.0), input.positionWS.w);
inputData.vertexLighting = 0;
#if !defined(LIGHTMAP_ON) && (defined(PROBE_VOLUMES_L1) || defined(PROBE_VOLUMES_L2))
inputData.bakedGI = SAMPLE_GI(input.vertexSH,
GetAbsolutePositionWS(inputData.positionWS),
inputData.normalWS,
inputData.viewDirectionWS,
input.clipPos.xy,
input.probeOcclusion,
inputData.shadowMask);
#else
inputData.bakedGI = SampleSHPixel(input.vertexSH, inputData.normalWS);
#endif
inputData.normalizedScreenSpaceUV = GetNormalizedScreenSpaceUV(input.clipPos);
inputData.shadowMask = 1;
inputData.shadowCoord = 0;
#if defined(DEBUG_DISPLAY) && !defined(PARTICLES_EDITOR_META_PASS)
inputData.vertexSH = input.vertexSH;
#endif
#if defined(DEBUG_DISPLAY) && defined(USE_APV_PROBE_OCCLUSION)
inputData.probeOcclusion = input.probeOcclusion;
#endif
}
void InitializeSurfaceData(ParticleParams particleParams, out SurfaceData surfaceData)
{
surfaceData = (SurfaceData)0;
half4 albedo = SampleAlbedo(UnityBuildTexture2DStructNoScaleNoTexelSize(_BaseMap), particleParams);
half3 normalTS = SampleNormalTS(particleParams.uv, particleParams.blendUv, UnityBuildTexture2DStructNoScaleNoTexelSize(_BumpMap));
#if defined (_DISTORTION_ON)
albedo.rgb = Distortion(albedo, normalTS, _DistortionStrengthScaled, _DistortionBlend, particleParams.projectedPosition);
#endif
#if defined(_EMISSION)
half3 emission = BlendTexture(UnityBuildTexture2DStructNoScaleNoTexelSize(_EmissionMap), particleParams.uv, particleParams.blendUv).rgb * _EmissionColor.rgb;
#else
const half3 emission = 0;
#endif
surfaceData.albedo = albedo.rgb;
surfaceData.specular = 0;
surfaceData.normalTS = normalTS;
surfaceData.emission = emission;
surfaceData.metallic = 0;
surfaceData.smoothness = 1;
surfaceData.occlusion = 1;
surfaceData.alpha = albedo.a;
surfaceData.clearCoatMask = 0;
surfaceData.clearCoatSmoothness = 1;
}
///////////////////////////////////////////////////////////////////////////////
// Vertex and Fragment functions //
///////////////////////////////////////////////////////////////////////////////
VaryingsParticle vertParticleUnlit(AttributesParticle input)
{
VaryingsParticle output = (VaryingsParticle)0;
UNITY_SETUP_INSTANCE_ID(input);
UNITY_TRANSFER_INSTANCE_ID(input, output);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
VertexPositionInputs vertexInput = GetParticleVertexPositionInputs(input.positionOS.xyz);
VertexNormalInputs normalInput = GetParticleVertexNormalInputs(input.normalOS, input.tangentOS);
half fogFactor = 0.0;
#if !defined(_FOG_FRAGMENT)
fogFactor = ComputeFogFactor(vertexInput.positionCS.z);
#endif
// position ws is used to compute eye depth in vertFading
output.positionWS.xyz = vertexInput.positionWS;
output.positionWS.w = fogFactor;
output.clipPos = vertexInput.positionCS;
output.color = GetParticleColor(input.color);
half3 viewDirWS = GetWorldSpaceNormalizeViewDir(vertexInput.positionWS);
#ifdef _NORMALMAP
output.normalWS = half4(normalInput.normalWS, viewDirWS.x);
output.tangentWS = half4(normalInput.tangentWS, viewDirWS.y);
output.bitangentWS = half4(normalInput.bitangentWS, viewDirWS.z);
#else
output.normalWS = half3(normalInput.normalWS);
output.viewDirWS = viewDirWS;
#endif
#if defined(_FLIPBOOKBLENDING_ON)
#if defined(UNITY_PARTICLE_INSTANCING_ENABLED)
GetParticleTexcoords(output.texcoord, output.texcoord2AndBlend, input.texcoords.xyxy, 0.0);
#else
GetParticleTexcoords(output.texcoord, output.texcoord2AndBlend, input.texcoords, input.texcoordBlend);
#endif
#else
GetParticleTexcoords(output.texcoord, input.texcoords.xy);
#endif
#if defined(_SOFTPARTICLES_ON) || defined(_FADING_ON) || defined(_DISTORTION_ON)
output.projectedPosition = vertexInput.positionNDC;
#endif
return output;
}
half4 fragParticleUnlit(VaryingsParticle input) : SV_Target
{
UNITY_SETUP_INSTANCE_ID(input);
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);
ParticleParams particleParams;
InitParticleParams(input, particleParams);
SurfaceData surfaceData;
InitializeSurfaceData(particleParams, surfaceData);
InputData inputData;
InitializeInputData(input, surfaceData, inputData);
SETUP_DEBUG_TEXTURE_DATA_FOR_TEX(inputData, input.texcoord, _BaseMap);
half4 finalColor = UniversalFragmentUnlit(inputData, surfaceData);
#if defined(_SCREEN_SPACE_OCCLUSION) && !defined(_SURFACE_TYPE_TRANSPARENT)
float2 normalizedScreenSpaceUV = GetNormalizedScreenSpaceUV(input.clipPos);
AmbientOcclusionFactor aoFactor = GetScreenSpaceAmbientOcclusion(normalizedScreenSpaceUV);
finalColor.rgb *= aoFactor.directAmbientOcclusion;
#endif
finalColor.rgb = MixFog(finalColor.rgb, inputData.fogCoord);
finalColor.a = OutputAlpha(finalColor.a, IsSurfaceTypeTransparent());
return finalColor;
}
#endif // UNIVERSAL_PARTICLES_UNLIT_FORWARD_PASS_INCLUDED
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: a361552991159403bbd785132d5cb812
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,84 @@
#ifndef UNIVERSAL_PARTICLES_UNLIT_INPUT_INCLUDED
#define UNIVERSAL_PARTICLES_UNLIT_INPUT_INCLUDED
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
#include "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesInput.hlsl"
#include "Packages/com.unity.render-pipelines.universal/Shaders/Utils/SurfaceType.hlsl"
// NOTE: Do not ifdef the properties here as SRP batcher can not handle different layouts.
CBUFFER_START(UnityPerMaterial)
float4 _SoftParticleFadeParams;
float4 _CameraFadeParams;
float4 _BaseMap_ST;
float4 _BaseMap_TexelSize;
half4 _BaseColor;
half4 _EmissionColor;
half4 _BaseColorAddSubDiff;
half _Cutoff;
half _DistortionStrengthScaled;
half _DistortionBlend;
CBUFFER_END
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Particles.hlsl"
#define SOFT_PARTICLE_NEAR_FADE _SoftParticleFadeParams.x
#define SOFT_PARTICLE_INV_FADE_DISTANCE _SoftParticleFadeParams.y
#define CAMERA_NEAR_FADE _CameraFadeParams.x
#define CAMERA_INV_FADE_DISTANCE _CameraFadeParams.y
#define _BumpScale 1.0
half4 SampleAlbedo(float2 uv, float3 blendUv, half4 color, float4 particleColor, float4 projectedPosition, UnityTexture2D albedoMap)
{
half4 albedo = BlendTexture(albedoMap, uv, blendUv) * color;
// No distortion Support
half4 colorAddSubDiff = half4(0, 0, 0, 0);
#if defined (_COLORADDSUBDIFF_ON)
colorAddSubDiff = _BaseColorAddSubDiff;
#endif
albedo = MixParticleColor(albedo, half4(particleColor), colorAddSubDiff);
albedo.a = AlphaDiscard(albedo.a, _Cutoff);
albedo.rgb = AlphaModulateAndPremultiply(albedo.rgb, albedo.a);
#if defined(_SOFTPARTICLES_ON)
albedo = SOFT_PARTICLE_MUL_ALBEDO(albedo, half(SoftParticles(SOFT_PARTICLE_NEAR_FADE, SOFT_PARTICLE_INV_FADE_DISTANCE, projectedPosition)));
#endif
#if defined(_FADING_ON)
ALBEDO_MUL *= CameraFade(CAMERA_NEAR_FADE, CAMERA_INV_FADE_DISTANCE, projectedPosition);
#endif
return albedo;
}
half4 SampleAlbedo(UnityTexture2D albedoMap, ParticleParams params)
{
half4 albedo = BlendTexture(albedoMap, params.uv, params.blendUv) * params.baseColor;
// No distortion Support
#if defined (_COLORADDSUBDIFF_ON)
half4 colorAddSubDiff = _BaseColorAddSubDiff;
#else
half4 colorAddSubDiff = half4(0, 0, 0, 0);
#endif
albedo = MixParticleColor(albedo, half4(params.vertexColor), colorAddSubDiff);
albedo.a = AlphaDiscard(albedo.a, _Cutoff);
albedo.rgb = AlphaModulateAndPremultiply(albedo.rgb, albedo.a);
#if defined(_SOFTPARTICLES_ON)
albedo = SOFT_PARTICLE_MUL_ALBEDO(albedo, half(SoftParticles(SOFT_PARTICLE_NEAR_FADE, SOFT_PARTICLE_INV_FADE_DISTANCE, params)));
#endif
#if defined(_FADING_ON)
ALBEDO_MUL *= CameraFade(CAMERA_NEAR_FADE, CAMERA_INV_FADE_DISTANCE, params.projectedPosition);
#endif
return albedo;
}
#endif // UNIVERSAL_PARTICLES_PBR_INCLUDED
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 0ddf9719bc9ff43e1a017712e21bb5e6
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant: