Skip to content

Commit 35273a9

Browse files
authored
2021.2/universal/case 1379188 particle unlit blend (#6840)
* Remove duplica alpha multiplies. * Fix alpha modulate. * Update changelog. * Remove autogenerated text in changelog.
1 parent 0166435 commit 35273a9

File tree

5 files changed

+9
-11
lines changed

5 files changed

+9
-11
lines changed

com.unity.render-pipelines.universal/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
99
### Changed
1010
- Re-added the menu button to be able to convert selected materials.
1111

12-
1312
### Fixed
13+
- Fixed incorrect blending of ParticleUnlit. [case 1373188](https://issuetracker.unity3d.com/product/unity/issues/guid/1373188/)
1414
- Fixed max light count cpu/gpu mismatch in Editor with Android target. [case 1392965](https://issuetracker.unity3d.com/product/unity/issues/guid/1392965/)
1515

1616
## [12.1.4] - 2021-12-07

com.unity.render-pipelines.universal/Editor/ShaderGUI/BaseShaderGUI.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -600,14 +600,16 @@ internal static void SetupMaterialBlendModeInternal(Material material, out int a
600600
{
601601
BlendMode blendMode = (BlendMode)material.GetFloat(Property.BlendMode);
602602

603+
material.DisableKeyword(ShaderKeywordStrings._ALPHAPREMULTIPLY_ON);
604+
material.DisableKeyword(ShaderKeywordStrings._ALPHAMODULATE_ON);
605+
603606
// Specific Transparent Mode Settings
604607
switch (blendMode)
605608
{
606609
case BlendMode.Alpha:
607610
SetMaterialSrcDstBlendProperties(material,
608611
UnityEngine.Rendering.BlendMode.SrcAlpha,
609612
UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha);
610-
material.DisableKeyword(ShaderKeywordStrings._ALPHAPREMULTIPLY_ON);
611613
break;
612614
case BlendMode.Premultiply:
613615
SetMaterialSrcDstBlendProperties(material,
@@ -619,13 +621,11 @@ internal static void SetupMaterialBlendModeInternal(Material material, out int a
619621
SetMaterialSrcDstBlendProperties(material,
620622
UnityEngine.Rendering.BlendMode.SrcAlpha,
621623
UnityEngine.Rendering.BlendMode.One);
622-
material.DisableKeyword(ShaderKeywordStrings._ALPHAPREMULTIPLY_ON);
623624
break;
624625
case BlendMode.Multiply:
625626
SetMaterialSrcDstBlendProperties(material,
626627
UnityEngine.Rendering.BlendMode.DstColor,
627628
UnityEngine.Rendering.BlendMode.Zero);
628-
material.DisableKeyword(ShaderKeywordStrings._ALPHAPREMULTIPLY_ON);
629629
material.EnableKeyword(ShaderKeywordStrings._ALPHAMODULATE_ON);
630630
break;
631631
}

com.unity.render-pipelines.universal/ShaderLibrary/Unlit.hlsl

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@ half4 UniversalFragmentUnlit(InputData inputData, SurfaceData surfaceData)
1010
{
1111
half3 albedo = surfaceData.albedo;
1212

13-
#if defined(_ALPHAPREMULTIPLY_ON)
14-
albedo *= surfaceData.alpha;
15-
#endif
16-
1713
#if defined(DEBUG_DISPLAY)
1814
half4 debugColor;
1915

com.unity.render-pipelines.universal/Shaders/Particles/ParticlesUnlitForwardPass.hlsl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,13 @@ void InitializeSurfaceData(ParticleParams particleParams, out SurfaceData surfac
5555
const half3 emission = 0;
5656
#endif
5757

58-
surfaceData.albedo = albedo.rgb;
58+
surfaceData.albedo = albedo.rgb; // NOTE: Pre-multiplied and modulated in SampleAlbedo().
5959
surfaceData.specular = 0;
6060
surfaceData.normalTS = normalTS;
6161
surfaceData.emission = emission;
6262
surfaceData.metallic = 0;
6363
surfaceData.smoothness = 1;
6464
surfaceData.occlusion = 1;
65-
66-
surfaceData.albedo = AlphaModulate(surfaceData.albedo, albedo.a);
6765
surfaceData.alpha = albedo.a;
6866

6967
surfaceData.clearCoatMask = 0;

com.unity.render-pipelines.universal/Shaders/UnlitForwardPass.hlsl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@ half4 UnlitPassFragment(Varyings input) : SV_Target
101101

102102
AlphaDiscard(alpha, _Cutoff);
103103

104+
#if defined(_ALPHAPREMULTIPLY_ON)
105+
color *= alpha;
106+
#endif
107+
104108
InputData inputData;
105109
InitializeInputData(input, inputData);
106110
SETUP_DEBUG_TEXTURE_DATA(inputData, input.uv, _BaseMap);

0 commit comments

Comments
 (0)