Posts

Showing posts from May 5, 2019

Forward and backward alpha blending for raymarching

When implementing raymatching by scanning a ray to accumulating scene's colors, containing semi-transparent colors (for example, scene with clouds), it's required to properly combine colors using alpha blending method. Here we discuss how to do it and obtain corresponding formula. (So, here we propose that objects has "uniform" ambient lighting and some transparency and all we need to accumulate their colors). The forward alpha blending formula, used "everywhere" - in OpenGL, VJ software, photo and video editors, can be formulated in the following way: Formula for "forward" alpha blending ---------------------------------- Let C is a current RGB color, c is a new RGB color and alpha is a new color's opaqueness (alpha is a float value from 0 to 1). Then updating rule for C is the following:     C = (1- alpha )* C + alpha * c    ---------------------------------- So, the more alpha , the more c affec