Skip to content

Commit

Permalink
[rtx] refactor map settings (sun spawning, manual culling override)
Browse files Browse the repository at this point in the history
- add commandline arg `no_sun` (disable sun spawning via map settings)
- add console command `mapsettings_get_defaults` (prints default map sun-settings in to the console)
  • Loading branch information
xoxor4d committed Apr 6, 2024
1 parent 9733435 commit 431c7ea
Show file tree
Hide file tree
Showing 8 changed files with 298 additions and 89 deletions.
60 changes: 35 additions & 25 deletions assets-remix/iw3xo/rtx/map_settings.ini
Original file line number Diff line number Diff line change
@@ -1,25 +1,35 @@
// (0) mapname
// (1) skybox to use (rtx_gui::skysphere_get_name_for_variant)
// (2) distance at which fog reaches max value (can NOT be lower then 700)
// (3-4-5) r , g , b (0-255)
mp_backlot, 5, 4000, 240,200,200
mp_bloc, 4, 8000, 200,200,200
mp_bog, 3, 5000, 135, 81, 60
mp_broadcast, 5, 8000, 200,200,200
mp_carentan, 3, 4000, 180,160,220
mp_cargoship, 3, 4000, 80, 120,160
mp_citystreets, 5, 8000, 200,200,200
mp_convoy, 0, 1600, 200,190,180
mp_countdown, 5, 15000, 180,180,200
mp_crash, 5, 5000, 200,200,160
mp_crash_snow, 3, 4500, 200,200,240
mp_creek, 0, 8000, 200,200,200
mp_crossfire, 5, 5000, 200,200,200
mp_farm, 4, 1800, 150,200,220
mp_killhouse, 5, 8000, 210,200,205
mp_overgrown, 0, 8000, 200,200,200
mp_pipeline, 5, 8000, 200,200,200
mp_shipment, 4, 8000, 200,200,200
mp_showdown, 5, 8000, 200,200,200
mp_strike, 5, 4000, 200,200,200
mp_vacant, 0, 8000, 200,200,200
// (0) : mapname
// (1) : fog dist : distance at which fog reaches max value (can NOT be lower then 700)
// (2-3-4) : fog color : r , g , b (0-255)
// (5-6-7) : sun dir : x , y , z (angles of directional light [x=x] [y=-y+5] [z=z-45] .... x=(z=-45) y=y-5 z=x)
// (8-9-10) : sun color : r , g , b (0-255)
// (11) : sun intensity : color intensity scalar
// (12) : sky : sky index (0-8)
//
// mapname fog dist fog color sun direction sun color sun intensity sky
// ------------------------------------------------------------------------------------------------------------------
mp_backlot, 4000, 240,200,200, -0.657,-0.308,-0.688, 255.0,234.6,224.4, 1.30, 5
mp_bloc, 8000, 200,200,200, 0.321,-0.383,-0.866, 229.5,249.9,255.0, 0.90, 4
mp_bog, 5000, 135, 81, 60, 0.362,0.853,-0.375, 228.2,241.6,255.0, 0.80, 3
mp_broadcast, 8000, 200,200,200, -0.163,-0.925,-0.342, 255.0,216.8,170.9, 1.40, 5
mp_carentan, 4000, 180,160,220, -0.855,-0.060,-0.515, 204.0,229.5,255.0, 0.75, 3
mp_cargoship, 4000, 80, 120,160, -0.641,0.641,-0.423, 127.5,153.0,255.0, 1.30, 7
mp_citystreets, 8000, 200,200,200, 0.048,-0.388,-0.921, 255.0,234.6,224.4, 0.78, 5
mp_convoy, 1600, 200,190,180, -0.814,-0.296,-0.500, 255.0,228.0,159.0, 1.60, 5
mp_countdown, 15000, 180,180,200, -0.866,-0.000,-0.500, 255.0,204.0,153.0, 1.50, 5
mp_crash, 5000, 200,200,160, 0.321,0.557,-0.766, 255.0,234.6,224.4, 1.30, 5
mp_crash_snow, 4500, 200,200,240, 0.321,-0.383,-0.866, 165.8,178.5,255.0, 0.25, 3
mp_creek, 8000, 200,200,200, 0.685,0.367,-0.814, 254.6,255.0,249.0, 1.80, 0
mp_crossfire, 5000, 200,200,200, 0.462,-0.447,-0.766, 255.0,234.6,224.4, 1.00, 5
mp_farm, 1800, 150,200,220, 0.542,0.542,-0.643, 229.5,249.9,255.0, 1.00, 4
mp_killhouse, 8000, 210,200,205, -0.262,0.720,-0.643, 255.0,242.2,204.0, 1.50, 5
mp_overgrown, 20000, 200,200,200, -0.407,0.734,-0.545, 255.0,245.9,176.1, 1.10, 4
mp_pipeline, 8000, 200,200,200, 0.551,0.462,-0.695, 229.5,249.9,255.0, 1.15, 5
mp_shipment, 8000, 200,200,200, -0.455,-0.572,-0.682, 255.0,255.0,242.2, 1.30, 4
mp_showdown, 8000, 200,200,200, 0.389,-0.739,-0.550, 255.0,228.0,159.0, 1.60, 5
mp_strike, 4000, 200,200,200, 0.572,0.416,-0.707, 255.0,239.7,204.0, 1.00, 5
mp_vacant, 8000, 200,200,200, -0.641,-0.299,-0.707, 255.0,245.9,176.1, 1.30, 0
mp_mw3_hardhat, 2600, 200,200,200, 0.406,0.406,-0.819, 254.6,255.0,249.0, 1.50, 5

