Skip to content

Commit

Permalink
Improved VC ambient environment debugging.
Browse files Browse the repository at this point in the history
  • Loading branch information
jarmonik committed Jan 24, 2024
1 parent bdc8996 commit 4534b74
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 36 deletions.
56 changes: 30 additions & 26 deletions OVP/D3D9Client/D3D9Client.rc
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ EXSTYLE WS_EX_WINDOWEDGE
CAPTION "D3D9 Debug Controls"
FONT 8, "Ms Shell Dlg"
{
GROUPBOX "Mesh Options", IDC_STATIC, 5, 165, 176, 60, 0, WS_EX_LEFT
GROUPBOX "Mesh Options and Flags", IDC_STATIC, 5, 165, 176, 60, 0, WS_EX_LEFT
PUSHBUTTON "Close", IDCANCEL, 124, 429, 51, 14, 0, WS_EX_LEFT
PUSHBUTTON "Open", IDC_DBG_OPEN, 387, 34, 30, 14, 0, WS_EX_LEFT
PUSHBUTTON "Execute", IDC_DBG_EXECUTE, 490, 147, 56, 14, 0, WS_EX_LEFT
Expand All @@ -56,26 +56,26 @@ FONT 8, "Ms Shell Dlg"
EDITTEXT IDC_DBG_FILE, 421, 35, 125, 12, WS_GROUP | ES_AUTOHSCROLL | ES_READONLY, WS_EX_LEFT
AUTOCHECKBOX "Highlight selected group", IDC_DBG_HSG, 18, 107, 92, 8, 0, WS_EX_LEFT
AUTOCHECKBOX "Highlight selected mesh", IDC_DBG_HSM, 18, 117, 91, 8, 0, WS_EX_LEFT
AUTOCHECKBOX "Boxes", IDC_DBG_BOXES, 208, 162, 35, 8, 0, WS_EX_LEFT
AUTOCHECKBOX "Boxes", IDC_DBG_BOXES, 208, 202, 35, 8, 0, WS_EX_LEFT
AUTOCHECKBOX "Normalize", IDC_DBG_NORM, 400, 79, 47, 8, 0, WS_EX_LEFT
AUTOCHECKBOX "Mipmap fade", IDC_DBG_FADE, 400, 92, 57, 8, 0, WS_EX_LEFT
AUTOCHECKBOX "Reduce seams", IDC_DBG_SEAMS, 460, 79, 63, 8, 0, WS_EX_LEFT
AUTOCHECKBOX "Spheres", IDC_DBG_SPHERES, 208, 171, 42, 8, 0, WS_EX_LEFT
AUTOCHECKBOX "Surface Tiles", IDC_DBG_TILEBB, 208, 180, 57, 8, 0, WS_EX_LEFT
AUTOCHECKBOX "Selected group only", IDC_DBG_GRPO, 274, 162, 79, 8, 0, WS_EX_LEFT
GROUPBOX "Bounding geometry", IDC_STATIC, 195, 150, 175, 45, 0, WS_EX_LEFT
GROUPBOX "Visualize local light cones", IDC_STATIC, 195, 200, 175, 35, 0, WS_EX_LEFT
AUTOCHECKBOX "Spheres", IDC_DBG_SPHERES, 208, 211, 42, 8, 0, WS_EX_LEFT
AUTOCHECKBOX "Surface Tiles", IDC_DBG_TILEBB, 208, 220, 57, 8, 0, WS_EX_LEFT
AUTOCHECKBOX "Selected group only", IDC_DBG_GRPO, 274, 202, 79, 8, 0, WS_EX_LEFT
GROUPBOX "Bounding geometry", IDC_STATIC, 195, 190, 175, 45, 0, WS_EX_LEFT
GROUPBOX "Visualize local light cones", IDC_STATIC, 195, 240, 175, 35, 0, WS_EX_LEFT
GROUPBOX "Selection and Display Options", IDC_STATIC, 5, 15, 175, 145, 0, WS_EX_LEFT
GROUPBOX "Misc.", IDC_STATIC, 195, 10, 173, 70, 0, WS_EX_LEFT
GROUPBOX "Scene Debugger", IDC_STATIC, 195, 85, 173, 60, 0, WS_EX_LEFT
GROUPBOX "Scene Debugger", IDC_STATIC, 195, 85, 173, 95, 0, WS_EX_LEFT
GROUPBOX "Texture Tools", IDC_STATIC, 380, 15, 173, 151, 0, WS_EX_LEFT
AUTOCHECKBOX "Selected mesh only", IDC_DBG_MSHO, 274, 171, 77, 8, 0, WS_EX_LEFT
AUTOCHECKBOX "Selected mesh only", IDC_DBG_MSHO, 274, 211, 77, 8, 0, WS_EX_LEFT
AUTOCHECKBOX "Dual sided", IDC_DBG_DUAL, 120, 107, 49, 8, 0, WS_EX_LEFT
PUSHBUTTON "<", IDC_DBG_GRPUP, 102, 90, 9, 12, BS_CENTER, WS_EX_LEFT
PUSHBUTTON ">", IDC_DBG_GRPDN, 114, 90, 9, 12, BS_CENTER, WS_EX_LEFT
PUSHBUTTON "<", IDC_DBG_MSHUP, 102, 73, 9, 12, BS_CENTER, WS_EX_LEFT
PUSHBUTTON ">", IDC_DBG_MSHDN, 114, 73, 9, 12, BS_CENTER, WS_EX_LEFT
AUTOCHECKBOX "Selected visual only", IDC_DBG_VISO, 274, 180, 79, 8, 0, WS_EX_LEFT
AUTOCHECKBOX "Selected visual only", IDC_DBG_VISO, 274, 220, 79, 8, 0, WS_EX_LEFT
CONTROL "", IDC_DBG_SPEED, TRACKBAR_CLASS, WS_TABSTOP | TBS_BOTH | TBS_NOTICKS, 42, 58, 108, 13, WS_EX_LEFT
CONTROL "", IDC_DBG_RESBIAS, TRACKBAR_CLASS, WS_TABSTOP | TBS_AUTOTICKS | TBS_BOTH, 205, 55, 155, 20, WS_EX_LEFT
LTEXT "Speed", IDC_STATIC, 18, 58, 22, 8, SS_LEFT, WS_EX_LEFT
Expand All @@ -85,7 +85,7 @@ FONT 8, "Ms Shell Dlg"
GROUPBOX "Material", IDC_DBG_MATGRP, 5, 230, 175, 165, 0, WS_EX_LEFT
COMBOBOX IDC_DBG_MATPRP, 77, 240, 96, 15, CBS_DROPDOWNLIST | CBS_HASSTRINGS, WS_EX_LEFT
COMBOBOX IDC_DBG_DEFSHADER, 75, 177, 96, 15, CBS_DROPDOWNLIST | CBS_HASSTRINGS, WS_EX_LEFT
COMBOBOX IDC_DBG_CONES, 200, 215, 165, 15, CBS_DROPDOWNLIST | CBS_HASSTRINGS, WS_EX_LEFT
COMBOBOX IDC_DBG_CONES, 200, 255, 165, 15, CBS_DROPDOWNLIST | CBS_HASSTRINGS, WS_EX_LEFT
LTEXT "Material property", IDC_STATIC, 18, 242, 53, 8, SS_LEFT, WS_EX_LEFT
LTEXT "Mesh Shader", IDC_STATIC, 15, 179, 43, 9, SS_LEFT, WS_EX_LEFT
EDITTEXT IDC_DBG_RED, 31, 260, 30, 12, ES_AUTOHSCROLL, WS_EX_LEFT
Expand All @@ -111,7 +111,7 @@ FONT 8, "Ms Shell Dlg"
PUSHBUTTON "Save materials", IDC_DBG_MATSAVE, 5, 429, 51, 14, 0, WS_EX_LEFT
PUSHBUTTON "Create kernel", IDC_DBG_KERNEL, 315, 430, 47, 14, 0, WS_EX_LEFT
PUSHBUTTON "Data window", IDC_DBG_DATAWND, 5, 446, 50, 14, 0, WS_EX_LEFT
PUSHBUTTON "Save envmap", IDC_DBG_ENVSAVE, 205, 128, 60, 12, 0, WS_EX_LEFT
PUSHBUTTON "Save envmap", IDC_DBG_ENVSAVE, 300, 164, 60, 12, 0, WS_EX_LEFT
PUSHBUTTON ">>>", IDC_DBG_MORE, 124, 446, 50, 14, 0, WS_EX_LEFT
PUSHBUTTON "Reload Shader", IDC_DBG_RELOADSHD, 60, 446, 60, 14, 0, WS_EX_LEFT
PUSHBUTTON "Reload Textures", IDC_DBG_RELOADTEX, 60, 430, 60, 14, 0, WS_EX_LEFT
Expand All @@ -129,28 +129,32 @@ FONT 8, "Ms Shell Dlg"
COMBOBOX IDC_DBG_BKLID, 11, 407, 50, 15, CBS_DROPDOWNLIST | CBS_HASSTRINGS, WS_EX_LEFT
GROUPBOX "Baked Lights", 0, 6, 395, 175, 30, 0, WS_EX_LEFT
CONTROL "", IDC_DBG_BKLADJ, TRACKBAR_CLASS, WS_TABSTOP | TBS_BOTH | TBS_NOTICKS, 65, 405, 115, 15, WS_EX_LEFT
GROUPBOX "Mesh Group Information", IDC_STATIC, 195, 240, 175, 135, 0, WS_EX_LEFT
AUTOCHECKBOX "No Shadow", IDC_DBG_NOSHADOW, 200, 255, 53, 8, 0, WS_EX_LEFT
AUTOCHECKBOX "Do not render", IDC_DBG_NORENDER, 200, 265, 59, 8, 0, WS_EX_LEFT
AUTOCHECKBOX "Always Lit", IDC_DBG_NOLIGHT, 200, 275, 47, 8, 0, WS_EX_LEFT
AUTOCHECKBOX "Additive Blend", IDC_DBG_ADDITIVE, 200, 285, 61, 8, 0, WS_EX_LEFT
AUTOCHECKBOX "Texture Alpha Only (No Color)", IDC_DBG_NOCOLOR, 200, 295, 109, 8, 0, WS_EX_LEFT
AUTOCHECKBOX "Order Independent Transparency", IDC_DBG_OIT, 200, 305, 121, 8, 0, WS_EX_LEFT
EDITTEXT IDC_DBG_MATIDX, 225, 320, 30, 12, ES_AUTOHSCROLL, WS_EX_LEFT
EDITTEXT IDC_DBG_TEXIDX, 225, 335, 30, 12, ES_AUTOHSCROLL, WS_EX_LEFT
LTEXT "MatIdx", IDC_STATIC, 200, 321, 22, 9, SS_LEFT, WS_EX_LEFT
LTEXT "TexIdx", IDC_STATIC, 200, 337, 22, 9, SS_LEFT, WS_EX_LEFT
GROUPBOX "Mesh Group Information", IDC_STATIC, 195, 280, 175, 135, 0, WS_EX_LEFT
AUTOCHECKBOX "No Shadow", IDC_DBG_NOSHADOW, 200, 295, 53, 8, 0, WS_EX_LEFT
AUTOCHECKBOX "Do not render", IDC_DBG_NORENDER, 200, 305, 59, 8, 0, WS_EX_LEFT
AUTOCHECKBOX "Always Lit", IDC_DBG_NOLIGHT, 200, 315, 47, 8, 0, WS_EX_LEFT
AUTOCHECKBOX "Additive Blend", IDC_DBG_ADDITIVE, 200, 325, 61, 8, 0, WS_EX_LEFT
AUTOCHECKBOX "Texture Alpha Only (No Color)", IDC_DBG_NOCOLOR, 200, 335, 109, 8, 0, WS_EX_LEFT
AUTOCHECKBOX "Order Independent Transparency", IDC_DBG_OIT, 200, 345, 121, 8, 0, WS_EX_LEFT
EDITTEXT IDC_DBG_MATIDX, 225, 360, 30, 12, ES_AUTOHSCROLL, WS_EX_LEFT
EDITTEXT IDC_DBG_TEXIDX, 225, 375, 30, 12, ES_AUTOHSCROLL, WS_EX_LEFT
LTEXT "MatIdx", IDC_STATIC, 200, 361, 22, 9, SS_LEFT, WS_EX_LEFT
LTEXT "TexIdx", IDC_STATIC, 200, 377, 22, 9, SS_LEFT, WS_EX_LEFT
PUSHBUTTON "Save Mesh", IDC_DBG_MESHSAVE, 200, 430, 55, 14, 0, WS_EX_LEFT
PUSHBUTTON "Unrendered", IDC_DBG_NEXT, 127, 90, 48, 12, 0, WS_EX_LEFT
LTEXT "Label", IDC_STATIC, 201, 352, 18, 9, SS_LEFT, WS_EX_LEFT
EDITTEXT IDC_DBG_GRPLABEL, 225, 350, 140, 12, ES_AUTOHSCROLL, WS_EX_LEFT
LTEXT "Label", IDC_STATIC, 201, 392, 18, 9, SS_LEFT, WS_EX_LEFT
EDITTEXT IDC_DBG_GRPLABEL, 225, 390, 140, 12, ES_AUTOHSCROLL, WS_EX_LEFT
AUTOCHECKBOX "Exterior in VC", IDC_DBG_EXTVC, 120, 137, 58, 8, 0, WS_EX_LEFT
AUTOCHECKBOX "2cm near clip distance", IDC_DBG_CLIPDIST, 18, 136, 87, 8, 0, WS_EX_LEFT
LTEXT "MeshVisMode: ", IDC_DBG_VISMODE, 10, 380, 162, 9, SS_LEFT, WS_EX_LEFT
AUTOCHECKBOX "Pick only current mesh", IDC_DBG_PICKCURRENT, 18, 146, 87, 8, 0, WS_EX_LEFT
AUTOCHECKBOX "Dynamic", IDC_DBG_DYNAMIC, 285, 255, 43, 8, 0, WS_EX_LEFT
AUTOCHECKBOX "Dynamic", IDC_DBG_DYNAMIC, 285, 295, 43, 8, 0, WS_EX_LEFT
AUTOCHECKBOX "Is VC Mesh", IDC_DBG_ISVCMESH, 15, 193, 52, 8, 0, WS_EX_LEFT
AUTOCHECKBOX "Cast VC Shadow", IDC_DBG_VCSHADOW, 15, 203, 69, 8, 0, WS_EX_LEFT
COMBOBOX IDC_DBG_AMBDIR, 275, 130, 86, 15, CBS_DROPDOWNLIST | CBS_HASSTRINGS, WS_EX_LEFT
LTEXT "VC Ambient View Dir", IDC_STATIC, 205, 132, 66, 9, SS_LEFT, WS_EX_LEFT
AUTOCHECKBOX "No sunlight", IDC_DBG_NOSUNAMB, 205, 143, 51, 8, 0, WS_EX_LEFT
AUTOCHECKBOX "No planet glow", IDC_DBG_NOPLNAMB, 205, 152, 63, 8, 0, WS_EX_LEFT
}


