100{
102 GLfloat rscale, gscale, bscale, ascale;
107
108
109
110
111 rscale =
ctx->Visual->RedScale;
112 gscale =
ctx->Visual->GreenScale;
113 bscale =
ctx->Visual->BlueScale;
114 ascale =
ctx->Visual->AlphaScale;
115
116 mat = &
ctx->Light.Material[side];
117
118
119 baseR =
mat->Emission[0] +
ctx->Light.Model.Ambient[0] *
mat->Ambient[0];
120 baseG =
mat->Emission[1] +
ctx->Light.Model.Ambient[1] *
mat->Ambient[1];
121 baseB =
mat->Emission[2] +
ctx->Light.Model.Ambient[2] *
mat->Ambient[2];
123
125
129
130 if (side==0) {
131
135 }
136 else {
137
141 }
142
143 sumR = baseR;
144 sumG = baseG;
145 sumB = baseB;
146
147
149 GLfloat ambientR, ambientG, ambientB;
153
154
155 if (
light->Position[3]==0.0) {
156
157 VPx =
light->VP_inf_norm[0];
158 VPy =
light->VP_inf_norm[1];
159 VPz =
light->VP_inf_norm[2];
160 attenuation = 1.0F;
161 }
162 else {
163
171 VPx *= invd;
172 VPy *= invd;
173 VPz *= invd;
174 }
175 attenuation = 1.0F / (
light->ConstantAttenuation
176 +
d * (
light->LinearAttenuation
177 +
d *
light->QuadraticAttenuation));
178 }
179
180
181 if (
light->SpotCutoff==180.0F) {
182
183 spot = 1.0F;
184 }
185 else {
186 GLfloat PVx, PVy, PVz, PV_dot_dir;
187 PVx = -VPx;
188 PVy = -VPy;
189 PVz = -VPz;
190 PV_dot_dir = PVx*
light->NormDirection[0]
191 + PVy*
light->NormDirection[1]
192 + PVz*
light->NormDirection[2];
193 if (PV_dot_dir<=0.0F || PV_dot_dir<light->CosCutoff) {
194
195 spot = 0.0F;
196 }
197 else {
200 spot =
light->SpotExpTable[
k][0]
202 }
203 }
204
205 ambientR =
mat->Ambient[0] *
light->Ambient[0];
206 ambientG =
mat->Ambient[1] *
light->Ambient[1];
207 ambientB =
mat->Ambient[2] *
light->Ambient[2];
208
209
210 n_dot_VP =
nx * VPx +
ny * VPy +
nz * VPz;
211
212
213 if (n_dot_VP<=0.0F) {
214
216 sumR +=
t * ambientR;
217 sumG +=
t * ambientG;
218 sumB +=
t * ambientB;
219
220 }
221 else {
222 GLfloat diffuseR, diffuseG, diffuseB;
223 GLfloat specularR, specularG, specularB;
225
226
227 diffuseR = n_dot_VP *
mat->Diffuse[0] *
light->Diffuse[0];
228 diffuseG = n_dot_VP *
mat->Diffuse[1] *
light->Diffuse[1];
229 diffuseB = n_dot_VP *
mat->Diffuse[2] *
light->Diffuse[2];
230
231
232 if (
ctx->Light.Model.LocalViewer) {
237 vlen =
GL_SQRT( vx*vx + vy*vy + vz*vz );
238 if (vlen>0.0001F) {
240 vx *= invlen;
241 vy *= invlen;
242 vz *= invlen;
243 }
244
245 h_x = VPx - vx;
246 h_y = VPy - vy;
247 h_z = VPz - vz;
248 }
249 else {
250
251 h_x = VPx;
252 h_y = VPy;
253 h_z = VPz + 1.0F;
254 }
255
256
257 n_dot_h =
nx*h_x +
ny*h_y +
nz*h_z;
258
259 if (n_dot_h<=0.0F) {
260 specularR = 0.0F;
261 specularG = 0.0F;
262 specularB = 0.0F;
263 }
264 else {
266
267 n_dot_h = n_dot_h /
GL_SQRT( h_x*h_x + h_y*h_y + h_z*h_z );
268 if (n_dot_h>1.0F) {
269
270 spec_coef =
pow( n_dot_h,
mat->Shininess );
271 }
272 else {
273
275 if (
mat->ShineTable[
k] < 0.0F)
277 spec_coef =
mat->ShineTable[
k];
278 }
279 if (spec_coef<1.0e-10) {
280 specularR = 0.0F;
281 specularG = 0.0F;
282 specularB = 0.0F;
283 }
284 else {
285 specularR = spec_coef *
mat->Specular[0]*
light->Specular[0];
286 specularG = spec_coef *
mat->Specular[1]*
light->Specular[1];
287 specularB = spec_coef *
mat->Specular[2]*
light->Specular[2];
288 }
289 }
290
291 t = attenuation * spot;
292 sumR +=
t * (ambientR + diffuseR + specularR);
293 sumG +=
t * (ambientG + diffuseG + specularG);
294 sumB +=
t * (ambientB + diffuseB + specularB);
295 }
296
297 }
298
299
304
305 }
306}
static CHAR baseA[MAX_PATH]
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
double pow(double x, double y)
GLint GLint GLint GLint GLint x
GLfloat GLfloat GLfloat GLfloat nx
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum light
static GLfloat gl_pow(GLfloat x, GLfloat y)
#define CLAMP(f, min, max)