Skip to content

Commit

Permalink
improve fog color transition
Browse files Browse the repository at this point in the history
  • Loading branch information
Bixilon committed Feb 29, 2024
1 parent 3fada12 commit b6b106e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,17 @@ class FogManager(
val progress = delta / INTERPOLATE_DURATION.toFloat()
state.start = interpolateLinear(progress, interpolation.start, options?.start ?: 0.0f)
state.end = interpolateLinear(progress, interpolation.end, options?.end ?: 0.0f)
var color: RGBColor? = interpolateSine(progress, interpolation.color ?: Colors.TRANSPARENT, options?.color ?: Colors.TRANSPARENT)

val sourceColor = interpolation.color ?: options?.color ?: Colors.TRANSPARENT
val targetColor = options?.color ?: RGBColor(sourceColor.red, sourceColor.green, sourceColor.blue, 0x00)
var color: RGBColor? = interpolateSine(progress, sourceColor, targetColor)
if (color == Colors.TRANSPARENT) {
color = null
}
state.color = color
if (progress >= 1.0f) {
interpolation.change = 1L // this avoid further interpolations with the same data
interpolation.color = options?.color
}

state.revision++
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ void fog_mix_alpha(float alpha) {
}

void fog_mix_color(float alpha) {
foutColor.rgb = mix(uFogColor.rgb, foutColor.rgb, foutColor.a * alpha);
foutColor.rgb = mix(uFogColor.rgb, foutColor.rgb, foutColor.a * alpha);// uFogColor.a *
foutColor.a = 1.0f;
}

Expand Down

0 comments on commit b6b106e

Please sign in to comment.