Expand Down
21 changes: 21 additions & 0 deletions OVP/D3D9Client/DebugControls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ extern D3D9Client *g_client;

namespace DebugControls {

int ambdir = -1;
int bkl_id = 0;
DWORD dwGFX, dwCmd, nMesh, nGroup, sMesh, sGroup, debugFlags, dspMode, camMode, SelColor, sEmitter;
double camSpeed;
Expand Down Expand Up @@ -488,6 +489,8 @@ void UpdateFlags()
SETFLAG(debugFlags, DBG_FLAGS_NEARCLIP, (SendDlgItemMessageA(hDlg, IDC_DBG_CLIPDIST, BM_GETCHECK, 0, 0) == BST_CHECKED));
SETFLAG(debugFlags, DBG_FLAGS_RENDEREXT, (SendDlgItemMessageA(hDlg, IDC_DBG_EXTVC, BM_GETCHECK, 0, 0) == BST_CHECKED));
SETFLAG(debugFlags, DBG_FLAGS_PICKCURRENT, (SendDlgItemMessageA(hDlg, IDC_DBG_PICKCURRENT, BM_GETCHECK, 0, 0) == BST_CHECKED));
SETFLAG(debugFlags, DBG_FLAGS_NOSUNAMB, (SendDlgItemMessageA(hDlg, IDC_DBG_NOSUNAMB, BM_GETCHECK, 0, 0) == BST_CHECKED));
SETFLAG(debugFlags, DBG_FLAGS_NOPLNAMB, (SendDlgItemMessageA(hDlg, IDC_DBG_NOPLNAMB, BM_GETCHECK, 0, 0) == BST_CHECKED));

Config->EnableLimiter = (int)((debugFlags&DBG_FLAGS_FPSLIM)>0);
}
Expand Down Expand Up @@ -650,6 +653,16 @@ void OpenDlgClbk(void *context)
SendDlgItemMessageA(hDlg, IDC_DBG_ENVMAP, CB_ADDSTRING, 0, (LPARAM)"LightVisbil.");
SendDlgItemMessageA(hDlg, IDC_DBG_ENVMAP, CB_ADDSTRING, 0, (LPARAM)"BakedLightMap");
SendDlgItemMessageA(hDlg, IDC_DBG_ENVMAP, CB_SETCURSEL, 0, 0);

