Skip to content

Commit

Permalink
Add factor for light conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
elishacloud committed Apr 25, 2024
1 parent be2aad9 commit 6651807
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Dllmain/BuildNo.rc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#define BUILD_NUMBER 7003
#define BUILD_NUMBER 7004
1 change: 1 addition & 0 deletions ddraw/IDirect3DDeviceX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2165,6 +2165,7 @@ HRESULT m_IDirect3DDeviceX::SetLight(m_IDirect3DLight* lpLightInterface, LPD3DLI

D3DLIGHT7 Light7;

// ToDo: the dvAttenuation members are interpreted differently in D3DLIGHT2 than they were for D3DLIGHT.
ConvertLight(Light7, *lpLight);

DWORD dwLightIndex = 0;
Expand Down
11 changes: 7 additions & 4 deletions ddraw/IDirect3DTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,13 @@ void ConvertLight(D3DLIGHT7& Light7, D3DLIGHT& Light)
LOG_LIMIT(100, __FUNCTION__ << " Error: Incorrect dwSize: " << Light.dwSize);
return;
}
const float DiffuseFactor = 1.0f;
const float SpecularFactor = 0.1f;
const float AmbientFactor = 0.3f;
Light7.dltType = Light.dltType;
Light7.dcvDiffuse = Light.dcvColor;
Light7.dcvSpecular = Light.dcvColor;
Light7.dcvAmbient = Light.dcvColor;
Light7.dcvDiffuse = { Light.dcvColor.r * DiffuseFactor, Light.dcvColor.g * DiffuseFactor, Light.dcvColor.b * DiffuseFactor, Light.dcvColor.a };
Light7.dcvSpecular = { Light.dcvColor.r * SpecularFactor, Light.dcvColor.g * SpecularFactor, Light.dcvColor.b * SpecularFactor, Light.dcvColor.a };
Light7.dcvAmbient = { Light.dcvColor.r * AmbientFactor, Light.dcvColor.g * AmbientFactor, Light.dcvColor.b * AmbientFactor, Light.dcvColor.a };
Light7.dvPosition = Light.dvPosition;
Light7.dvDirection = Light.dvDirection;
Light7.dvRange = Light.dvRange;
Expand All @@ -50,7 +53,7 @@ void ConvertLight(D3DLIGHT7& Light7, D3DLIGHT& Light)
Light7.dvPhi = Light.dvPhi;

// Apply additional flags
if (Light.dwSize == sizeof(D3DLIGHT2) && !(((LPD3DLIGHT2)&Light)->dwFlags & D3DLIGHT_NO_SPECULAR))
if (Light.dwSize == sizeof(D3DLIGHT2) && (((LPD3DLIGHT2)&Light)->dwFlags & D3DLIGHT_NO_SPECULAR))
{
// No specular reflection
Light7.dcvSpecular = { 0.0f, 0.0f, 0.0f, 1.0f };
Expand Down

0 comments on commit 6651807

Please sign in to comment.