From 58fa6917c266d24eb84d008191b230054ee5e63c Mon Sep 17 00:00:00 2001 From: Robert Bragg Date: Sun, 7 Jun 2009 11:54:05 +0100 Subject: [PATCH] [fog] Document that fogging only works with opaque or unmultipled colors The fixed function fogging provided by OpenGL only works with unmultiplied colors (or if the color has an alpha of 1.0) so since we now premultiply textures and colors by default a note to this affect has been added to clutter_stage_set_fog and cogl_set_fog. test-depth.c no longer uses clutter_stage_set_fog for this reason. In the future when we can depend on fragment shaders we should also be able to support fogging of premultiplied primitives. --- cogl.h.in | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/cogl.h.in b/cogl.h.in index 64d57fc4f..26bcf25c2 100644 --- a/cogl.h.in +++ b/cogl.h.in @@ -386,13 +386,22 @@ gboolean cogl_get_backface_culling_enabled (void); * @z_near: Position along z-axis where no fogging should be applied * @z_far: Position along z-axes where full fogging should be applied * - * Enables fogging. Fogging causes vertices that are further away from - * the eye to be rendered with a different color. The color is determined - * according to the chosen fog mode; at it's simplest the color is - * linearly interpolated so that vertices at @z_near are drawn fully - * with their original color and vertices at @z_far are drawn fully - * with @fog_color. Fogging will remain enabled until you call - * cogl_disable_fog(). + * Enables fogging. Fogging causes vertices that are further away from the eye + * to be rendered with a different color. The color is determined according to + * the chosen fog mode; at it's simplest the color is linearly interpolated so + * that vertices at @z_near are drawn fully with their original color and + * vertices at @z_far are drawn fully with @fog_color. Fogging will remain + * enabled until you call cogl_disable_fog(). + * + * Note: The fogging functions only work correctly when primitives use + * unmultiplied alpha colors. By default Cogl will premultiply textures + * and cogl_set_source_color will premultiply colors, so unless you + * explicitly load your textures requesting an unmultiplied + * internal_format and use cogl_material_set_color you can only use + * fogging with fully opaque primitives. + * + * We can look to improve this in the future when we can depend on + * fragment shaders. */ void cogl_set_fog (const CoglColor *fog_color, CoglFogMode mode,