| Index: ddraw/shadergen.cpp |
| — | — | @@ -281,7 +281,6 @@ |
| 282 | 282 | static const char op_resetcolor[] = "diffuse = specular = vec4(0.0);\n\
|
| 283 | 283 | ambient = ambientcolor / 255.0;\n";
|
| 284 | 284 | static const char op_dirlight[] = "DirLight(lightX);\n";
|
| 285 | | -static const char op_dirlightnospecular[] = "DirLightNoSpecular(lightX);\n";
|
| 286 | 285 | static const char op_spotlight[] = "SpotLight(lightX);\n";
|
| 287 | 286 | static const char op_colorout[] = "gl_FrontColor = (material.diffuse * diffuse) + (material.ambient * ambient) + material.emissive;\n\
|
| 288 | 287 | gl_FrontSecondaryColor = (material.specular * specular);\n";
|
| — | — | @@ -305,7 +304,7 @@ |
| 306 | 305 | ambient += light.ambient;\n\
|
| 307 | 306 | float NdotL = max(dot(N,dir),0.0);\n\
|
| 308 | 307 | diffuse += light.diffuse*NdotL;\n\
|
| 309 | | -if(NdotL > 0.0)\n\
|
| | 308 | +if((NdotL > 0.0) && (material.power != 0.0))\n\
|
| 310 | 309 | {\n\
|
| 311 | 310 | vec3 eye = (-view[3].xyz / view[3].w);\n\
|
| 312 | 311 | vec3 P = vec3((view*world)*xyzw);\n\
|
| — | — | @@ -316,16 +315,20 @@ |
| 317 | 316 | ambient += light.ambient;\n\
|
| 318 | 317 | }\n\
|
| 319 | 318 | }\n";
|
| 320 | | -static const char func_dirlightnospecular[] = "void DirLightNoSpecular(in Light light)\n\
|
| | 319 | +static const char func_spotlight[] = "void SpotLight(in Light light)\n\
|
| 321 | 320 | {\n\
|
| 322 | | -float NdotHV = 0.0;\n\
|
| 323 | | -vec3 dir = normalize(-light.direction);\n\
|
| | 321 | +float NdotHV = 0.0\n\
|
| | 322 | +vec3 V = normalize(eye - P);\n\
|
| | 323 | +float d = length( light.position - V );\n\
|
| | 324 | +vec3 L = normalize( light.position - V );\n\
|
| | 325 | +float NdotL = max(dot(N,L),0.0);\n\
|
| | 326 | +float NdotH = max(dot(N,H),0.0);\n\
|
| | 327 | +diffuse += light.diffuse*NdotL;\n\
|
| 324 | 328 | ambient += light.ambient;\n\
|
| 325 | | -float NdotL = max(dot(N,dir),0.0);\n\
|
| 326 | | -diffuse += light.diffuse*NdotL;\n\
|
| 327 | 329 | }\n";
|
| 328 | 330 |
|
| 329 | 331 |
|
| | 332 | +
|
| 330 | 333 | /**
|
| 331 | 334 | * Creates an OpenGL shader program
|
| 332 | 335 | * @param index
|
| — | — | @@ -440,11 +443,7 @@ |
| 441 | 444 | }
|
| 442 | 445 | bool hasspecular = (id >> 11) & 1;
|
| 443 | 446 | if(hasspot) FIXME("Add spot lights");
|
| 444 | | - if(hasdir)
|
| 445 | | - {
|
| 446 | | - if(hasspecular) vsrc->append(func_dirlight);
|
| 447 | | - else vsrc->append(func_dirlightnospecular);
|
| 448 | | - }
|
| | 447 | + if(hasdir) vsrc->append(func_dirlight);
|
| 449 | 448 | //Main
|
| 450 | 449 | vsrc->append(mainstart);
|
| 451 | 450 | if((id>>50)&1) vsrc->append(op_passthru);
|
| — | — | @@ -464,18 +463,9 @@ |
| 465 | 464 | }
|
| 466 | 465 | else
|
| 467 | 466 | {
|
| 468 | | - if(hasspecular)
|
| 469 | | - {
|
| 470 | | - tmp = op_dirlight;
|
| 471 | | - tmp.replace(14,1,_itoa(i,idstring,10));
|
| 472 | | - vsrc->append(tmp);
|
| 473 | | - }
|
| 474 | | - else
|
| 475 | | - {
|
| 476 | | - tmp = op_dirlightnospecular;
|
| 477 | | - tmp.replace(24,1,_itoa(i,idstring,10));
|
| 478 | | - vsrc->append(tmp);
|
| 479 | | - }
|
| | 467 | + tmp = op_dirlight;
|
| | 468 | + tmp.replace(14,1,_itoa(i,idstring,10));
|
| | 469 | + vsrc->append(tmp);
|
| 480 | 470 | }
|
| 481 | 471 | }
|
| 482 | 472 | vsrc->append(op_colorout);
|