Skip to content

2021.2/universal/case 1379188 particle unlit blend #6840

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion com.unity.render-pipelines.universal/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Changed
- Re-added the menu button to be able to convert selected materials.


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

## [12.1.4] - 2021-12-07
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -600,14 +600,16 @@ internal static void SetupMaterialBlendModeInternal(Material material, out int a
{
BlendMode blendMode = (BlendMode)material.GetFloat(Property.BlendMode);

material.DisableKeyword(ShaderKeywordStrings._ALPHAPREMULTIPLY_ON);
material.DisableKeyword(ShaderKeywordStrings._ALPHAMODULATE_ON);

// Specific Transparent Mode Settings
switch (blendMode)
{
case BlendMode.Alpha:
SetMaterialSrcDstBlendProperties(material,
UnityEngine.Rendering.BlendMode.SrcAlpha,
UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha);
material.DisableKeyword(ShaderKeywordStrings._ALPHAPREMULTIPLY_ON);
break;
case BlendMode.Premultiply:
SetMaterialSrcDstBlendProperties(material,
Expand All @@ -619,13 +621,11 @@ internal static void SetupMaterialBlendModeInternal(Material material, out int a
SetMaterialSrcDstBlendProperties(material,
UnityEngine.Rendering.BlendMode.SrcAlpha,
UnityEngine.Rendering.BlendMode.One);
material.DisableKeyword(ShaderKeywordStrings._ALPHAPREMULTIPLY_ON);
break;
case BlendMode.Multiply:
SetMaterialSrcDstBlendProperties(material,
UnityEngine.Rendering.BlendMode.DstColor,
UnityEngine.Rendering.BlendMode.Zero);
material.DisableKeyword(ShaderKeywordStrings._ALPHAPREMULTIPLY_ON);
material.EnableKeyword(ShaderKeywordStrings._ALPHAMODULATE_ON);
break;
}
Expand Down
4 changes: 0 additions & 4 deletions com.unity.render-pipelines.universal/ShaderLibrary/Unlit.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ half4 UniversalFragmentUnlit(InputData inputData, SurfaceData surfaceData)
{
half3 albedo = surfaceData.albedo;

#if defined(_ALPHAPREMULTIPLY_ON)
albedo *= surfaceData.alpha;
#endif

#if defined(DEBUG_DISPLAY)
half4 debugColor;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,13 @@ void InitializeSurfaceData(ParticleParams particleParams, out SurfaceData surfac
const half3 emission = 0;
#endif

surfaceData.albedo = albedo.rgb;
surfaceData.albedo = albedo.rgb; // NOTE: Pre-multiplied and modulated in SampleAlbedo().
surfaceData.specular = 0;
surfaceData.normalTS = normalTS;
surfaceData.emission = emission;
surfaceData.metallic = 0;
surfaceData.smoothness = 1;
surfaceData.occlusion = 1;

surfaceData.albedo = AlphaModulate(surfaceData.albedo, albedo.a);
surfaceData.alpha = albedo.a;

surfaceData.clearCoatMask = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ half4 UnlitPassFragment(Varyings input) : SV_Target

AlphaDiscard(alpha, _Cutoff);

#if defined(_ALPHAPREMULTIPLY_ON)
color *= alpha;
#endif

InputData inputData;
InitializeInputData(input, inputData);
SETUP_DEBUG_TEXTURE_DATA(inputData, input.uv, _BaseMap);
Expand Down