From 2ccde3ff30a39ed3a76d10e463343e9ad4cbdd86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elvar=20O=CC=88rn=20Unn=C3=BEo=CC=81rsson?= Date: Fri, 15 Jan 2021 22:28:44 +0100 Subject: [PATCH 1/6] Adding Depth & Depth Normals to Particle Shaders --- .../CHANGELOG.md | 3 + .../Particles/ParticlesDepthNormalsPass.hlsl | 93 +++++++++++++++++ .../ParticlesDepthNormalsPass.hlsl.meta | 9 ++ .../Particles/ParticlesDepthOnlyPass.hlsl | 63 ++++++++++++ .../ParticlesDepthOnlyPass.hlsl.meta | 9 ++ .../Shaders/Particles/ParticlesInput.hlsl | 53 ++++++++++ .../Shaders/Particles/ParticlesLit.shader | 62 ++++++++++++ .../Particles/ParticlesSimpleLit.shader | 62 ++++++++++++ .../Particles/ParticlesSimpleLitInput.hlsl | 2 + .../Shaders/Particles/ParticlesUnlit.shader | 99 +++++++++++++++++++ .../Particles/ParticlesUnlitInput.hlsl | 2 + 11 files changed, 457 insertions(+) create mode 100644 com.unity.render-pipelines.universal/Shaders/Particles/ParticlesDepthNormalsPass.hlsl create mode 100644 com.unity.render-pipelines.universal/Shaders/Particles/ParticlesDepthNormalsPass.hlsl.meta create mode 100644 com.unity.render-pipelines.universal/Shaders/Particles/ParticlesDepthOnlyPass.hlsl create mode 100644 com.unity.render-pipelines.universal/Shaders/Particles/ParticlesDepthOnlyPass.hlsl.meta diff --git a/com.unity.render-pipelines.universal/CHANGELOG.md b/com.unity.render-pipelines.universal/CHANGELOG.md index 733c05a94b3..9e1ff450ee6 100644 --- a/com.unity.render-pipelines.universal/CHANGELOG.md +++ b/com.unity.render-pipelines.universal/CHANGELOG.md @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [12.0.0] - 2021-01-11 +### Added +- Added Depth and DepthNormals passes to particles shaders. + ### Fixed - Fixed an issue where render scale was breaking SSAO in scene view. [case 1296710](https://issuetracker.unity3d.com/issues/ssao-effect-floating-in-the-air-in-scene-view-when-2-objects-with-shadergraph-materials-are-on-top-of-each-other) - Fixed GC allocations from XR occlusion mesh when using multipass. diff --git a/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesDepthNormalsPass.hlsl b/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesDepthNormalsPass.hlsl new file mode 100644 index 00000000000..8020c2a2261 --- /dev/null +++ b/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesDepthNormalsPass.hlsl @@ -0,0 +1,93 @@ +#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(AttributesParticle input) +{ + VaryingsDepthNormalsParticle output = (VaryingsDepthNormalsParticle)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 + + #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.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 + + return output; +} + +half4 DepthNormalsFragment(VaryingsDepthNormalsParticle input) : SV_TARGET +{ + UNITY_SETUP_INSTANCE_ID(input); + UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input); + + // Inputs... + float2 uv = input.texcoord; + #if defined(_FLIPBOOKBLENDING_ON) + float3 blendUv = input.texcoord2AndBlend; + #else + float3 blendUv = float3(0,0,0); + #endif + + // Check if we need to discard... + #if defined(_ALPHATEST_ON) + half4 vertexColor = input.color; + half4 baseColor = _BaseColor; + + half4 albedo = BlendTexture(TEXTURE2D_ARGS(_BaseMap, sampler_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, TEXTURE2D_ARGS(_BumpMap, sampler_BumpMap), _BumpScale); + float3 normalWS = TransformTangentToWorld(normalTS, half3x3(input.tangentWS.xyz, input.bitangentWS.xyz, input.normalWS.xyz)); + #else + float3 normalWS = input.normalWS; + #endif + + // Output... + #if defined(_GBUFFER_NORMALS_OCT) + float2 octNormalWS = PackNormalOctQuadEncode(normalWS); // values between [-1, +1], must use fp32 on Nintendo Switch. + float2 remappedOctNormalWS = saturate(octNormalWS * 0.5 + 0.5); // values between [ 0, 1] + half3 packedNormalWS = PackFloat2To888(remappedOctNormalWS); // values between [ 0, 1] + return half4(packedNormalWS, 0.0); + #else + return half4(NormalizeNormalPerPixel(normalWS), 0.0); + #endif +} + +#endif // UNIVERSAL_PARTICLES_LIT_DEPTH_NORMALS_PASS_INCLUDED diff --git a/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesDepthNormalsPass.hlsl.meta b/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesDepthNormalsPass.hlsl.meta new file mode 100644 index 00000000000..a6366493a4c --- /dev/null +++ b/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesDepthNormalsPass.hlsl.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 637c27b6fe6224a06b2b066769d0a6e6 +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesDepthOnlyPass.hlsl b/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesDepthOnlyPass.hlsl new file mode 100644 index 00000000000..4a48d8b5ab7 --- /dev/null +++ b/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesDepthOnlyPass.hlsl @@ -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 = GetVertexPositionInputs(input.vertex.xyz); + 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 + + + return output; +} + +half4 DepthOnlyFragment(VaryingsDepthOnlyParticle input) : SV_TARGET +{ + UNITY_SETUP_INSTANCE_ID(input); + UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input); + + // Inputs... + float2 uv = input.texcoord; + + // Check if we need to discard... + #if defined(_ALPHATEST_ON) + 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(TEXTURE2D_ARGS(_BaseMap, sampler_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_LIT_DEPTH_ONLY_PASS_INCLUDED diff --git a/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesDepthOnlyPass.hlsl.meta b/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesDepthOnlyPass.hlsl.meta new file mode 100644 index 00000000000..1b74d8cd2cd --- /dev/null +++ b/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesDepthOnlyPass.hlsl.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: e9795406c7fc049d2b125cce47405fa9 +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesInput.hlsl b/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesInput.hlsl index 9a0c738a14e..250667bcbff 100644 --- a/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesInput.hlsl +++ b/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesInput.hlsl @@ -59,4 +59,57 @@ struct VaryingsParticle UNITY_VERTEX_OUTPUT_STEREO }; +struct AttributesDepthOnlyParticle +{ + 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 + UNITY_VERTEX_INPUT_INSTANCE_ID +}; + +struct VaryingsDepthOnlyParticle +{ + float4 clipPos : SV_POSITION; + float2 texcoord : TEXCOORD0; + half4 color : COLOR; + + #if defined(_FLIPBOOKBLENDING_ON) + float3 texcoord2AndBlend : TEXCOORD5; + #endif + + UNITY_VERTEX_INPUT_INSTANCE_ID + UNITY_VERTEX_OUTPUT_STEREO +}; + +struct VaryingsDepthNormalsParticle +{ + float4 clipPos : SV_POSITION; + float2 texcoord : TEXCOORD0; + half4 color : COLOR; + + #if defined(_FLIPBOOKBLENDING_ON) + float3 texcoord2AndBlend : TEXCOORD5; + #endif + + #if !defined(PARTICLES_EDITOR_META_PASS) + #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 + #endif + + UNITY_VERTEX_INPUT_INSTANCE_ID + UNITY_VERTEX_OUTPUT_STEREO +}; + #endif // UNIVERSAL_PARTICLES_INPUT_INCLUDED diff --git a/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesLit.shader b/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesLit.shader index df6fbdb0c2b..e53f21427da 100644 --- a/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesLit.shader +++ b/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesLit.shader @@ -172,6 +172,68 @@ Shader "Universal Render Pipeline/Particles/Lit" ENDHLSL } // ------------------------------------------------------------------ + // Depth Only pass. + Pass + { + Name "DepthOnly" + Tags{"LightMode" = "DepthOnly"} + + ZWrite On + ColorMask 0 + Cull[_Cull] + + HLSLPROGRAM + #pragma target 2.0 + + // ------------------------------------- + // Unity defined keywords + #pragma multi_compile_instancing + #pragma instancing_options procedural:ParticleInstancingSetup + + #pragma vertex DepthOnlyVertex + #pragma fragment DepthOnlyFragment + + // ------------------------------------- + // Material Keywords + #pragma shader_feature_local_fragment _ALPHATEST_ON + #pragma shader_feature_local _FLIPBOOKBLENDING_ON + + #include "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesLitInput.hlsl" + #include "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesDepthOnlyPass.hlsl" + ENDHLSL + } + // This pass is used when drawing to a _CameraNormalsTexture texture + Pass + { + Name "DepthNormals" + Tags{"LightMode" = "DepthNormals"} + + ZWrite On + Cull[_Cull] + + HLSLPROGRAM + #pragma target 2.0 + + // ------------------------------------- + // Material Keywords + #pragma shader_feature_local _NORMALMAP + #pragma shader_feature_local _FLIPBOOKBLENDING_ON + #pragma shader_feature_local_fragment _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 + + #pragma vertex DepthNormalsVertex + #pragma fragment DepthNormalsFragment + + #include "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesLitInput.hlsl" + #include "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesDepthNormalsPass.hlsl" + ENDHLSL + } + // ------------------------------------------------------------------ // Scene view outline pass. Pass { diff --git a/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesSimpleLit.shader b/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesSimpleLit.shader index 3168371a197..c6437c1955e 100644 --- a/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesSimpleLit.shader +++ b/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesSimpleLit.shader @@ -182,6 +182,68 @@ Shader "Universal Render Pipeline/Particles/Simple Lit" ENDHLSL } // ------------------------------------------------------------------ + // Depth Only pass. + Pass + { + Name "DepthOnly" + Tags{"LightMode" = "DepthOnly"} + + ZWrite On + ColorMask 0 + Cull[_Cull] + + HLSLPROGRAM + #pragma target 2.0 + + // ------------------------------------- + // Unity defined keywords + #pragma multi_compile_instancing + #pragma instancing_options procedural:ParticleInstancingSetup + + #pragma vertex DepthOnlyVertex + #pragma fragment DepthOnlyFragment + + // ------------------------------------- + // Material Keywords + #pragma shader_feature_local_fragment _ALPHATEST_ON + #pragma shader_feature_local _FLIPBOOKBLENDING_ON + + #include "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesSimpleLitInput.hlsl" + #include "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesDepthOnlyPass.hlsl" + ENDHLSL + } + // This pass is used when drawing to a _CameraNormalsTexture texture + Pass + { + Name "DepthNormals" + Tags{"LightMode" = "DepthNormals"} + + ZWrite On + Cull[_Cull] + + HLSLPROGRAM + #pragma target 2.0 + + // ------------------------------------- + // Material Keywords + #pragma shader_feature_local _NORMALMAP + #pragma shader_feature_local _FLIPBOOKBLENDING_ON + #pragma shader_feature_local_fragment _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 + + #pragma vertex DepthNormalsVertex + #pragma fragment DepthNormalsFragment + + #include "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesSimpleLitInput.hlsl" + #include "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesDepthNormalsPass.hlsl" + ENDHLSL + } + // ------------------------------------------------------------------ // Scene view outline pass. Pass { diff --git a/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesSimpleLitInput.hlsl b/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesSimpleLitInput.hlsl index 99fa0ab8b27..8b2e1e39629 100644 --- a/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesSimpleLitInput.hlsl +++ b/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesSimpleLitInput.hlsl @@ -30,6 +30,8 @@ TEXTURE2D(_SpecGlossMap); SAMPLER(sampler_SpecGlossMap); #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, TEXTURE2D_PARAM(albedoMap, sampler_albedoMap)) { half4 albedo = BlendTexture(TEXTURE2D_ARGS(albedoMap, sampler_albedoMap), uv, blendUv) * color; diff --git a/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesUnlit.shader b/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesUnlit.shader index f17f7dbd8ef..4344dc064d4 100644 --- a/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesUnlit.shader +++ b/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesUnlit.shader @@ -100,6 +100,105 @@ Shader "Universal Render Pipeline/Particles/Unlit" ENDHLSL } // ------------------------------------------------------------------ + // Depth Only pass. + Pass + { + Name "DepthOnly" + Tags{"LightMode" = "DepthOnly"} + + ZWrite On + ColorMask 0 + Cull[_Cull] + + HLSLPROGRAM + #pragma target 2.0 + + // ------------------------------------- + // Unity defined keywords + #pragma multi_compile_instancing + #pragma instancing_options procedural:ParticleInstancingSetup + + #pragma vertex DepthOnlyVertex + #pragma fragment DepthOnlyFragment + + // ------------------------------------- + // Material Keywords + #pragma shader_feature_local_fragment _ALPHATEST_ON + #pragma shader_feature_local _FLIPBOOKBLENDING_ON + + #include "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesUnlitInput.hlsl" + #include "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesDepthOnlyPass.hlsl" + ENDHLSL + } + // This pass is used when drawing to a _CameraNormalsTexture texture + Pass + { + Name "DepthNormals" + Tags{"LightMode" = "DepthNormals"} + + ZWrite On + Cull[_Cull] + + HLSLPROGRAM + #pragma target 2.0 + + // ------------------------------------- + // Material Keywords + #pragma shader_feature_local _NORMALMAP + #pragma shader_feature_local _FLIPBOOKBLENDING_ON + #pragma shader_feature_local_fragment _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 + + #pragma vertex DepthNormalsVertex + #pragma fragment DepthNormalsFragment + + #include "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesUnlitInput.hlsl" + #include "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesDepthNormalsPass.hlsl" + ENDHLSL + } + // Same as DepthNormals pass, but used for deferred renderer and forwardOnly materials. + Pass + { + Name "DepthNormalsOnly" + Tags{"LightMode" = "DepthNormalsOnly"} + + ZWrite On + Cull[_Cull] + + HLSLPROGRAM + #pragma exclude_renderers gles gles3 glcore + #pragma target 4.5 + + #pragma vertex DepthNormalsVertex + #pragma fragment DepthNormalsFragment + + // ------------------------------------- + // Material Keywords + #pragma shader_feature_local _NORMALMAP + #pragma shader_feature_local _PARALLAXMAP + #pragma shader_feature_local _ _DETAIL_MULX2 _DETAIL_SCALED + #pragma shader_feature_local_fragment _ALPHATEST_ON + #pragma shader_feature_local_fragment _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A + + // ------------------------------------- + // Unity defined keywords + #pragma multi_compile_fragment _ _GBUFFER_NORMALS_OCT // forward-only variant + + //-------------------------------------- + // GPU Instancing + #pragma multi_compile_instancing + #pragma multi_compile _ DOTS_INSTANCING_ON + + #include "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 { diff --git a/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesUnlitInput.hlsl b/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesUnlitInput.hlsl index efd906dbdb4..23541de9652 100644 --- a/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesUnlitInput.hlsl +++ b/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesUnlitInput.hlsl @@ -26,6 +26,8 @@ CBUFFER_END #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, TEXTURE2D_PARAM(albedoMap, sampler_albedoMap)) { half4 albedo = BlendTexture(TEXTURE2D_ARGS(albedoMap, sampler_albedoMap), uv, blendUv) * color; From 2fab2c0dd05cd25e032a99ea193ae7ad5d378334 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elvar=20O=CC=88rn=20Unn=C3=BEo=CC=81rsson?= Date: Mon, 18 Jan 2021 16:38:39 +0100 Subject: [PATCH 2/6] Changes based on comments --- .../Particles/ParticlesDepthNormalsPass.hlsl | 37 +++++---- .../Particles/ParticlesDepthOnlyPass.hlsl | 22 +++--- .../Shaders/Particles/ParticlesInput.hlsl | 78 +++++++++++++------ .../Shaders/Particles/ParticlesLit.shader | 17 ++-- .../Particles/ParticlesSimpleLit.shader | 12 +-- .../Shaders/Particles/ParticlesUnlit.shader | 14 ++-- 6 files changed, 111 insertions(+), 69 deletions(-) diff --git a/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesDepthNormalsPass.hlsl b/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesDepthNormalsPass.hlsl index 8020c2a2261..bed886bd0b7 100644 --- a/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesDepthNormalsPass.hlsl +++ b/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesDepthNormalsPass.hlsl @@ -3,7 +3,7 @@ #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" -VaryingsDepthNormalsParticle DepthNormalsVertex(AttributesParticle input) +VaryingsDepthNormalsParticle DepthNormalsVertex(AttributesDepthNormalsParticle input) { VaryingsDepthNormalsParticle output = (VaryingsDepthNormalsParticle)0; UNITY_SETUP_INSTANCE_ID(input); @@ -18,7 +18,7 @@ VaryingsDepthNormalsParticle DepthNormalsVertex(AttributesParticle input) viewDirWS = SafeNormalize(viewDirWS); #endif - #ifdef _NORMALMAP + #if defined(_NORMALMAP) output.normalWS = half4(normalInput.normalWS, viewDirWS.x); output.tangentWS = half4(normalInput.tangentWS, viewDirWS.y); output.bitangentWS = half4(normalInput.bitangentWS, viewDirWS.z); @@ -28,16 +28,21 @@ VaryingsDepthNormalsParticle DepthNormalsVertex(AttributesParticle input) #endif 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); + #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, output.texcoord2AndBlend, input.texcoords, input.texcoordBlend); + GetParticleTexcoords(output.texcoord, input.texcoords.xy); #endif - #else - GetParticleTexcoords(output.texcoord, input.texcoords.xy); #endif return output; @@ -49,21 +54,23 @@ half4 DepthNormalsFragment(VaryingsDepthNormalsParticle input) : SV_TARGET UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input); // Inputs... - float2 uv = input.texcoord; - #if defined(_FLIPBOOKBLENDING_ON) - float3 blendUv = input.texcoord2AndBlend; - #else + #if defined(_ALPHATEST_ON) || defined(_NORMALMAP) + float2 uv = input.texcoord; float3 blendUv = float3(0,0,0); + + #if defined(_FLIPBOOKBLENDING_ON) + float3 blendUv = input.texcoord2AndBlend; + #endif #endif // Check if we need to discard... #if defined(_ALPHATEST_ON) half4 vertexColor = input.color; half4 baseColor = _BaseColor; - half4 albedo = BlendTexture(TEXTURE2D_ARGS(_BaseMap, sampler_BaseMap), uv, blendUv) * baseColor; + half4 colorAddSubDiff = half4(0, 0, 0, 0); - #if defined (_COLORADDSUBDIFF_ON) + #if defined(_COLORADDSUBDIFF_ON) colorAddSubDiff = _BaseColorAddSubDiff; #endif diff --git a/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesDepthOnlyPass.hlsl b/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesDepthOnlyPass.hlsl index 4a48d8b5ab7..548e095990c 100644 --- a/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesDepthOnlyPass.hlsl +++ b/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesDepthOnlyPass.hlsl @@ -12,19 +12,21 @@ VaryingsDepthOnlyParticle DepthOnlyVertex(AttributesDepthOnlyParticle input) VertexPositionInputs vertexInput = GetVertexPositionInputs(input.vertex.xyz); 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); + #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, output.texcoord2AndBlend, input.texcoords, input.texcoordBlend); + GetParticleTexcoords(output.texcoord, input.texcoords.xy); #endif - #else - GetParticleTexcoords(output.texcoord, input.texcoords.xy); #endif - return output; } @@ -33,11 +35,9 @@ half4 DepthOnlyFragment(VaryingsDepthOnlyParticle input) : SV_TARGET UNITY_SETUP_INSTANCE_ID(input); UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input); - // Inputs... - float2 uv = input.texcoord; - // Check if we need to discard... #if defined(_ALPHATEST_ON) + float2 uv = input.texcoord; half4 vertexColor = input.color; half4 baseColor = _BaseColor; diff --git a/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesInput.hlsl b/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesInput.hlsl index 250667bcbff..dd20240dd44 100644 --- a/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesInput.hlsl +++ b/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesInput.hlsl @@ -62,13 +62,16 @@ struct VaryingsParticle struct AttributesDepthOnlyParticle { 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; + #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 }; @@ -76,38 +79,69 @@ struct AttributesDepthOnlyParticle struct VaryingsDepthOnlyParticle { float4 clipPos : SV_POSITION; - float2 texcoord : TEXCOORD0; - half4 color : COLOR; - #if defined(_FLIPBOOKBLENDING_ON) - float3 texcoord2AndBlend : TEXCOORD5; + #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; - float2 texcoord : TEXCOORD0; - half4 color : COLOR; - #if defined(_FLIPBOOKBLENDING_ON) - float3 texcoord2AndBlend : TEXCOORD5; + #if defined(_ALPHATEST_ON) + half4 color : COLOR; #endif - #if !defined(PARTICLES_EDITOR_META_PASS) - #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; + #if defined(_ALPHATEST_ON) || defined(_NORMALMAP) + 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 }; diff --git a/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesLit.shader b/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesLit.shader index e53f21427da..560def72941 100644 --- a/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesLit.shader +++ b/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesLit.shader @@ -91,7 +91,7 @@ Shader "Universal Render Pipeline/Particles/Lit" // ------------------------------------- // Particle Keywords #pragma shader_feature_local_fragment _ _ALPHAPREMULTIPLY_ON _ALPHAMODULATE_ON - #pragma shader_feature_local_fragment _ALPHATEST_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 @@ -185,6 +185,11 @@ Shader "Universal Render Pipeline/Particles/Lit" HLSLPROGRAM #pragma target 2.0 + // ------------------------------------- + // Material Keywords + #pragma shader_feature_local _ _ALPHATEST_ON + #pragma shader_feature_local _FLIPBOOKBLENDING_ON + // ------------------------------------- // Unity defined keywords #pragma multi_compile_instancing @@ -193,10 +198,6 @@ Shader "Universal Render Pipeline/Particles/Lit" #pragma vertex DepthOnlyVertex #pragma fragment DepthOnlyFragment - // ------------------------------------- - // Material Keywords - #pragma shader_feature_local_fragment _ALPHATEST_ON - #pragma shader_feature_local _FLIPBOOKBLENDING_ON #include "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesLitInput.hlsl" #include "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesDepthOnlyPass.hlsl" @@ -216,9 +217,9 @@ Shader "Universal Render Pipeline/Particles/Lit" // ------------------------------------- // Material Keywords - #pragma shader_feature_local _NORMALMAP - #pragma shader_feature_local _FLIPBOOKBLENDING_ON - #pragma shader_feature_local_fragment _ALPHATEST_ON + #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 // ------------------------------------- diff --git a/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesSimpleLit.shader b/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesSimpleLit.shader index c6437c1955e..782e441ed38 100644 --- a/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesSimpleLit.shader +++ b/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesSimpleLit.shader @@ -195,6 +195,11 @@ Shader "Universal Render Pipeline/Particles/Simple Lit" HLSLPROGRAM #pragma target 2.0 + // ------------------------------------- + // Material Keywords + #pragma shader_feature_local _ _ALPHATEST_ON + #pragma shader_feature_local _ _FLIPBOOKBLENDING_ON + // ------------------------------------- // Unity defined keywords #pragma multi_compile_instancing @@ -203,11 +208,6 @@ Shader "Universal Render Pipeline/Particles/Simple Lit" #pragma vertex DepthOnlyVertex #pragma fragment DepthOnlyFragment - // ------------------------------------- - // Material Keywords - #pragma shader_feature_local_fragment _ALPHATEST_ON - #pragma shader_feature_local _FLIPBOOKBLENDING_ON - #include "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesSimpleLitInput.hlsl" #include "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesDepthOnlyPass.hlsl" ENDHLSL @@ -228,7 +228,7 @@ Shader "Universal Render Pipeline/Particles/Simple Lit" // Material Keywords #pragma shader_feature_local _NORMALMAP #pragma shader_feature_local _FLIPBOOKBLENDING_ON - #pragma shader_feature_local_fragment _ALPHATEST_ON + #pragma shader_feature_local _ALPHATEST_ON #pragma shader_feature_local_fragment _ _COLOROVERLAY_ON _COLORCOLOR_ON _COLORADDSUBDIFF_ON // ------------------------------------- diff --git a/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesUnlit.shader b/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesUnlit.shader index 4344dc064d4..d0555e9f863 100644 --- a/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesUnlit.shader +++ b/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesUnlit.shader @@ -113,6 +113,11 @@ Shader "Universal Render Pipeline/Particles/Unlit" HLSLPROGRAM #pragma target 2.0 + // ------------------------------------- + // Material Keywords + #pragma shader_feature_local _ALPHATEST_ON + #pragma shader_feature_local _FLIPBOOKBLENDING_ON + // ------------------------------------- // Unity defined keywords #pragma multi_compile_instancing @@ -121,11 +126,6 @@ Shader "Universal Render Pipeline/Particles/Unlit" #pragma vertex DepthOnlyVertex #pragma fragment DepthOnlyFragment - // ------------------------------------- - // Material Keywords - #pragma shader_feature_local_fragment _ALPHATEST_ON - #pragma shader_feature_local _FLIPBOOKBLENDING_ON - #include "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesUnlitInput.hlsl" #include "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesDepthOnlyPass.hlsl" ENDHLSL @@ -146,7 +146,7 @@ Shader "Universal Render Pipeline/Particles/Unlit" // Material Keywords #pragma shader_feature_local _NORMALMAP #pragma shader_feature_local _FLIPBOOKBLENDING_ON - #pragma shader_feature_local_fragment _ALPHATEST_ON + #pragma shader_feature_local _ALPHATEST_ON #pragma shader_feature_local_fragment _ _COLOROVERLAY_ON _COLORCOLOR_ON _COLORADDSUBDIFF_ON // ------------------------------------- @@ -182,7 +182,7 @@ Shader "Universal Render Pipeline/Particles/Unlit" #pragma shader_feature_local _NORMALMAP #pragma shader_feature_local _PARALLAXMAP #pragma shader_feature_local _ _DETAIL_MULX2 _DETAIL_SCALED - #pragma shader_feature_local_fragment _ALPHATEST_ON + #pragma shader_feature_local _ALPHATEST_ON #pragma shader_feature_local_fragment _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A // ------------------------------------- From c20d8adcdf9a6c989276a0cd65b100ba100c510e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elvar=20O=CC=88rn=20Unn=C3=BEo=CC=81rsson?= Date: Mon, 18 Jan 2021 16:43:37 +0100 Subject: [PATCH 3/6] Minor tweak --- .../Shaders/Particles/ParticlesInput.hlsl | 52 +++++++++---------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesInput.hlsl b/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesInput.hlsl index dd20240dd44..5004c8f6b8f 100644 --- a/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesInput.hlsl +++ b/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesInput.hlsl @@ -5,19 +5,19 @@ struct AttributesParticle { - float4 vertex : POSITION; - half4 color : COLOR; + float4 vertex : POSITION; + half4 color : COLOR; #if defined(_FLIPBOOKBLENDING_ON) && !defined(UNITY_PARTICLE_INSTANCING_ENABLED) - float4 texcoords : TEXCOORD0; - float texcoordBlend : TEXCOORD1; + float4 texcoords : TEXCOORD0; + float texcoordBlend : TEXCOORD1; #else - float2 texcoords : TEXCOORD0; + float2 texcoords : TEXCOORD0; #endif #if !defined(PARTICLES_EDITOR_META_PASS) - float3 normal : NORMAL; - float4 tangent : TANGENT; + float3 normal : NORMAL; + float4 tangent : TANGENT; #endif UNITY_VERTEX_INPUT_INSTANCE_ID }; @@ -61,16 +61,16 @@ struct VaryingsParticle struct AttributesDepthOnlyParticle { - float4 vertex : POSITION; + float4 vertex : POSITION; #if defined(_ALPHATEST_ON) - half4 color : COLOR; + half4 color : COLOR; #if defined(_FLIPBOOKBLENDING_ON) && !defined(UNITY_PARTICLE_INSTANCING_ENABLED) - float4 texcoords : TEXCOORD0; - float texcoordBlend : TEXCOORD1; + float4 texcoords : TEXCOORD0; + float texcoordBlend : TEXCOORD1; #else - float2 texcoords : TEXCOORD0; + float2 texcoords : TEXCOORD0; #endif #endif UNITY_VERTEX_INPUT_INSTANCE_ID @@ -78,7 +78,7 @@ struct AttributesDepthOnlyParticle struct VaryingsDepthOnlyParticle { - float4 clipPos : SV_POSITION; + float4 clipPos : SV_POSITION; #if defined(_ALPHATEST_ON) float2 texcoord : TEXCOORD0; @@ -95,23 +95,23 @@ struct VaryingsDepthOnlyParticle struct AttributesDepthNormalsParticle { - float4 vertex : POSITION; + float4 vertex : POSITION; #if defined(_ALPHATEST_ON) - half4 color : COLOR; + 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; + float4 texcoords : TEXCOORD0; + float texcoordBlend : TEXCOORD1; #else - float2 texcoords : TEXCOORD0; + float2 texcoords : TEXCOORD0; #endif #endif - float3 normal : NORMAL; - float4 tangent : TANGENT; + float3 normal : NORMAL; + float4 tangent : TANGENT; UNITY_VERTEX_INPUT_INSTANCE_ID }; @@ -119,7 +119,7 @@ struct AttributesDepthNormalsParticle struct VaryingsDepthNormalsParticle { - float4 clipPos : SV_POSITION; + float4 clipPos : SV_POSITION; #if defined(_ALPHATEST_ON) half4 color : COLOR; @@ -134,12 +134,12 @@ struct VaryingsDepthNormalsParticle #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 + 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; + float3 normalWS : TEXCOORD2; + float3 viewDirWS : TEXCOORD3; #endif UNITY_VERTEX_INPUT_INSTANCE_ID From db598f8397a63edd9a9cd5e2278c0954677a1e4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elvar=20O=CC=88rn=20Unn=C3=BEo=CC=81rsson?= Date: Mon, 18 Jan 2021 16:46:41 +0100 Subject: [PATCH 4/6] More minor tweaks --- .../Shaders/Particles/ParticlesLit.shader | 2 +- .../Shaders/Particles/ParticlesSimpleLit.shader | 6 +++--- .../Shaders/Particles/ParticlesUnlit.shader | 16 ++++++++-------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesLit.shader b/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesLit.shader index 560def72941..9bf58d87009 100644 --- a/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesLit.shader +++ b/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesLit.shader @@ -188,7 +188,7 @@ Shader "Universal Render Pipeline/Particles/Lit" // ------------------------------------- // Material Keywords #pragma shader_feature_local _ _ALPHATEST_ON - #pragma shader_feature_local _FLIPBOOKBLENDING_ON + #pragma shader_feature_local _ _FLIPBOOKBLENDING_ON // ------------------------------------- // Unity defined keywords diff --git a/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesSimpleLit.shader b/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesSimpleLit.shader index 782e441ed38..667738865a8 100644 --- a/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesSimpleLit.shader +++ b/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesSimpleLit.shader @@ -226,9 +226,9 @@ Shader "Universal Render Pipeline/Particles/Simple Lit" // ------------------------------------- // Material Keywords - #pragma shader_feature_local _NORMALMAP - #pragma shader_feature_local _FLIPBOOKBLENDING_ON - #pragma shader_feature_local _ALPHATEST_ON + #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 // ------------------------------------- diff --git a/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesUnlit.shader b/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesUnlit.shader index d0555e9f863..9a9d603a773 100644 --- a/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesUnlit.shader +++ b/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesUnlit.shader @@ -115,8 +115,8 @@ Shader "Universal Render Pipeline/Particles/Unlit" // ------------------------------------- // Material Keywords - #pragma shader_feature_local _ALPHATEST_ON - #pragma shader_feature_local _FLIPBOOKBLENDING_ON + #pragma shader_feature_local _ _ALPHATEST_ON + #pragma shader_feature_local _ _FLIPBOOKBLENDING_ON // ------------------------------------- // Unity defined keywords @@ -144,9 +144,9 @@ Shader "Universal Render Pipeline/Particles/Unlit" // ------------------------------------- // Material Keywords - #pragma shader_feature_local _NORMALMAP - #pragma shader_feature_local _FLIPBOOKBLENDING_ON - #pragma shader_feature_local _ALPHATEST_ON + #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 // ------------------------------------- @@ -179,10 +179,10 @@ Shader "Universal Render Pipeline/Particles/Unlit" // ------------------------------------- // Material Keywords - #pragma shader_feature_local _NORMALMAP - #pragma shader_feature_local _PARALLAXMAP + #pragma shader_feature_local _ _NORMALMAP + #pragma shader_feature_local _ _PARALLAXMAP #pragma shader_feature_local _ _DETAIL_MULX2 _DETAIL_SCALED - #pragma shader_feature_local _ALPHATEST_ON + #pragma shader_feature_local _ _ALPHATEST_ON #pragma shader_feature_local_fragment _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A // ------------------------------------- From fd88e0e194955dc63e22473220304ae8906c240d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elvar=20O=CC=88rn=20Unn=C3=BEo=CC=81rsson?= Date: Tue, 19 Jan 2021 10:50:03 +0100 Subject: [PATCH 5/6] Fixing some keywords in the particle shaders --- .../Shaders/Particles/ParticlesLit.shader | 2 +- .../Shaders/Particles/ParticlesSimpleLit.shader | 1 + .../Shaders/Particles/ParticlesUnlit.shader | 5 ++--- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesLit.shader b/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesLit.shader index 9bf58d87009..209d5f26333 100644 --- a/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesLit.shader +++ b/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesLit.shader @@ -189,6 +189,7 @@ Shader "Universal Render Pipeline/Particles/Lit" // 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 @@ -198,7 +199,6 @@ Shader "Universal Render Pipeline/Particles/Lit" #pragma vertex DepthOnlyVertex #pragma fragment DepthOnlyFragment - #include "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesLitInput.hlsl" #include "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesDepthOnlyPass.hlsl" ENDHLSL diff --git a/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesSimpleLit.shader b/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesSimpleLit.shader index 667738865a8..de9620fd213 100644 --- a/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesSimpleLit.shader +++ b/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesSimpleLit.shader @@ -199,6 +199,7 @@ Shader "Universal Render Pipeline/Particles/Simple Lit" // 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 diff --git a/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesUnlit.shader b/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesUnlit.shader index 9a9d603a773..4109b1dd621 100644 --- a/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesUnlit.shader +++ b/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesUnlit.shader @@ -117,6 +117,7 @@ Shader "Universal Render Pipeline/Particles/Unlit" // 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 @@ -180,10 +181,8 @@ Shader "Universal Render Pipeline/Particles/Unlit" // ------------------------------------- // Material Keywords #pragma shader_feature_local _ _NORMALMAP - #pragma shader_feature_local _ _PARALLAXMAP - #pragma shader_feature_local _ _DETAIL_MULX2 _DETAIL_SCALED #pragma shader_feature_local _ _ALPHATEST_ON - #pragma shader_feature_local_fragment _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A + #pragma shader_feature_local_fragment _ _COLOROVERLAY_ON _COLORCOLOR_ON _COLORADDSUBDIFF_ON // ------------------------------------- // Unity defined keywords From 7a76e4ca4404497e57a41dcd9997120a1d7bda47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elvar=20O=CC=88rn=20Unn=C3=BEo=CC=81rsson?= Date: Tue, 19 Jan 2021 11:21:23 +0100 Subject: [PATCH 6/6] Fixing a shader error with redefinition of variable [Cancel Old CI] --- .../Shaders/Particles/ParticlesDepthNormalsPass.hlsl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesDepthNormalsPass.hlsl b/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesDepthNormalsPass.hlsl index bed886bd0b7..3d68e460889 100644 --- a/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesDepthNormalsPass.hlsl +++ b/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesDepthNormalsPass.hlsl @@ -56,10 +56,11 @@ half4 DepthNormalsFragment(VaryingsDepthNormalsParticle input) : SV_TARGET // Inputs... #if defined(_ALPHATEST_ON) || defined(_NORMALMAP) float2 uv = input.texcoord; - float3 blendUv = float3(0,0,0); #if defined(_FLIPBOOKBLENDING_ON) float3 blendUv = input.texcoord2AndBlend; + #else + float3 blendUv = float3(0,0,0); #endif #endif