#CULL // [X: CELL to tweak](indices of cells always rendered when in X) -> display cell indices using dvar 'r_showCellIndex'
mp_backlot, [1](0 2), [2](1), [3](0), [4](0), [7](0 6 9 10), [9](0 10), [10](0), [11](0), [12](0), [14](0 11 16), [34](0 22 32)
45 changes: 36 additions & 9 deletions src/components/modules/rtx/rtx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,40 @@ namespace components

if (!flags::has_flag("no_fog"))
{
const auto s = rtx_map_settings::settings();
const float fog_start = 1.0f;

dev->SetRenderState(D3DRS_FOGENABLE, TRUE);
dev->SetRenderState(D3DRS_FOGCOLOR, rtx_map_settings::m_color.packed);
dev->SetRenderState(D3DRS_FOGCOLOR, s->fog_color.packed);
dev->SetRenderState(D3DRS_FOGVERTEXMODE, D3DFOG_LINEAR);
dev->SetRenderState(D3DRS_FOGSTART, *(DWORD*)(&fog_start));
dev->SetRenderState(D3DRS_FOGEND, *(DWORD*)(&rtx_map_settings::m_max_distance));
dev->SetRenderState(D3DRS_FOGEND, *(DWORD*)(&s->fog_distance));
}

if (!flags::has_flag("no_sun"))
{
// only set sun if debuglight 0 is not active
if (const auto l0 = &rtx_lights::rtx_debug_lights[0]; !l0->enable)
{
const auto s = rtx_map_settings::settings();

D3DLIGHT9 light = {};
light.Type = D3DLIGHT_DIRECTIONAL;
light.Diffuse.r = s->sun_color[0] * s->sun_intensity;
light.Diffuse.g = s->sun_color[1] * s->sun_intensity;
light.Diffuse.b = s->sun_color[2] * s->sun_intensity;

D3DXVec3Normalize((D3DXVECTOR3*)&light.Direction, (const D3DXVECTOR3*)&s->sun_direction);

dev->SetLight(0, &light);
dev->LightEnable(0, TRUE);

// update gui settings for debug light 0
l0->color_scale = s->sun_intensity;
l0->color[0] = s->sun_color[0]; l0->color[1] = s->sun_color[1]; l0->color[2] = s->sun_color[2];
l0->dir[0] = s->sun_direction[0]; l0->dir[1] = s->sun_direction[1]; l0->dir[2] = s->sun_direction[2];
l0->type = D3DLIGHT_DIRECTIONAL;
}
}
}