SendDlgItemMessageA(hDlg, IDC_DBG_AMBDIR, CB_RESETCONTENT, 0, 0);
SendDlgItemMessageA(hDlg, IDC_DBG_AMBDIR, CB_ADDSTRING, 0, (LPARAM)"Omnidir");
SendDlgItemMessageA(hDlg, IDC_DBG_AMBDIR, CB_ADDSTRING, 0, (LPARAM)"From Up (+y)");
SendDlgItemMessageA(hDlg, IDC_DBG_AMBDIR, CB_ADDSTRING, 0, (LPARAM)"From Down (-y)");
SendDlgItemMessageA(hDlg, IDC_DBG_AMBDIR, CB_ADDSTRING, 0, (LPARAM)"From Left (-x)");
SendDlgItemMessageA(hDlg, IDC_DBG_AMBDIR, CB_ADDSTRING, 0, (LPARAM)"From Right (+x)");
SendDlgItemMessageA(hDlg, IDC_DBG_AMBDIR, CB_ADDSTRING, 0, (LPARAM)"From Fwd (+z)");
SendDlgItemMessageA(hDlg, IDC_DBG_AMBDIR, CB_ADDSTRING, 0, (LPARAM)"From Aft (-z)");
SendDlgItemMessageA(hDlg, IDC_DBG_AMBDIR, CB_SETCURSEL, 0, 0);

