00001 #ifndef _VUTFPREINTEGRATED_H_ 00002 #define _VUTFPREINTEGRATED_H_ 00003 00004 #include "vuColour.h" 00005 #include "vuTFIntensity.h" 00006 00008 /* 00009 Details for this idea can be found in the paper "High-Quality 00010 Pre-Integrated Volume Rendering Using Hardware-Accelerated Pixel 00011 Shading" by Klaus Engel, Martin Kraus, Thomas Ertl 00012 00013 Two methods are possible. The non-alpha weighted method corresponds 00014 to the approximated pre-integration proposed in section 3.5 of the 00015 paper. useAlphaWeighting( false/true ) 00016 00017 Section 3.4 of the paperdescribes a more precise version using the 00018 alpha values and sampling distance for correct attenuation. This 00019 would lead to a non-symmetric LUT, which is not representable by a 00020 1D summed area table. 00021 00022 The other approach uses alpha weighting during preintegration. It's 00023 similar to the one in equation (10) of the paper. The only 00024 difference is that I use the integrated alpha rather than 1/sb-sf 00025 for normalization of the integral. The difference of the two 00026 methods becomes visible for rapid jumps of the alpha value in the 00027 transfer together with a change in colour. 00028 00029 It would be interesting to have an implementation of the exact 00030 method (paper 3.4). This would require a 2-D LUT. 00031 00032 To have comparable results with different sampling distances I 00033 modify the returned alpha value before using it for compositing: 00034 00035 opacity = 1 - exp ( -alpha * SamplingDistance * STRETCHALPHA) 00036 00037 'alpha' is restricted to [0,1]. The STRETCHALPHA coefficient helps 00038 to enhance this interval to reach opacities closer to 1. 00039 */ 00040 00041 class vuTFPreintegrated : public vuTFIntensity 00042 { 00043 public: 00045 00047 vuTFPreintegrated(); 00048 vuTFPreintegrated(dword ncomp, dword range); 00049 00051 vuTFPreintegrated(const vuTFIntensity& inst); 00052 00054 virtual ~vuTFPreintegrated(); 00055 00056 //assignment operator 00057 vuTFPreintegrated& operator=(const vuTFIntensity& rhs); 00058 00059 00061 void preintegrate(); 00062 00074 bool integrate(float back, float front, float d, vuColourN & col); 00075 00076 // do alpha weighted pre-integration 00077 void useAlphaWeighting(bool useit) { m_AlphaWeighted = useit; }; 00078 00079 00080 protected: 00084 bool init(dword ncomp, dword range); 00087 void cleanup(); 00088 00090 float *m_PITable; 00091 00093 bool m_AlphaWeighted; 00094 00095 }; 00096 00097 00098 #endif