Expand Down Expand Up @@ -637,7 +665,7 @@ namespace components
// #
// force cells defined in map_settings.ini

/*const auto& cell_settings = map_settings::settings()->cell_settings;
const auto& cell_settings = rtx_map_settings::settings()->cell_settings;
if (!cell_settings.empty())
{
for (const auto& c : cell_settings)
Expand All @@ -646,19 +674,18 @@ namespace components
{
for (const auto& i : c.forced_cell_indices)
{
const auto forced_cell = &game::sp::rgp->world->cells[i];
const auto c_index = forced_cell - game::sp::rgp->world->cells;
game::sp::R_AddCellSurfacesAndCullGroupsInFrustumDelayed(forced_cell, dpvs->frustumPlanes, dpvs->frustumPlaneCount, dpvs->frustumPlaneCount);
dpvsGlob->cellVisibleBits[(c_index >> 5) + 3] |= (1 << (c_index & 0x1F)) & ~((1 << (c_index & 0x1F)) & dpvsGlob->cellForceInvisibleBits[(c_index >> 5) + 3]);
const auto forced_cell = &game::rgp->world->cells[i];
const auto c_index = forced_cell - game::rgp->world->cells;
game::R_AddCellSurfacesAndCullGroupsInFrustumDelayed(forced_cell, dpvs->frustumPlanes, dpvs->frustumPlaneCount, dpvs->frustumPlaneCount);
dpvsGlob->cellVisibleBits[(c_index >> 5) + 3] |= (1 << (c_index & 0x1F));
}

break;
}
}
}*/
}

