next up previous contents index
Next: Bibliography Up: Vertex and Fragment Programs Previous: Volume Rendering Integral with   Contents   Index


Volume Rendering Integral with Linear Opacity and Luminance, Close Approximation

This listing is a function that provides a close but reasonably fast approximation to volume rendering with linearly interpolated opacity and luminance. Section 1.3.2 gives details of the approximation. We may use this function in conjunction with the fragment program given in Appendix 1.2.

float4 IntegrateRay(in float4 BackColor, in float4 FrontColor,
                    in float Length)
{
    float zeta = pow(1 - (  0.5*(colorBack.a+colorFront.a)
                          + (0.108165*(colorBack.a-colorFront.a)
                             *(colorBack.a-colorFront.a)) ),
                     distance*LengthMultiply);
    float alpha = 1 - zeta;
    float dtau2 = -distance*LengthMultiply
                   *log(1-(0.27*colorBack.a+0.73*colorFront.a));
    float zeta2 = exp(-dtau2);
    float Psi = (1-zeta2)/dtau2;

    float4 color;
    color.rgb = colorFront.rgb*(1-Psi) + colorBack.rgb*(Psi - zeta);
    color.a = alpha;

    return color;
}



Kenneth D Moreland 2004-07-16