Skip to content

Commit 5a6871c

Browse files
authored
Merge pull request #72 from CyberAgentGameEntertainment/bug-fix/basemap-compression-noise
Fix the issue where artifacts occur due to texture compression errors in emission.
2 parents 4276a4a + 10abd50 commit 5a6871c

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

Assets/Nova/Runtime/Core/Shaders/ParticlesUber.hlsl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,9 @@ inline void ApplyVertexColor(in out half4 color, in half4 vertexColor)
488488
inline void ApplyEmissionColor(in out half4 color, half2 emissionMapUv, float intensity, half emissionMapProgress,
489489
half emissionChannelsX)
490490
{
491+
// Texture compression may introduce an error of 1/256, so it's advisable to allow for some margin
492+
const half tex_comp_err_margin = 0.004;
493+
491494
half emissionIntensity = 0;
492495
half emissionColorRampU = 0;
493496
#ifdef _EMISSION_AREA_ALL
@@ -498,13 +501,13 @@ inline void ApplyEmissionColor(in out half4 color, half2 emissionMapUv, float in
498501
#if defined(_EMISSION_COLOR_COLOR) || defined(_EMISSION_COLOR_BASECOLOR)
499502
emissionIntensity = emissionMapValue;
500503
#elif _EMISSION_COLOR_MAP
501-
emissionIntensity = step(0.0001, emissionMapValue);
504+
emissionIntensity = step(tex_comp_err_margin, emissionMapValue);
502505
emissionColorRampU = emissionMapValue;
503506
#endif
504507
#elif _EMISSION_AREA_ALPHA
505-
emissionIntensity = step(0.0001, 1.0 - color.a);
508+
emissionIntensity = step(tex_comp_err_margin, 1.0 - color.a);
506509
emissionColorRampU = color.a;
507-
color.a = _KeepEdgeTransparency >= 0.5f ? color.a : step(0.0001, color.a);
510+
color.a = _KeepEdgeTransparency >= 0.5f ? color.a : step(tex_comp_err_margin, color.a);
508511
#endif
509512

510513
half3 emissionColor = 0;

0 commit comments

Comments
 (0)