// R_VisitPortals
//utils::hook::call<void(__cdecl)(game::GfxCell*, game::DpvsPlane*, game::DpvsPlane*, int)>(0x6B3DA0)(cell, &dpvsGlob->nearPlane, dpvs->frustumPlanes, dpvs->frustumPlaneCount);
game::R_VisitPortals(dpvs->frustumPlaneCount, cell, &dpvsGlob->viewPlane, dpvs->frustumPlanes); // viewplane here .. or is that the nearplane?
}
}
Expand Down
30 changes: 15 additions & 15 deletions src/components/modules/rtx/rtx_gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,25 +133,25 @@ namespace components
static float skygroup01_width = 0.0f;
gui::center_horz_begin(skygroup01_width);
{
if (ImGui::Button("Hill", ImVec2(BUTTON_WIDTH, 0)))
if (ImGui::Button("Hill [0]", ImVec2(BUTTON_WIDTH, 0)))
{
skysphere_spawn(SKY::CLEAR);
}

ImGui::SameLine();
if (ImGui::Button("Desert", ImVec2(BUTTON_WIDTH, 0)))
if (ImGui::Button("Desert [1]", ImVec2(BUTTON_WIDTH, 0)))
{
skysphere_spawn(SKY::DESERT);
}

ImGui::SameLine();
if (ImGui::Button("Night", ImVec2(BUTTON_WIDTH, 0)))
if (ImGui::Button("Night [3]", ImVec2(BUTTON_WIDTH, 0)))
{
skysphere_spawn(SKY::NIGHT);
}

ImGui::SameLine();
if (ImGui::Button("Night 2", ImVec2(BUTTON_WIDTH, 0)))
if (ImGui::Button("Night 2 [7]", ImVec2(BUTTON_WIDTH, 0)))
{
skysphere_spawn(SKY::NIGHT2);
}
Expand All @@ -162,25 +162,25 @@ namespace components
static float skygroup02_width = 0.0f;
gui::center_horz_begin(skygroup02_width);
{
if (ImGui::Button("Overcast", ImVec2(BUTTON_WIDTH, 0)))
if (ImGui::Button("Overcast [4]", ImVec2(BUTTON_WIDTH, 0)))
{
skysphere_spawn(SKY::OVERCAST);
}

ImGui::SameLine();
if (ImGui::Button("Sunset", ImVec2(BUTTON_WIDTH, 0)))
if (ImGui::Button("Sunset [5]", ImVec2(BUTTON_WIDTH, 0)))
{
skysphere_spawn(SKY::SUNSET);
}

ImGui::SameLine();
if (ImGui::Button("Galaxy 1", ImVec2(BUTTON_WIDTH, 0)))
if (ImGui::Button("Galaxy 1 [2]", ImVec2(BUTTON_WIDTH, 0)))
{
skysphere_spawn(SKY::GALAXY1);
}

ImGui::SameLine();
if (ImGui::Button("Galaxy 2", ImVec2(BUTTON_WIDTH, 0)))
if (ImGui::Button("Galaxy 2 [6]", ImVec2(BUTTON_WIDTH, 0)))
{
skysphere_spawn(SKY::GALAXY2);
}
Expand Down Expand Up @@ -303,7 +303,7 @@ namespace components
{
ImGui::PushID(i);

if (ImGui::CollapsingHeader(utils::va("Light %d", i), !i ? ImGuiTreeNodeFlags_DefaultOpen : ImGuiTreeNodeFlags_None))
if (ImGui::CollapsingHeader(!i ? "Light 0 - usually used as sun" : utils::va("Light %d", i), !i ? ImGuiTreeNodeFlags_DefaultOpen : ImGuiTreeNodeFlags_None))
{
bool on_edit = false;

Expand Down Expand Up @@ -414,7 +414,7 @@ namespace components

if (rtx_lights::rtx_debug_lights[i].type > D3DLIGHT_POINT)
{
on_edit = ImGui::DragFloat3("Direction", rtx_lights::rtx_debug_lights[i].dir, 0.05f) ? true : on_edit;
on_edit = ImGui::DragFloat3("Direction", rtx_lights::rtx_debug_lights[i].dir, 0.001f) ? true : on_edit;

if (rtx_lights::rtx_debug_lights[i].attach_to_head)
{
Expand All @@ -426,15 +426,15 @@ namespace components
{
if (rtx_lights::rtx_debug_lights[i].type == D3DLIGHT_SPOT)
{
on_edit = ImGui::DragFloat("Inner Angle", &rtx_lights::rtx_debug_lights[i].inner_angle, 0.25f) ? true : on_edit;
on_edit = ImGui::DragFloat("Outer Angle", &rtx_lights::rtx_debug_lights[i].outer_angle, 0.25f) ? true : on_edit;
on_edit = ImGui::DragFloat("Inner Angle", &rtx_lights::rtx_debug_lights[i].inner_angle, 0.05f) ? true : on_edit;
on_edit = ImGui::DragFloat("Outer Angle", &rtx_lights::rtx_debug_lights[i].outer_angle, 0.05f) ? true : on_edit;
}

on_edit = ImGui::DragFloat("Range", &rtx_lights::rtx_debug_lights[i].range, 0.25f) ? true : on_edit;
on_edit = ImGui::DragFloat("Range", &rtx_lights::rtx_debug_lights[i].range, 0.10f) ? true : on_edit;
}

on_edit = ImGui::ColorEdit3("Color", rtx_lights::rtx_debug_lights[i].color, ImGuiColorEditFlags_Float) ? true : on_edit;
on_edit = ImGui::DragFloat("Color Scale", &rtx_lights::rtx_debug_lights[i].color_scale, 0.1f) ? true : on_edit;
on_edit = ImGui::ColorEdit3("Color", rtx_lights::rtx_debug_lights[i].color, ImGuiColorEditFlags_RGB) ? true : on_edit;
on_edit = ImGui::DragFloat("Color Scale", &rtx_lights::rtx_debug_lights[i].color_scale, 0.005f) ? true : on_edit;

if (rtx_lights::rtx_debug_lights[i].type != D3DLIGHT_DIRECTIONAL)
{
Expand Down
Loading

0 comments on commit 431c7ea

Please sign in to comment.