improve fog color transition

This commit is contained in:
Moritz Zwerger 2024-03-01 00:24:54 +01:00
parent 3fada12014
commit b6b106ef83
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
2 changed files with 6 additions and 2 deletions

View File

@ -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++

View File

@ -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;
}