SendDlgItemMessageA(hDlg, IDC_DBG_BKLID, CB_RESETCONTENT, 0, 0);
for (int i = 0; i < 16; i++) {
Expand Down Expand Up @@ -2192,6 +2205,12 @@ INT_PTR CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
}
break;

case IDC_DBG_AMBDIR:
if (HIWORD(wParam) == CBN_SELCHANGE) {
ambdir = int(SendDlgItemMessage(hDlg, IDC_DBG_AMBDIR, CB_GETCURSEL, 0, 0)) - 1;
}
break;

case IDC_DBG_DISPLAY:
if (HIWORD(wParam)==CBN_SELCHANGE) dspMode = DWORD(SendDlgItemMessage(hWnd, IDC_DBG_DISPLAY, CB_GETCURSEL, 0, 0));
break;
Expand Down Expand Up @@ -2322,6 +2341,8 @@ INT_PTR CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
case IDC_DBG_CLIPDIST:
case IDC_DBG_EXTVC:
case IDC_DBG_PICKCURRENT:
case IDC_DBG_NOSUNAMB:
case IDC_DBG_NOPLNAMB:
UpdateFlags();
break;

Expand Down
3 changes: 3 additions & 0 deletions OVP/D3D9Client/DebugControls.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@
#define DBG_FLAGS_NEARCLIP 0x8000 ///< Set Clip distance to 2cm
#define DBG_FLAGS_RENDEREXT 0x10000 ///< Render exterior meshes for VC view
#define DBG_FLAGS_PICKCURRENT 0x20000 ///< Only use Pick for current mesh
#define DBG_FLAGS_NOSUNAMB 0x40000 ///< Disable sun ambient effect in VC
#define DBG_FLAGS_NOPLNAMB 0x80000 ///< Disable planet shine ambient effect in VC
/// @}


