testss
This commit is contained in:
@@ -0,0 +1,76 @@
|
||||
#ifndef UNIVERSAL_PARTICLES_EDITOR_PASS_INCLUDED
|
||||
#define UNIVERSAL_PARTICLES_EDITOR_PASS_INCLUDED
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesInput.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Particles.hlsl"
|
||||
|
||||
#ifdef _ALPHATEST_ON
|
||||
half _Cutoff;
|
||||
#endif
|
||||
|
||||
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 = GetVertexPositionInputs(input.vertex.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, TEXTURE2D_ARGS(_BaseMap, sampler_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,62 @@
|
||||
#ifndef UNIVERSAL_PARTICLES_INPUT_INCLUDED
|
||||
#define UNIVERSAL_PARTICLES_INPUT_INCLUDED
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
|
||||
|
||||
struct AttributesParticle
|
||||
{
|
||||
float4 vertex : 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 normal : NORMAL;
|
||||
float4 tangent : 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
|
||||
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
|
||||
|
||||
#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
|
||||
|
||||
float3 vertexSH : TEXCOORD8; // SH
|
||||
#endif
|
||||
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
#endif // UNIVERSAL_PARTICLES_INPUT_INCLUDED
|
@@ -0,0 +1,265 @@
|
||||
// ------------------------------------------
|
||||
// No shadows
|
||||
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" {}
|
||||
_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", Float) = 0.5
|
||||
_DistortionStrength("Distortion Strength", Float) = 1.0
|
||||
|
||||
// -------------------------------------
|
||||
// Hidden properties - Generic
|
||||
[HideInInspector] _Surface("__surface", Float) = 0.0
|
||||
[HideInInspector] _Blend("__mode", Float) = 0.0
|
||||
[HideInInspector] _AlphaClip("__clip", Float) = 0.0
|
||||
[HideInInspector] _BlendOp("__blendop", Float) = 0.0
|
||||
[HideInInspector] _SrcBlend("__src", Float) = 1.0
|
||||
[HideInInspector] _DstBlend("__dst", Float) = 0.0
|
||||
[HideInInspector] _ZWrite("__zw", Float) = 1.0
|
||||
[HideInInspector] _Cull("__cull", Float) = 2.0
|
||||
// Particle specific
|
||||
[HideInInspector] _ColorMode("_ColorMode", Float) = 0.0
|
||||
[HideInInspector] _BaseColorAddSubDiff("_ColorMode", Vector) = (0,0,0,0)
|
||||
[ToggleOff] _FlipbookBlending("__flipbookblending", Float) = 0.0
|
||||
[HideInInspector] _SoftParticlesEnabled("__softparticlesenabled", Float) = 0.0
|
||||
[HideInInspector] _CameraFadingEnabled("__camerafadingenabled", Float) = 0.0
|
||||
[HideInInspector] _SoftParticleFadeParams("__softparticlefadeparams", Vector) = (0,0,0,0)
|
||||
[HideInInspector] _CameraFadeParams("__camerafadeparams", Vector) = (0,0,0,0)
|
||||
[HideInInspector] _DistortionEnabled("__distortionenabled", Float) = 0.0
|
||||
[HideInInspector] _DistortionStrengthScaled("Distortion Strength Scaled", Float) = 0.1
|
||||
|
||||
// Editmode props
|
||||
[HideInInspector] _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)
|
||||
}
|
||||
|
||||
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"}
|
||||
|
||||
BlendOp[_BlendOp]
|
||||
Blend[_SrcBlend][_DstBlend]
|
||||
ZWrite[_ZWrite]
|
||||
Cull[_Cull]
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma target 2.0
|
||||
|
||||
// -------------------------------------
|
||||
// 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_local_fragment _ _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_local _SOFTPARTICLES_ON
|
||||
#pragma shader_feature_local _FADING_ON
|
||||
#pragma shader_feature_local _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
|
||||
|
||||
// -------------------------------------
|
||||
// Unity defined keywords
|
||||
#pragma multi_compile_fog
|
||||
#pragma multi_compile_instancing
|
||||
#pragma instancing_options procedural:ParticleInstancingSetup
|
||||
|
||||
#pragma vertex ParticlesLitVertex
|
||||
#pragma fragment ParticlesLitFragment
|
||||
|
||||
#include "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"}
|
||||
|
||||
ZWrite[_ZWrite]
|
||||
Cull[_Cull]
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma exclude_renderers gles
|
||||
#pragma target 2.0
|
||||
|
||||
// -------------------------------------
|
||||
// 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 _ _SHADOWS_SOFT
|
||||
#pragma multi_compile_fragment _ _GBUFFER_NORMALS_OCT
|
||||
|
||||
// -------------------------------------
|
||||
// Unity defined keywords
|
||||
#pragma multi_compile_instancing
|
||||
#pragma instancing_options procedural:ParticleInstancingSetup
|
||||
|
||||
#pragma vertex ParticlesGBufferVertex
|
||||
#pragma fragment ParticlesGBufferFragment
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesLitInput.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesLitGbufferPass.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
// ------------------------------------------------------------------
|
||||
// Scene view outline pass.
|
||||
Pass
|
||||
{
|
||||
Name "SceneSelectionPass"
|
||||
Tags { "LightMode" = "SceneSelectionPass" }
|
||||
|
||||
BlendOp Add
|
||||
Blend One Zero
|
||||
ZWrite On
|
||||
Cull Off
|
||||
|
||||
HLSLPROGRAM
|
||||
#define PARTICLES_EDITOR_META_PASS
|
||||
#pragma target 2.0
|
||||
|
||||
// -------------------------------------
|
||||
// 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
|
||||
|
||||
#pragma vertex vertParticleEditor
|
||||
#pragma fragment fragParticleSceneHighlight
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesLitInput.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesEditorPass.hlsl"
|
||||
|
||||
ENDHLSL
|
||||
}
|
||||
// ------------------------------------------------------------------
|
||||
// Scene picking buffer pass.
|
||||
Pass
|
||||
{
|
||||
Name "ScenePickingPass"
|
||||
Tags{ "LightMode" = "Picking" }
|
||||
|
||||
BlendOp Add
|
||||
Blend One Zero
|
||||
ZWrite On
|
||||
Cull Off
|
||||
|
||||
HLSLPROGRAM
|
||||
#define PARTICLES_EDITOR_META_PASS
|
||||
#pragma target 2.0
|
||||
|
||||
// -------------------------------------
|
||||
// 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
|
||||
|
||||
#pragma vertex vertParticleEditor
|
||||
#pragma fragment fragParticleScenePicking
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesLitInput.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesEditorPass.hlsl"
|
||||
|
||||
ENDHLSL
|
||||
}
|
||||
Pass
|
||||
{
|
||||
Name "Universal2D"
|
||||
Tags{ "LightMode" = "Universal2D" }
|
||||
|
||||
Blend[_SrcBlend][_DstBlend]
|
||||
ZWrite[_ZWrite]
|
||||
Cull[_Cull]
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma shader_feature_local_fragment _ALPHATEST_ON
|
||||
#pragma shader_feature_local_fragment _ALPHAPREMULTIPLY_ON
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/UnlitInput.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/Utils/Universal2D.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
}
|
||||
|
||||
Fallback "Universal Render Pipeline/Particles/SimpleLit"
|
||||
CustomEditor "UnityEditor.Rendering.Universal.ShaderGUI.ParticlesLitShader"
|
||||
}
|
@@ -0,0 +1,126 @@
|
||||
#ifndef UNIVERSAL_PARTICLES_FORWARD_LIT_PASS_INCLUDED
|
||||
#define UNIVERSAL_PARTICLES_FORWARD_LIT_PASS_INCLUDED
|
||||
|
||||
#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 output)
|
||||
{
|
||||
output = (InputData)0;
|
||||
|
||||
output.positionWS = input.positionWS.xyz;
|
||||
|
||||
#ifdef _NORMALMAP
|
||||
half3 viewDirWS = half3(input.normalWS.w, input.tangentWS.w, input.bitangentWS.w);
|
||||
output.normalWS = TransformTangentToWorld(normalTS,
|
||||
half3x3(input.tangentWS.xyz, input.bitangentWS.xyz, input.normalWS.xyz));
|
||||
#else
|
||||
half3 viewDirWS = input.viewDirWS;
|
||||
output.normalWS = input.normalWS;
|
||||
#endif
|
||||
|
||||
output.normalWS = NormalizeNormalPerPixel(output.normalWS);
|
||||
|
||||
#if SHADER_HINT_NICE_QUALITY
|
||||
viewDirWS = SafeNormalize(viewDirWS);
|
||||
#endif
|
||||
|
||||
output.viewDirectionWS = viewDirWS;
|
||||
|
||||
#if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
|
||||
output.shadowCoord = input.shadowCoord;
|
||||
#elif defined(MAIN_LIGHT_CALCULATE_SHADOWS)
|
||||
output.shadowCoord = TransformWorldToShadowCoord(output.positionWS);
|
||||
#else
|
||||
output.shadowCoord = float4(0, 0, 0, 0);
|
||||
#endif
|
||||
|
||||
output.fogCoord = (half)input.positionWS.w;
|
||||
output.vertexLighting = half3(0.0h, 0.0h, 0.0h);
|
||||
output.bakedGI = SampleSHPixel(input.vertexSH, output.normalWS);
|
||||
output.normalizedScreenSpaceUV = GetNormalizedScreenSpaceUV(input.clipPos);
|
||||
output.shadowMask = half4(1, 1, 1, 1);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// 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 = GetVertexPositionInputs(input.vertex.xyz);
|
||||
VertexNormalInputs normalInput = GetVertexNormalInputs(input.normal, input.tangent);
|
||||
|
||||
half3 viewDirWS = GetWorldSpaceViewDir(vertexInput.positionWS);
|
||||
#if !SHADER_HINT_NICE_QUALITY
|
||||
viewDirWS = SafeNormalize(viewDirWS);
|
||||
#endif
|
||||
|
||||
half3 vertexLight = VertexLighting(vertexInput.positionWS, normalInput.normalWS);
|
||||
half fogFactor = ComputeFogFactor(vertexInput.positionCS.z);
|
||||
|
||||
#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 = normalInput.normalWS;
|
||||
output.viewDirWS = viewDirWS;
|
||||
#endif
|
||||
|
||||
OUTPUT_SH(output.normalWS.xyz, output.vertexSH);
|
||||
|
||||
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 = (InputData)0;
|
||||
InitializeInputData(input, surfaceData.normalTS, inputData);
|
||||
|
||||
half4 color = UniversalFragmentPBR(inputData, surfaceData);
|
||||
color.rgb = MixFog(color.rgb, inputData.fogCoord);
|
||||
color.a = OutputAlpha(color.a, _Surface);
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
#endif // UNIVERSAL_PARTICLES_FORWARD_LIT_PASS_INCLUDED
|
@@ -0,0 +1,134 @@
|
||||
#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/UnityGBuffer.hlsl"
|
||||
|
||||
void InitializeInputData(VaryingsParticle input, half3 normalTS, out InputData output)
|
||||
{
|
||||
output = (InputData)0;
|
||||
|
||||
output.positionWS = input.positionWS.xyz;
|
||||
|
||||
#ifdef _NORMALMAP
|
||||
half3 viewDirWS = half3(input.normalWS.w, input.tangentWS.w, input.bitangentWS.w);
|
||||
output.normalWS = TransformTangentToWorld(normalTS,
|
||||
half3x3(input.tangentWS.xyz, input.bitangentWS.xyz, input.normalWS.xyz));
|
||||
#else
|
||||
half3 viewDirWS = input.viewDirWS;
|
||||
output.normalWS = input.normalWS;
|
||||
#endif
|
||||
|
||||
output.normalWS = NormalizeNormalPerPixel(output.normalWS);
|
||||
|
||||
#if SHADER_HINT_NICE_QUALITY
|
||||
viewDirWS = SafeNormalize(viewDirWS);
|
||||
#endif
|
||||
|
||||
output.viewDirectionWS = viewDirWS;
|
||||
|
||||
#if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
|
||||
output.shadowCoord = input.shadowCoord;
|
||||
#elif defined(MAIN_LIGHT_CALCULATE_SHADOWS)
|
||||
output.shadowCoord = TransformWorldToShadowCoord(output.positionWS);
|
||||
#else
|
||||
output.shadowCoord = float4(0, 0, 0, 0);
|
||||
#endif
|
||||
|
||||
output.fogCoord = 0.0; // not used for deferred shading
|
||||
output.vertexLighting = half3(0.0h, 0.0h, 0.0h);
|
||||
output.bakedGI = SampleSHPixel(input.vertexSH, output.normalWS);
|
||||
output.normalizedScreenSpaceUV = GetNormalizedScreenSpaceUV(input.clipPos);
|
||||
output.shadowMask = half4(1, 1, 1, 1);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// 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 = GetVertexPositionInputs(input.vertex.xyz);
|
||||
VertexNormalInputs normalInput = GetVertexNormalInputs(input.normal, input.tangent);
|
||||
|
||||
half3 viewDirWS = GetWorldSpaceViewDir(vertexInput.positionWS);
|
||||
#if !SHADER_HINT_NICE_QUALITY
|
||||
viewDirWS = SafeNormalize(viewDirWS);
|
||||
#endif
|
||||
|
||||
half3 vertexLight = VertexLighting(vertexInput.positionWS, 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 = normalInput.normalWS;
|
||||
output.viewDirWS = viewDirWS;
|
||||
#endif
|
||||
|
||||
OUTPUT_SH(output.normalWS.xyz, output.vertexSH);
|
||||
|
||||
output.positionWS.xyz = vertexInput.positionWS;
|
||||
output.clipPos = vertexInput.positionCS;
|
||||
output.color = 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;
|
||||
}
|
||||
|
||||
FragmentOutput 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 = (InputData)0;
|
||||
InitializeInputData(input, surfaceData.normalTS, inputData);
|
||||
|
||||
// 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, inputData.bakedGI, surfaceData.occlusion, inputData.normalWS, inputData.viewDirectionWS);
|
||||
|
||||
return BRDFDataToGbuffer(brdfData, inputData, surfaceData.smoothness, surfaceData.emission + color);
|
||||
}
|
||||
|
||||
#endif // UNIVERSAL_PARTICLES_GBUFFER_LIT_PASS_INCLUDED
|
@@ -0,0 +1,165 @@
|
||||
#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"
|
||||
|
||||
// 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;
|
||||
half4 _BaseColor;
|
||||
half4 _EmissionColor;
|
||||
half4 _BaseColorAddSubDiff;
|
||||
half _Cutoff;
|
||||
half _Metallic;
|
||||
half _Smoothness;
|
||||
half _BumpScale;
|
||||
half _DistortionStrengthScaled;
|
||||
half _DistortionBlend;
|
||||
half _Surface;
|
||||
CBUFFER_END
|
||||
|
||||
#include "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
|
||||
|
||||
// Pre-multiplied alpha helper
|
||||
#if defined(_ALPHAPREMULTIPLY_ON)
|
||||
#define ALBEDO_MUL albedo
|
||||
#else
|
||||
#define ALBEDO_MUL albedo.a
|
||||
#endif
|
||||
|
||||
half4 SampleAlbedo(float2 uv, float3 blendUv, half4 color, float4 particleColor, float4 projectedPosition, TEXTURE2D_PARAM(albedoMap, sampler_albedoMap))
|
||||
{
|
||||
half4 albedo = BlendTexture(TEXTURE2D_ARGS(albedoMap, sampler_albedoMap), uv, blendUv) * color;
|
||||
|
||||
half4 colorAddSubDiff = half4(0, 0, 0, 0);
|
||||
#if defined (_COLORADDSUBDIFF_ON)
|
||||
colorAddSubDiff = _BaseColorAddSubDiff;
|
||||
#endif
|
||||
// No distortion Support
|
||||
albedo = MixParticleColor(albedo, particleColor, colorAddSubDiff);
|
||||
|
||||
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(TEXTURE2D_PARAM(albedoMap, sampler_albedoMap), ParticleParams params)
|
||||
{
|
||||
half4 albedo = BlendTexture(TEXTURE2D_ARGS(albedoMap, sampler_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, params.vertexColor, colorAddSubDiff);
|
||||
|
||||
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, TEXTURE2D_ARGS(_BaseMap, sampler_BaseMap));
|
||||
|
||||
#if defined(_METALLICSPECGLOSSMAP)
|
||||
half2 metallicGloss = BlendTexture(TEXTURE2D_ARGS(_MetallicGlossMap, sampler_MetallicGlossMap), uv, blendUv).ra * half2(1.0, _Smoothness);
|
||||
#else
|
||||
half2 metallicGloss = half2(_Metallic, _Smoothness);
|
||||
#endif
|
||||
|
||||
half3 normalTS = SampleNormalTS(uv, blendUv, TEXTURE2D_ARGS(_BumpMap, sampler_BumpMap), _BumpScale);
|
||||
|
||||
#if defined(_EMISSION)
|
||||
half3 emission = BlendTexture(TEXTURE2D_ARGS(_EmissionMap, sampler_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);
|
||||
outSurfaceData.alpha = albedo.a;
|
||||
|
||||
outSurfaceData.clearCoatMask = 0.0h;
|
||||
outSurfaceData.clearCoatSmoothness = 1.0h;
|
||||
}
|
||||
|
||||
inline void InitializeParticleLitSurfaceData(ParticleParams params, out SurfaceData outSurfaceData)
|
||||
{
|
||||
half4 albedo = SampleAlbedo(TEXTURE2D_ARGS(_BaseMap, sampler_BaseMap), params);
|
||||
|
||||
#if defined(_METALLICSPECGLOSSMAP)
|
||||
half2 metallicGloss = BlendTexture(TEXTURE2D_ARGS(_MetallicGlossMap, sampler_MetallicGlossMap), params.uv, params.blendUv).ra * half2(1.0, _Smoothness);
|
||||
#else
|
||||
half2 metallicGloss = half2(_Metallic, _Smoothness);
|
||||
#endif
|
||||
|
||||
half3 normalTS = SampleNormalTS(params.uv, params.blendUv, TEXTURE2D_ARGS(_BumpMap, sampler_BumpMap), _BumpScale);
|
||||
|
||||
#if defined(_EMISSION)
|
||||
half3 emission = BlendTexture(TEXTURE2D_ARGS(_EmissionMap, sampler_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 = 0.0h;
|
||||
outSurfaceData.clearCoatSmoothness = 1.0h;
|
||||
}
|
||||
|
||||
#endif // UNIVERSAL_PARTICLES_LIT_INPUT_INCLUDED
|
@@ -0,0 +1,277 @@
|
||||
// ------------------------------------------
|
||||
// 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" {}
|
||||
|
||||
[HideInInspector] _SmoothnessSource("Smoothness Source", Float) = 0.0
|
||||
[ToggleOff] _SpecularHighlights("Specular Highlights", Float) = 1.0
|
||||
_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", Float) = 0.5
|
||||
_DistortionStrength("Distortion Strength", Float) = 1.0
|
||||
|
||||
// -------------------------------------
|
||||
// Hidden properties - Generic
|
||||
[HideInInspector] _Surface("__surface", Float) = 0.0
|
||||
[HideInInspector] _Blend("__mode", Float) = 0.0
|
||||
[HideInInspector] _AlphaClip("__clip", Float) = 0.0
|
||||
[HideInInspector] _BlendOp("__blendop", Float) = 0.0
|
||||
[HideInInspector] _SrcBlend("__src", Float) = 1.0
|
||||
[HideInInspector] _DstBlend("__dst", Float) = 0.0
|
||||
[HideInInspector] _ZWrite("__zw", Float) = 1.0
|
||||
[HideInInspector] _Cull("__cull", Float) = 2.0
|
||||
|
||||
// Particle specific
|
||||
[HideInInspector] _ColorMode("_ColorMode", Float) = 0.0
|
||||
[HideInInspector] _BaseColorAddSubDiff("_ColorMode", Vector) = (0,0,0,0)
|
||||
[ToggleOff] _FlipbookBlending("__flipbookblending", Float) = 0.0
|
||||
[HideInInspector] _SoftParticlesEnabled("__softparticlesenabled", Float) = 0.0
|
||||
[HideInInspector] _CameraFadingEnabled("__camerafadingenabled", Float) = 0.0
|
||||
[HideInInspector] _SoftParticleFadeParams("__softparticlefadeparams", Vector) = (0,0,0,0)
|
||||
[HideInInspector] _CameraFadeParams("__camerafadeparams", Vector) = (0,0,0,0)
|
||||
[HideInInspector] _DistortionEnabled("__distortionenabled", Float) = 0.0
|
||||
[HideInInspector] _DistortionStrengthScaled("Distortion Strength Scaled", Float) = 0.1
|
||||
|
||||
// Editmode props
|
||||
[HideInInspector] _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)
|
||||
}
|
||||
|
||||
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"}
|
||||
|
||||
BlendOp[_BlendOp]
|
||||
Blend[_SrcBlend][_DstBlend]
|
||||
ZWrite[_ZWrite]
|
||||
Cull[_Cull]
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma target 2.0
|
||||
|
||||
// -------------------------------------
|
||||
// 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_local_fragment _ _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_local _SOFTPARTICLES_ON
|
||||
#pragma shader_feature_local _FADING_ON
|
||||
#pragma shader_feature_local _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
|
||||
|
||||
// -------------------------------------
|
||||
// Unity defined keywords
|
||||
#pragma multi_compile_fog
|
||||
#pragma multi_compile_instancing
|
||||
#pragma instancing_options procedural:ParticleInstancingSetup
|
||||
|
||||
#pragma vertex ParticlesLitVertex
|
||||
#pragma fragment ParticlesLitFragment
|
||||
#define BUMP_SCALE_NOT_SUPPORTED 1
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesSimpleLitInput.hlsl"
|
||||
#include "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"}
|
||||
|
||||
ZWrite[_ZWrite]
|
||||
Cull[_Cull]
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma exclude_renderers gles
|
||||
#pragma target 2.0
|
||||
|
||||
// -------------------------------------
|
||||
// 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
|
||||
#pragma multi_compile_fragment _ _GBUFFER_NORMALS_OCT
|
||||
|
||||
// -------------------------------------
|
||||
// Unity defined keywords
|
||||
#pragma multi_compile_instancing
|
||||
#pragma instancing_options procedural:ParticleInstancingSetup
|
||||
|
||||
#pragma vertex ParticlesLitGBufferVertex
|
||||
#pragma fragment ParticlesLitGBufferFragment
|
||||
#define BUMP_SCALE_NOT_SUPPORTED 1
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesSimpleLitInput.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesSimpleLitGBufferPass.hlsl"
|
||||
ENDHLSL
|
||||
}
|
||||
// ------------------------------------------------------------------
|
||||
// Scene view outline pass.
|
||||
Pass
|
||||
{
|
||||
Name "SceneSelectionPass"
|
||||
Tags { "LightMode" = "SceneSelectionPass" }
|
||||
|
||||
BlendOp Add
|
||||
Blend One Zero
|
||||
ZWrite On
|
||||
Cull Off
|
||||
|
||||
HLSLPROGRAM
|
||||
#define PARTICLES_EDITOR_META_PASS
|
||||
#pragma target 2.0
|
||||
|
||||
// -------------------------------------
|
||||
// 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
|
||||
|
||||
#pragma vertex vertParticleEditor
|
||||
#pragma fragment fragParticleSceneHighlight
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesSimpleLitInput.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesEditorPass.hlsl"
|
||||
|
||||
ENDHLSL
|
||||
}
|
||||
// ------------------------------------------------------------------
|
||||
// Scene picking buffer pass.
|
||||
Pass
|
||||
{
|
||||
Name "ScenePickingPass"
|
||||
Tags{ "LightMode" = "Picking" }
|
||||
|
||||
BlendOp Add
|
||||
Blend One Zero
|
||||
ZWrite On
|
||||
Cull Off
|
||||
|
||||
HLSLPROGRAM
|
||||
#define PARTICLES_EDITOR_META_PASS
|
||||
#pragma target 2.0
|
||||
|
||||
// -------------------------------------
|
||||
// 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
|
||||
|
||||
#pragma vertex vertParticleEditor
|
||||
#pragma fragment fragParticleScenePicking
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesSimpleLitInput.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesEditorPass.hlsl"
|
||||
|
||||
ENDHLSL
|
||||
}
|
||||
Pass
|
||||
{
|
||||
Name "Universal2D"
|
||||
Tags{ "LightMode" = "Universal2D" }
|
||||
|
||||
Blend[_SrcBlend][_DstBlend]
|
||||
ZWrite[_ZWrite]
|
||||
Cull[_Cull]
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma target 2.0
|
||||
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma shader_feature_local_fragment _ALPHATEST_ON
|
||||
#pragma shader_feature_local_fragment _ALPHAPREMULTIPLY_ON
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/UnlitInput.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,136 @@
|
||||
#ifndef UNIVERSAL_PARTICLES_FORWARD_SIMPLE_LIT_PASS_INCLUDED
|
||||
#define UNIVERSAL_PARTICLES_FORWARD_SIMPLE_LIT_PASS_INCLUDED
|
||||
|
||||
#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 output)
|
||||
{
|
||||
output = (InputData)0;
|
||||
|
||||
output.positionWS = input.positionWS.xyz;
|
||||
|
||||
#ifdef _NORMALMAP
|
||||
half3 viewDirWS = half3(input.normalWS.w, input.tangentWS.w, input.bitangentWS.w);
|
||||
output.normalWS = TransformTangentToWorld(normalTS,
|
||||
half3x3(input.tangentWS.xyz, input.bitangentWS.xyz, input.normalWS.xyz));
|
||||
#else
|
||||
half3 viewDirWS = input.viewDirWS;
|
||||
output.normalWS = input.normalWS;
|
||||
#endif
|
||||
|
||||
output.normalWS = NormalizeNormalPerPixel(output.normalWS);
|
||||
|
||||
#if SHADER_HINT_NICE_QUALITY
|
||||
viewDirWS = SafeNormalize(viewDirWS);
|
||||
#endif
|
||||
|
||||
output.viewDirectionWS = viewDirWS;
|
||||
|
||||
#if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
|
||||
output.shadowCoord = input.shadowCoord;
|
||||
#elif defined(MAIN_LIGHT_CALCULATE_SHADOWS)
|
||||
output.shadowCoord = TransformWorldToShadowCoord(output.positionWS);
|
||||
#else
|
||||
output.shadowCoord = float4(0, 0, 0, 0);
|
||||
#endif
|
||||
|
||||
output.fogCoord = (half)input.positionWS.w;
|
||||
output.vertexLighting = half3(0.0h, 0.0h, 0.0h);
|
||||
output.bakedGI = SampleSHPixel(input.vertexSH, output.normalWS);
|
||||
output.normalizedScreenSpaceUV = GetNormalizedScreenSpaceUV(input.clipPos);
|
||||
output.shadowMask = half4(1, 1, 1, 1);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// 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 = GetVertexPositionInputs(input.vertex.xyz);
|
||||
VertexNormalInputs normalInput = GetVertexNormalInputs(input.normal, input.tangent);
|
||||
|
||||
half3 viewDirWS = GetWorldSpaceViewDir(vertexInput.positionWS);
|
||||
#if !SHADER_HINT_NICE_QUALITY
|
||||
viewDirWS = SafeNormalize(viewDirWS);
|
||||
#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 = normalInput.normalWS;
|
||||
output.viewDirWS = viewDirWS;
|
||||
#endif
|
||||
|
||||
OUTPUT_SH(output.normalWS.xyz, output.vertexSH);
|
||||
|
||||
output.positionWS.xyz = vertexInput.positionWS.xyz;
|
||||
output.positionWS.w = ComputeFogFactor(vertexInput.positionCS.z);
|
||||
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, TEXTURE2D_ARGS(_BumpMap, sampler_BumpMap));
|
||||
half4 albedo = SampleAlbedo(TEXTURE2D_ARGS(_BaseMap, sampler_BaseMap), particleParams);
|
||||
half3 diffuse = AlphaModulate(albedo.rgb, albedo.a);
|
||||
half alpha = albedo.a;
|
||||
#if defined(_EMISSION)
|
||||
half3 emission = BlendTexture(TEXTURE2D_ARGS(_EmissionMap, sampler_EmissionMap), particleParams.uv, particleParams.blendUv) * _EmissionColor.rgb;
|
||||
#else
|
||||
half3 emission = half3(0, 0, 0);
|
||||
#endif
|
||||
half4 specularGloss = SampleSpecularSmoothness(particleParams.uv, particleParams.blendUv, albedo.a, _SpecColor, TEXTURE2D_ARGS(_SpecGlossMap, sampler_SpecGlossMap));
|
||||
half shininess = specularGloss.a;
|
||||
|
||||
#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, shininess, emission, alpha);
|
||||
color.rgb = MixFog(color.rgb, inputData.fogCoord);
|
||||
color.a = OutputAlpha(color.a, _Surface);
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
#endif // UNIVERSAL_PARTICLES_FORWARD_SIMPLE_LIT_PASS_INCLUDED
|
@@ -0,0 +1,149 @@
|
||||
#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/UnityGBuffer.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Particles.hlsl"
|
||||
|
||||
void InitializeInputData(VaryingsParticle input, half3 normalTS, out InputData output)
|
||||
{
|
||||
output = (InputData)0;
|
||||
|
||||
output.positionWS = input.positionWS.xyz;
|
||||
|
||||
#ifdef _NORMALMAP
|
||||
half3 viewDirWS = half3(input.normalWS.w, input.tangentWS.w, input.bitangentWS.w);
|
||||
output.normalWS = TransformTangentToWorld(normalTS,
|
||||
half3x3(input.tangentWS.xyz, input.bitangentWS.xyz, input.normalWS.xyz));
|
||||
#else
|
||||
half3 viewDirWS = input.viewDirWS;
|
||||
output.normalWS = input.normalWS;
|
||||
#endif
|
||||
|
||||
output.normalWS = NormalizeNormalPerPixel(output.normalWS);
|
||||
|
||||
#if SHADER_HINT_NICE_QUALITY
|
||||
viewDirWS = SafeNormalize(viewDirWS);
|
||||
#endif
|
||||
|
||||
output.viewDirectionWS = viewDirWS;
|
||||
|
||||
#if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
|
||||
output.shadowCoord = input.shadowCoord;
|
||||
#elif defined(MAIN_LIGHT_CALCULATE_SHADOWS)
|
||||
output.shadowCoord = TransformWorldToShadowCoord(output.positionWS);
|
||||
#else
|
||||
output.shadowCoord = float4(0, 0, 0, 0);
|
||||
#endif
|
||||
|
||||
output.fogCoord = 0; // not used for deferred shading
|
||||
output.vertexLighting = half3(0.0h, 0.0h, 0.0h);
|
||||
output.bakedGI = SampleSHPixel(input.vertexSH, output.normalWS);
|
||||
output.normalizedScreenSpaceUV = GetNormalizedScreenSpaceUV(input.clipPos);
|
||||
output.shadowMask = half4(1, 1, 1, 1);
|
||||
}
|
||||
|
||||
inline void InitializeParticleSimpleLitSurfaceData(VaryingsParticle input, out SurfaceData outSurfaceData)
|
||||
{
|
||||
outSurfaceData = (SurfaceData)0;
|
||||
|
||||
ParticleParams particleParams;
|
||||
InitParticleParams(input, particleParams);
|
||||
|
||||
outSurfaceData.normalTS = SampleNormalTS(particleParams.uv, particleParams.blendUv, TEXTURE2D_ARGS(_BumpMap, sampler_BumpMap));
|
||||
half4 albedo = SampleAlbedo(TEXTURE2D_ARGS(_BaseMap, sampler_BaseMap), particleParams);
|
||||
outSurfaceData.albedo = AlphaModulate(albedo.rgb, albedo.a);
|
||||
outSurfaceData.alpha = albedo.a;
|
||||
#if defined(_EMISSION)
|
||||
outSurfaceData.emission = BlendTexture(TEXTURE2D_ARGS(_EmissionMap, sampler_EmissionMap), particleParams.uv, particleParams.blendUv) * _EmissionColor.rgb;
|
||||
#else
|
||||
outSurfaceData.emission = half3(0, 0, 0);
|
||||
#endif
|
||||
half4 specularGloss = SampleSpecularSmoothness(particleParams.uv, particleParams.blendUv, albedo.a, _SpecColor, TEXTURE2D_ARGS(_SpecGlossMap, sampler_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; // unused
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// 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 = GetVertexPositionInputs(input.vertex.xyz);
|
||||
VertexNormalInputs normalInput = GetVertexNormalInputs(input.normal, input.tangent);
|
||||
|
||||
half3 viewDirWS = GetWorldSpaceViewDir(vertexInput.positionWS);
|
||||
#if !SHADER_HINT_NICE_QUALITY
|
||||
viewDirWS = SafeNormalize(viewDirWS);
|
||||
#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 = normalInput.normalWS;
|
||||
output.viewDirWS = viewDirWS;
|
||||
#endif
|
||||
|
||||
OUTPUT_SH(output.normalWS.xyz, output.vertexSH);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
FragmentOutput 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);
|
||||
|
||||
half4 color = half4(inputData.bakedGI * surfaceData.albedo + surfaceData.emission, surfaceData.alpha);
|
||||
|
||||
return SurfaceDataToGbuffer(surfaceData, inputData, color.rgb, kLightingSimpleLit);
|
||||
|
||||
}
|
||||
|
||||
#endif // UNIVERSAL_PARTICLES_GBUFFER_SIMPLE_LIT_PASS_INCLUDED
|
@@ -0,0 +1,96 @@
|
||||
#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"
|
||||
|
||||
// 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;
|
||||
half4 _BaseColor;
|
||||
half4 _EmissionColor;
|
||||
half4 _BaseColorAddSubDiff;
|
||||
half4 _SpecColor;
|
||||
half _Cutoff;
|
||||
half _Smoothness;
|
||||
half _DistortionStrengthScaled;
|
||||
half _DistortionBlend;
|
||||
half _Surface;
|
||||
CBUFFER_END
|
||||
|
||||
#include "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
|
||||
|
||||
half4 SampleAlbedo(float2 uv, float3 blendUv, half4 color, float4 particleColor, float4 projectedPosition, TEXTURE2D_PARAM(albedoMap, sampler_albedoMap))
|
||||
{
|
||||
half4 albedo = BlendTexture(TEXTURE2D_ARGS(albedoMap, sampler_albedoMap), uv, blendUv) * color;
|
||||
|
||||
half4 colorAddSubDiff = half4(0, 0, 0, 0);
|
||||
#if defined (_COLORADDSUBDIFF_ON)
|
||||
colorAddSubDiff = _BaseColorAddSubDiff;
|
||||
#endif
|
||||
albedo = MixParticleColor(albedo, particleColor, colorAddSubDiff);
|
||||
|
||||
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(TEXTURE2D_PARAM(albedoMap, sampler_albedoMap), ParticleParams params)
|
||||
{
|
||||
half4 albedo = BlendTexture(TEXTURE2D_ARGS(albedoMap, sampler_albedoMap), params.uv, params.blendUv) * params.baseColor;
|
||||
|
||||
half4 colorAddSubDiff = half4(0, 0, 0, 0);
|
||||
#if defined (_COLORADDSUBDIFF_ON)
|
||||
colorAddSubDiff = _BaseColorAddSubDiff;
|
||||
#endif
|
||||
albedo = MixParticleColor(albedo, params.vertexColor, colorAddSubDiff);
|
||||
|
||||
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, TEXTURE2D_PARAM(specGlossMap, sampler_specGlossMap))
|
||||
{
|
||||
half4 specularGloss = half4(0.0h, 0.0h, 0.0h, 1.0h);
|
||||
#ifdef _SPECGLOSSMAP
|
||||
specularGloss = BlendTexture(TEXTURE2D_ARGS(specGlossMap, sampler_specGlossMap), uv, blendUv);
|
||||
#elif defined(_SPECULAR_COLOR)
|
||||
specularGloss = specColor;
|
||||
#endif
|
||||
|
||||
#ifdef _GLOSSINESS_FROM_BASE_ALPHA
|
||||
specularGloss.a = alpha;
|
||||
#endif
|
||||
specularGloss.a = exp2(10 * specularGloss.a + 1);
|
||||
|
||||
return specularGloss;
|
||||
}
|
||||
|
||||
#endif // UNIVERSAL_PARTICLES_SIMPLE_LIT_INPUT_INCLUDED
|
@@ -0,0 +1,172 @@
|
||||
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", Float) = 0.5
|
||||
_DistortionStrength("Distortion Strength", Float) = 1.0
|
||||
|
||||
// -------------------------------------
|
||||
// Hidden properties - Generic
|
||||
[HideInInspector] _Surface("__surface", Float) = 0.0
|
||||
[HideInInspector] _Blend("__mode", Float) = 0.0
|
||||
[HideInInspector] _AlphaClip("__clip", Float) = 0.0
|
||||
[HideInInspector] _BlendOp("__blendop", Float) = 0.0
|
||||
[HideInInspector] _SrcBlend("__src", Float) = 1.0
|
||||
[HideInInspector] _DstBlend("__dst", Float) = 0.0
|
||||
[HideInInspector] _ZWrite("__zw", Float) = 1.0
|
||||
[HideInInspector] _Cull("__cull", Float) = 2.0
|
||||
// Particle specific
|
||||
[HideInInspector] _ColorMode("_ColorMode", Float) = 0.0
|
||||
[HideInInspector] _BaseColorAddSubDiff("_ColorMode", Vector) = (0,0,0,0)
|
||||
[ToggleOff] _FlipbookBlending("__flipbookblending", Float) = 0.0
|
||||
[HideInInspector] _SoftParticlesEnabled("__softparticlesenabled", Float) = 0.0
|
||||
[HideInInspector] _CameraFadingEnabled("__camerafadingenabled", Float) = 0.0
|
||||
[HideInInspector] _SoftParticleFadeParams("__softparticlefadeparams", Vector) = (0,0,0,0)
|
||||
[HideInInspector] _CameraFadeParams("__camerafadeparams", Vector) = (0,0,0,0)
|
||||
[HideInInspector] _DistortionEnabled("__distortionenabled", Float) = 0.0
|
||||
[HideInInspector] _DistortionStrengthScaled("Distortion Strength Scaled", Float) = 0.1
|
||||
|
||||
// Editmode props
|
||||
[HideInInspector] _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)
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
Tags{"RenderType" = "Opaque" "IgnoreProjector" = "True" "PreviewType" = "Plane" "PerformanceChecks" = "False" "RenderPipeline" = "UniversalPipeline"}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Forward pass.
|
||||
Pass
|
||||
{
|
||||
Name "ForwardLit"
|
||||
|
||||
BlendOp[_BlendOp]
|
||||
Blend[_SrcBlend][_DstBlend]
|
||||
ZWrite[_ZWrite]
|
||||
Cull[_Cull]
|
||||
ColorMask RGB
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma target 2.0
|
||||
|
||||
// -------------------------------------
|
||||
// Material Keywords
|
||||
#pragma shader_feature_local _NORMALMAP
|
||||
#pragma shader_feature_local_fragment _EMISSION
|
||||
|
||||
// -------------------------------------
|
||||
// Particle Keywords
|
||||
#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
|
||||
#pragma shader_feature_local _FLIPBOOKBLENDING_ON
|
||||
#pragma shader_feature_local _SOFTPARTICLES_ON
|
||||
#pragma shader_feature_local _FADING_ON
|
||||
#pragma shader_feature_local _DISTORTION_ON
|
||||
|
||||
// -------------------------------------
|
||||
// Unity defined keywords
|
||||
#pragma multi_compile_fog
|
||||
#pragma multi_compile_instancing
|
||||
#pragma instancing_options procedural:ParticleInstancingSetup
|
||||
|
||||
#pragma vertex vertParticleUnlit
|
||||
#pragma fragment fragParticleUnlit
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesUnlitInput.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesUnlitForwardPass.hlsl"
|
||||
|
||||
ENDHLSL
|
||||
}
|
||||
// ------------------------------------------------------------------
|
||||
// Scene view outline pass.
|
||||
Pass
|
||||
{
|
||||
Name "SceneSelectionPass"
|
||||
Tags { "LightMode" = "SceneSelectionPass" }
|
||||
|
||||
BlendOp Add
|
||||
Blend One Zero
|
||||
ZWrite On
|
||||
Cull Off
|
||||
|
||||
HLSLPROGRAM
|
||||
#define PARTICLES_EDITOR_META_PASS
|
||||
#pragma target 2.0
|
||||
|
||||
// -------------------------------------
|
||||
// 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
|
||||
|
||||
#pragma vertex vertParticleEditor
|
||||
#pragma fragment fragParticleSceneHighlight
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesUnlitInput.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesEditorPass.hlsl"
|
||||
|
||||
ENDHLSL
|
||||
}
|
||||
// ------------------------------------------------------------------
|
||||
// Scene picking buffer pass.
|
||||
Pass
|
||||
{
|
||||
Name "ScenePickingPass"
|
||||
Tags{ "LightMode" = "Picking" }
|
||||
|
||||
BlendOp Add
|
||||
Blend One Zero
|
||||
ZWrite On
|
||||
Cull Off
|
||||
|
||||
HLSLPROGRAM
|
||||
#define PARTICLES_EDITOR_META_PASS
|
||||
#pragma target 2.0
|
||||
|
||||
// -------------------------------------
|
||||
// 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
|
||||
|
||||
#pragma vertex vertParticleEditor
|
||||
#pragma fragment fragParticleScenePicking
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesUnlitInput.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesEditorPass.hlsl"
|
||||
|
||||
ENDHLSL
|
||||
}
|
||||
}
|
||||
CustomEditor "UnityEditor.Rendering.Universal.ShaderGUI.ParticlesUnlitShader"
|
||||
}
|
@@ -0,0 +1,118 @@
|
||||
#ifndef UNIVERSAL_PARTICLES_UNLIT_FORWARD_PASS_INCLUDED
|
||||
#define UNIVERSAL_PARTICLES_UNLIT_FORWARD_PASS_INCLUDED
|
||||
|
||||
#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 output)
|
||||
{
|
||||
output = (InputData)0;
|
||||
|
||||
output.positionWS = input.positionWS.xyz;
|
||||
|
||||
#ifdef _NORMALMAP
|
||||
half3 viewDirWS = half3(input.normalWS.w, input.tangentWS.w, input.bitangentWS.w);
|
||||
output.normalWS = TransformTangentToWorld(normalTS,
|
||||
half3x3(input.tangentWS.xyz, input.bitangentWS.xyz, input.normalWS.xyz));
|
||||
#else
|
||||
half3 viewDirWS = input.viewDirWS;
|
||||
output.normalWS = input.normalWS;
|
||||
#endif
|
||||
|
||||
output.normalWS = NormalizeNormalPerPixel(output.normalWS);
|
||||
|
||||
#if SHADER_HINT_NICE_QUALITY
|
||||
viewDirWS = SafeNormalize(viewDirWS);
|
||||
#endif
|
||||
|
||||
output.viewDirectionWS = viewDirWS;
|
||||
|
||||
output.fogCoord = (half)input.positionWS.w;
|
||||
output.vertexLighting = half3(0.0h, 0.0h, 0.0h);
|
||||
output.bakedGI = SampleSHPixel(input.vertexSH, output.normalWS);
|
||||
output.normalizedScreenSpaceUV = GetNormalizedScreenSpaceUV(input.clipPos);
|
||||
output.shadowMask = half4(1, 1, 1, 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 = GetVertexPositionInputs(input.vertex.xyz);
|
||||
VertexNormalInputs normalInput = GetVertexNormalInputs(input.normal, input.tangent);
|
||||
|
||||
// position ws is used to compute eye depth in vertFading
|
||||
output.positionWS.xyz = vertexInput.positionWS;
|
||||
output.positionWS.w = ComputeFogFactor(vertexInput.positionCS.z);
|
||||
output.clipPos = vertexInput.positionCS;
|
||||
output.color = GetParticleColor(input.color);
|
||||
|
||||
half3 viewDirWS = GetWorldSpaceViewDir(vertexInput.positionWS);
|
||||
#if !SHADER_HINT_NICE_QUALITY
|
||||
viewDirWS = SafeNormalize(viewDirWS);
|
||||
#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 = 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);
|
||||
|
||||
half4 albedo = SampleAlbedo(TEXTURE2D_ARGS(_BaseMap, sampler_BaseMap), particleParams);
|
||||
half3 normalTS = SampleNormalTS(particleParams.uv, particleParams.blendUv, TEXTURE2D_ARGS(_BumpMap, sampler_BumpMap));
|
||||
|
||||
#if defined (_DISTORTION_ON)
|
||||
albedo.rgb = Distortion(albedo, normalTS, _DistortionStrengthScaled, _DistortionBlend, particleParams.projectedPosition);
|
||||
#endif
|
||||
|
||||
#if defined(_EMISSION)
|
||||
half3 emission = BlendTexture(TEXTURE2D_ARGS(_EmissionMap, sampler_EmissionMap), particleParams.uv, particleParams.blendUv).rgb * _EmissionColor.rgb;
|
||||
#else
|
||||
half3 emission = half3(0, 0, 0);
|
||||
#endif
|
||||
|
||||
half3 result = albedo.rgb + emission;
|
||||
half fogFactor = input.positionWS.w;
|
||||
result = MixFog(result, fogFactor);
|
||||
albedo.a = OutputAlpha(albedo.a, _Surface);
|
||||
|
||||
return half4(result, albedo.a);
|
||||
}
|
||||
|
||||
#endif // UNIVERSAL_PARTICLES_UNLIT_FORWARD_PASS_INCLUDED
|
@@ -0,0 +1,82 @@
|
||||
#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"
|
||||
|
||||
// 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;
|
||||
half4 _BaseColor;
|
||||
half4 _EmissionColor;
|
||||
half4 _BaseColorAddSubDiff;
|
||||
half _Cutoff;
|
||||
half _DistortionStrengthScaled;
|
||||
half _DistortionBlend;
|
||||
half _Surface;
|
||||
CBUFFER_END
|
||||
|
||||
#include "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
|
||||
|
||||
half4 SampleAlbedo(float2 uv, float3 blendUv, half4 color, float4 particleColor, float4 projectedPosition, TEXTURE2D_PARAM(albedoMap, sampler_albedoMap))
|
||||
{
|
||||
half4 albedo = BlendTexture(TEXTURE2D_ARGS(albedoMap, sampler_albedoMap), uv, blendUv) * color;
|
||||
|
||||
// No distortion Support
|
||||
half4 colorAddSubDiff = half4(0, 0, 0, 0);
|
||||
#if defined (_COLORADDSUBDIFF_ON)
|
||||
colorAddSubDiff = _BaseColorAddSubDiff;
|
||||
#endif
|
||||
albedo = MixParticleColor(albedo, particleColor, colorAddSubDiff);
|
||||
|
||||
AlphaDiscard(albedo.a, _Cutoff);
|
||||
|
||||
|
||||
albedo.rgb = AlphaModulate(albedo.rgb, albedo.a);
|
||||
|
||||
#if defined(_SOFTPARTICLES_ON)
|
||||
albedo = SOFT_PARTICLE_MUL_ALBEDO(albedo, 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(TEXTURE2D_PARAM(albedoMap, sampler_albedoMap), ParticleParams params)
|
||||
{
|
||||
half4 albedo = BlendTexture(TEXTURE2D_ARGS(albedoMap, sampler_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, params.vertexColor, colorAddSubDiff);
|
||||
|
||||
AlphaDiscard(albedo.a, _Cutoff);
|
||||
albedo.rgb = AlphaModulate(albedo.rgb, albedo.a);
|
||||
|
||||
#if defined(_SOFTPARTICLES_ON)
|
||||
albedo = SOFT_PARTICLE_MUL_ALBEDO(albedo, 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
|
Reference in New Issue
Block a user