DXGL r176 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r175‎ | r176 | r177 >
Date:18:34, 23 June 2012
Author:admin
Status:new
Tags:
Comment:
Tweak point lights. Enable positional lighting.
Modified paths:
  • /ddraw/glDirect3D.cpp (modified) (history)
  • /ddraw/shadergen.cpp (modified) (history)

Diff [purge]

Index: ddraw/glDirect3D.cpp
@@ -92,7 +92,7 @@
9393 IID_IDirect3DHALDevice, //deviceGUID
9494 0, //wMaxUserClipPlanes
9595 0, //wMaxVertexBlendMatrices
96 - D3DVTXPCAPS_DIRECTIONALLIGHTS, //dwVertexProcessingCaps
 96+ D3DVTXPCAPS_DIRECTIONALLIGHTS|D3DVTXPCAPS_POSITIONALLIGHTS, //dwVertexProcessingCaps
9797 0,0,0,0 //dwReserved1 through dwReserved4
9898 };
9999
Index: ddraw/shadergen.cpp
@@ -317,10 +317,11 @@
318318 }\n";
319319 static const char func_spotlight[] = "void SpotLight(in Light light)\n\
320320 {\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\
 321+float NdotHV = 0.0;\n\
 322+vec3 V = ((view*world)*xyzw).xyz;\n\
 323+float d = length(light.position - V);\n\
 324+vec3 L = normalize(light.position - V);\n\
 325+vec3 H = normalize(L + vec3(0.0, 0.0, 1.0));\n\
325326 float NdotL = max(dot(N,L),0.0);\n\
326327 float NdotH = max(dot(N,H),0.0);\n\
327328 diffuse += light.diffuse*NdotL;\n\
@@ -442,7 +443,7 @@
443444 }
444445 }
445446 bool hasspecular = (id >> 11) & 1;
446 - if(hasspot) FIXME("Add spot lights");
 447+ if(hasspot) vsrc->append(func_spotlight);
447448 if(hasdir) vsrc->append(func_dirlight);
448449 //Main
449450 vsrc->append(mainstart);