Expand All @@ -73,6 +75,7 @@ class vObject;

namespace DebugControls {

extern int ambdir;
extern DWORD sMesh;
extern DWORD sGroup;
extern DWORD debugFlags;
Expand Down
26 changes: 20 additions & 6 deletions OVP/D3D9Client/Mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ void D3D9Mesh::LoadBakedLights()
}
}

for (int i = 0; i < 16; i++) BakedLightsControl[i] = FVECTOR3(1.0f, 1.0f, 1.0f);
for (int i = 0; i < 16; i++) BakedLightsControl[i] = FVECTOR3(0.0f, 0.0f, 0.0f);

bli = BakedLights.begin();
}
Expand Down Expand Up @@ -658,6 +658,7 @@ void D3D9Mesh::BakeAO(ImageProcessing* pBaker, const FVECTOR3 &vSun, const LVLH
FVECTOR3 ParTexCoord[6];
bool bSE[6];
float fShine = 1.0f;
bool bShine = true;

// Compute texcoords for Irradiance lookup for prime directions
//
Expand All @@ -675,24 +676,37 @@ void D3D9Mesh::BakeAO(ImageProcessing* pBaker, const FVECTOR3 &vSun, const LVLH
//
for (int i = 0; i < 6; i++)
{
auto tex = bli->second.pSunAO[i];
bSE[i] = false;
control[i] = 0.0f;

if (DebugControls::IsActive())
if ((DebugControls::ambdir != i) && (DebugControls::ambdir != -1)) continue;

auto tex = bli->second.pSunAO[i];
bSE[i] = (tex != NULL);
if (tex)
{
pBaker->SetTextureNative(i, tex, flags);
control[i] = saturate(dot(GetDir(i), vSun));
control[i] *= control[i];
}
else {
control[i] = 0.0f;
}
}
}

if (DebugControls::IsActive()) {
if (DebugControls::debugFlags & DBG_FLAGS_NOSUNAMB)
for (int i = 0; i < 6; i++) control[i] = 0;
if (DebugControls::debugFlags & DBG_FLAGS_NOPLNAMB)
fShine = 0.0f, bShine = false;
}

if (pIrrad == nullptr) fShine = 0.0f, bShine = false;

pBaker->SetTextureNative("tIrrad", pIrrad, IPF_LINEAR | IPF_CLAMP);
pBaker->SetFloat("fControl", control, sizeof(control));
pBaker->SetFloat("vParTexPos", ParTexCoord, sizeof(ParTexCoord));
pBaker->SetFloat("fShine", &fShine, sizeof(fShine));
pBaker->SetBool("bEnabled", bSE, sizeof(bSE));
pBaker->SetBool("bShine", &bShine, sizeof(bShine));

LPDIRECT3DSURFACE9 pSrf = NULL;

Expand Down
4 changes: 3 additions & 1 deletion OVP/D3D9Client/VVessel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -716,14 +716,16 @@ void vVessel::BakeLights(ImageProcessing *pBaker)
lvlh.East = tmul(FVECTOR4(lvlh.East, 0), mW).xyz;
lvlh.North = tmul(FVECTOR4(lvlh.North, 0), mW).xyz;

auto maps = GetEnvMap();

for (int i = 0; i < nmesh; i++)
{
if (!meshlist[i].mesh) continue;
if (meshlist[i].vismode & MESHVIS_VC)
{
auto vSun = tmul(FVECTOR4(sundir, 0), mW);
meshlist[i].mesh->BakeLights(pBaker);
meshlist[i].mesh->BakeAO(pBaker, vSun.xyz, lvlh, ecDefExt.tex.pIrrad);
meshlist[i].mesh->BakeAO(pBaker, vSun.xyz, lvlh, maps->pIrrad);
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions OVP/D3D9Client/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -239,3 +239,6 @@
#define IDC_DBG_DYNAMIC 3056
#define IDC_DBG_ISVCMESH 3057
#define IDC_DBG_VCSHADOW 3058
#define IDC_DBG_AMBDIR 3059
#define IDC_DBG_NOSUNAMB 3060
#define IDC_DBG_NOPLNAMB 3061
9 changes: 6 additions & 3 deletions OVP/D3D9Client/shaders/PreBakeLights.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ uniform extern float3 fControl[16];
uniform extern int iCount;
uniform extern bool bEnabled[6];
uniform extern float fShine;
uniform extern bool bShine;

sampler tMap[16] : register(s0); // Lightmaps
sampler tAO[6] : register(s0); // AO Textures for prime directions
Expand Down Expand Up @@ -60,11 +61,13 @@ float4 PSSunAO(float x : TEXCOORD0, float y : TEXCOORD1) : COLOR

// For a given pixel in texture (x,y)
[unroll] for (int i = 0; i < 6; i++) { // Browse through direction
if (bEnabled[i]) {
// Get planet shine color for a given direction 'i'
float3 cShine = ParaboloidalSampler(tIrrad, vParTexPos[i]).rgb;
if (bEnabled[i]) {
// Get ambient distribution inside VC for a given light direction 'i'
float3 ad = tex2D(tAO[i], float2(x, y)).rgb;

float3 cShine = 0.0f;
// Get planet shine color for a given direction 'i'
if (bShine) cShine = ParaboloidalSampler(tIrrad, vParTexPos[i]).rgb;
// Compute sunlight and planet shine factors
float3 shineAO = ad * cShine * fShine;
float3 sunAO = ad * fControl[i];
Expand Down

0 comments on commit 4534b74

Please sign in to comment.