1 ////////////////////////////////////////////////////////////////////////////////
2 // Scorched3D (c) 2000-2009
4 // This file is part of Scorched3D.
6 // Scorched3D is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 2 of the License, or
9 // (at your option) any later version.
11 // Scorched3D is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with Scorched3D; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 ////////////////////////////////////////////////////////////////////////////////
21 #if !defined(__INCLUDE_Water2Constantsh_INCLUDE__)
22 #define __INCLUDE_Water2Constantsh_INCLUDE__
24 #include <common/Vector.h>
26 static inline float myfmod(float a
, float b
) { return a
-floorf(a
/b
)*b
; }//fmod is different for negative a/b
28 static const float wave_tidecycle_time
= 10.24f
;
29 static const unsigned int wave_phases
= 256;
30 static const unsigned int wave_patch_width
= 64;
31 static const unsigned int wave_resolution
= 128;
33 static const float grid_size
= 512.0f
/ (256.0f
/ float(wave_patch_width
));
34 static const float half_grid_size
= grid_size
/ 2.0f
;
36 static const float wavetile_length
= 256.0f
;
37 static const float wave_waterwidth
= wavetile_length
;
38 static const float wavetile_length_rcp
= 1.0f
/ wavetile_length
;
40 static const float VIRTUAL_PLANE_HEIGHT
= 25.0f
;
42 #define REFRAC_COLOR_RES 32
43 #define FRESNEL_FCT_RES 256
48 Vector
&getPoint(int x
, int y
)
50 DIALOG_ASSERT(x
>=0 && y
>=0 && x
<wave_resolution
&& y
<wave_resolution
);
55 Vector points
[wave_resolution
][wave_resolution
];
58 static inline float exact_fresnel(float x
)
60 // the real formula (recheck it!)
62 float g = 1.333f + x*x - 1;
65 return (z1*z1)*(1+((x*z2-1)*(x*z2-1))/((x*z1+1)*(x*z1+1)))/(2*z2*z2);
71 if (tmp < 0.0f) tmp = 0.0f;
74 // a good approximation (1/(x+1)^8)
82 #endif // __INCLUDE_Water2Constantsh_INCLUDE__