Frapper  1.0a
DualScatterMath.h
Go to the documentation of this file.
1 /*
2 -----------------------------------------------------------------------------
3 This source file is part of FRAPPER
4 research.animationsinstitut.de
5 sourceforge.net/projects/frapper
6 
7 Copyright (c) 2008-2011 Filmakademie Baden-Wuerttemberg, Institute of Animation
8 
9 This program is free software; you can redistribute it and/or modify it under
10 the terms of the GNU Lesser General Public License as published by the Free Software
11 Foundation; either version 2 of the License, or (at your option) any later
12 version.
13 
14 This program is distributed in the hope that it will be useful, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
17 
18 You should have received a copy of the GNU Lesser General Public License along with
19 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
20 Place - Suite 330, Boston, MA 02111-1307, USA, or go to
21 http://www.gnu.org/copyleft/lesser.txt.
22 -----------------------------------------------------------------------------
23 */
24 
33 
34 #ifndef DUALSCATTERMATH_H
35 #define DUALSCATTERMATH_H
36 
37 // OGRE
38 #include <Ogre.h>
39 #if (OGRE_PLATFORM == OGRE_PLATFORM_WIN32)
40 #include <windows.h>
41 #endif
42 
43 namespace HairRenderNode {
44 
46 {
47 public:
48  DualScatterMath(const unsigned int tableSize = 128);
50 
51 public:
52  unsigned int getTablesize() const;
53 
54 private:
55  typedef float (DualScatterMath::*funcPtr) (float, float);
56 
57 private:
58  inline float GToR(const float grad);
59 
60  float g(float x, float variance);
61 
70  inline float S(funcPtr f, const float a, const float b, int n, const float c);
71 
72  inline float M_X(const float alpha, const float beta, const float theta);
73 
74  inline float SM_X(const float alpha, const float beta, const float a, const float b);
75 
76  inline float N_R(const float phi, float empty = 0);
77 
78  inline float N_TT(const float phi, const float gamma);
79 
80  inline float N_TRT(const float phi, const float gamma);
81 
82  inline Ogre::ColourValue f_R(const float theta, const float I, const float phi, Ogre::ColourValue &colour);
83 
84  inline Ogre::ColourValue f_TT(const float theta, const float I, const float phi, Ogre::ColourValue &colour);
85 
86  inline Ogre::ColourValue f_TRT(const float theta, const float I, const float phi, Ogre::ColourValue &colour);
87 
88  inline Ogre::ColourValue DualScatterMath::f_s(const float theta, const float phi, const float I_R, const float I_TT, const float I_TRT, const float I_G, Ogre::ColourValue &colour_R, Ogre::ColourValue &colour_TT, Ogre::ColourValue &colour_TRT);
89 
90  inline Ogre::ColourValue alpha_fb(const float phi, const float from, const float to);
91 
92  inline Ogre::ColourValue beta_fb(const float phi, const float from, const float to);
93 
94  inline Ogre::ColourValue SX_f_s(const float theta, const float from, const float to);
95 
96  inline Ogre::ColourValue a_fb(const float theta, const float from, const float to);
97 
98  inline Ogre::ColourValue A_b(const float theta);
99 
100  inline Ogre::ColourValue delta_b(const float theta);
101 
102  inline Ogre::ColourValue sigma_b(const float theta);
103 
104  float* fillN_gR();
105  float* fillN_gTT();
106  float* fillN_gTRT();
107 
108  Ogre::ColourValue* fill_A_b(const float from, const float to);
109  Ogre::ColourValue* fill_delta_b(const float from, const float to);
110  Ogre::ColourValue* fill_sigma_b(const float from, const float to);
111 
112 private:
113  // hair fibre
114  float m_eta;
115  float m_sigma_a;
116  float m_a;
117 
118  // hair colors and intensities
119  Ogre::ColourValue m_C_R;
120  Ogre::ColourValue m_C_TT;
121  Ogre::ColourValue m_C_TRT;
122  float m_I_R;
123  float m_I_TT;
124  float m_I_TRT;
125  float m_I_G;
126 
127  // surface
128  float m_alpha_R;
129  float m_alpha_TT;
130  float m_alpha_TRT;
131  float m_beta_R;
132  float m_beta_TT;
133  float m_beta_TRT;
134  float m_gamma_TT;
135  float m_gamma_G;
136 
137  // highlights
138  float m_k_g;
139  float m_w_c;
140  float m_dEta;
141  float m_dh_M;
142 
143 
144  Ogre::ColourValue *m_A_b;
145  Ogre::ColourValue *m_delta_b;
146  Ogre::ColourValue *m_sigma_b;
147  float *m_N_gR;
148  float *m_N_gTT;
149  float *m_N_gTRT;
150  unsigned int m_tableSize;
151 };
152 
153 } // namespace HairRenderNode
154 
155 #endif