Skip to content

Commit

Permalink
fix a sky issue - add ff - add sample rtx mod - update conf
Browse files Browse the repository at this point in the history
  • Loading branch information
xoxor4d committed Mar 17, 2024
1 parent ae6796e commit b4db81a
Show file tree
Hide file tree
Showing 9 changed files with 751 additions and 38 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
This client modification is made to make the game compatible with nvidia's [rtx-remix](https://github.com/NVIDIAGameWorks/rtx-remix).
How? By manually reimplementing fixed function rendering :)

It does __not__ come with a 'rtx mod' -> meaning no custom models nor materials.
It does come with a sample 'rtx mod' which places a few lights and has few custom materials.

<br>

Expand Down Expand Up @@ -56,6 +56,7 @@ remix runtime - https://github.com/NVIDIAGameWorks/dxvk-remix/actions
## ⚠️ Current issues:
- vid_restart (changing resolution / refreshrate) should generally work but might cause the game to be unstable afterwards
- main menu TV might behave odd and will be darker after a map was loaded (changing hash etc)
- there are still a few objects that wobble, indicating that they are rendered using shaders

<br>

Expand Down
63 changes: 63 additions & 0 deletions assets/main/rtx.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
seta fx_marks "1"
seta fx_marks_ents "1"
seta fx_marks_smodels "1"
seta r_aaAlpha "dither (fast)"
seta r_aspectRatio "auto"
seta r_autopriority "0"
seta r_backBufferSize "128"
seta r_backBufferSizeY "128"
seta r_blur_allowed "0"
seta r_clipCodec "MJPEG"
seta r_clipFPS "24"
seta r_clipSize "360"
seta r_customMode ""
seta r_debugLineWidth "1"
seta r_displayRefresh "120 Hz"
seta r_enablePlayerShadow "0"
seta r_filmLut "-1"
seta r_flame_allowed "1"
seta r_flameFX_distortionScaleFactor "0 1 1 0.511918"
seta r_flameFX_enable "0"
seta r_flameFX_fadeDuration "0.5"
seta r_flameFX_FPS "15"
seta r_flameFX_magnitude "0.0215147"
seta r_fovScaleThresholdRigid "2.4"
seta r_fovScaleThresholdSkinned "2.4"
seta r_fullscreen "0"
seta r_gamma "0.9"
seta r_gfxopt_dynamic_foliage "1"
seta r_gfxopt_water_simulation "1"
seta r_ignorehwgamma "0"
seta r_inGameVideo "1"
seta r_lodBiasRigid "0"
seta r_lodBiasSkinned "0"
seta r_mode "1920x1200"
seta r_monitor "0"
seta r_motionblur_directionFactor "0.001"
seta r_motionblur_frameBased_enable "0"
seta r_motionblur_maxblur "30"
seta r_motionblur_numberOfSamples "1"
seta r_motionblur_positionFactor "0.01"
seta r_multithreaded_device "1"
seta r_noborder "0"
seta r_picmip "0"
seta r_picmip_bump "3"
seta r_picmip_manual "1"
seta r_picmip_spec "0"
seta r_picmip_water "1"
seta r_polygonOffsetBias "-1"
seta r_polygonOffsetScale "-1"
seta r_portalBevels "0.7"
seta r_rendererPreference "Default"
seta r_reviveFX_debug "0"
seta r_reviveFX_fadeDuration "5"
seta r_texFilterAnisoMax "16"
seta r_texFilterAnisoMin "16"
seta r_texFilterMipMode "Force Trilinear"
seta r_use_driver_convergence "0"
seta r_waterSheetingFX_allowed "1"
seta r_waterSheetingFX_distortionScaleFactor "0.021961 1 0 0"
seta r_waterSheetingFX_enable "0"
seta r_waterSheetingFX_fadeDuration "2"
seta r_waterSheetingFX_magnitude "0.0655388"
seta r_waterSheetingFX_radius "4.44051"
686 changes: 653 additions & 33 deletions assets/rtx.conf

Large diffs are not rendered by default.

Binary file added assets/sample-mod.zip
Binary file not shown.
Binary file added assets/zone/Common/xcommon_rtx.ff
Binary file not shown.
27 changes: 25 additions & 2 deletions src/components/modules/sp/fixed_function.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,13 +298,22 @@ namespace components::sp
if (const auto identity = game::sp::gfxCmdBufSourceState->u.input.codeImages[game::TEXTURE_SRC_CODE_IDENTITY_NORMAL_MAP];
identity && identity->texture.basemap)
{
game::sp::dx->device->SetTexture(0, identity->texture.basemap);
// reduce rapid sky switching on some maps?
if (fixed_function::last_valid_sky_texture)
{
game::sp::dx->device->SetTexture(0, fixed_function::last_valid_sky_texture);
}
else
{
game::sp::dx->device->SetTexture(0, identity->texture.basemap);
}
}
}
else
{
// non cubemap images or cubemaps that were replaced with kowloon
game::sp::dx->device->SetTexture(0, state->material->textureTable->u.image->texture.basemap);
fixed_function::last_valid_sky_texture = state->material->textureTable->u.image->texture.basemap;
}

/*main_module::setup_sky_image(state->material->textureTable->u.image);
Expand Down Expand Up @@ -482,6 +491,7 @@ namespace components::sp
//R_FatalLockError(hr);
//game::sp::Com_Error(0, "Fatal lock error :: R_SetIndexData");
__debugbreak();
return -1;
}

if (buffer_data)
Expand Down Expand Up @@ -952,6 +962,8 @@ namespace components::sp
unsigned int base_index = 0u, count = 0u, tri_count = 0u;
auto base_vertex = -1;

bool early_out = false;

while (R_ReadBspDrawSurfs(&drawStream->primDrawSurfPos, &list, &count))
{
for (auto index = 0u; index < count; ++index)
Expand All @@ -964,6 +976,12 @@ namespace components::sp
{
//const auto base = R_SetIndexData(state, &game::sp::rgp->world->draw.indices[prev_tris->baseIndex], tri_count);
const auto base = R_SetIndexData(state, &game::sp::get_g_world_draw()->indices[prev_tris->baseIndex], tri_count);
if (base < 0)
{
early_out = true;
break;
}

R_DrawBspTris(state, prev_tris, base, tri_count);
}

Expand All @@ -980,9 +998,14 @@ namespace components::sp

tri_count += bsp_surf->tris.triCount;
}

if (early_out)
{
break;
}
}

if (prev_tris)
if (!early_out && prev_tris)
{
const auto base = R_SetIndexData(state, &game::sp::get_g_world_draw()->indices[prev_tris->baseIndex], tri_count);
R_DrawBspTris(state, prev_tris, base, tri_count);
Expand Down
2 changes: 2 additions & 0 deletions src/components/modules/sp/fixed_function.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ namespace components::sp
~fixed_function() = default;
const char* get_name() override { return "fixed_function_sp"; }

static inline IDirect3DBaseTexture9* last_valid_sky_texture = nullptr;

private:
};
}
4 changes: 4 additions & 0 deletions src/components/modules/sp/main_module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,8 @@ namespace components::sp
main_module::m_sky_texture->Release();
main_module::m_sky_texture = nullptr;
}

fixed_function::fixed_function::last_valid_sky_texture = nullptr;
}

// > fixed_function::free_fixed_function_buffers_stub
Expand All @@ -664,6 +666,8 @@ namespace components::sp
main_module::m_sky_texture->Release();
main_module::m_sky_texture = nullptr;
}

fixed_function::fixed_function::last_valid_sky_texture = nullptr;
}

void ui_3d_render_to_texture(game::GfxViewInfo* view)
Expand Down
4 changes: 2 additions & 2 deletions src/components/modules/sp/rtx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -385,8 +385,8 @@ namespace components::sp
// disable mins culling
utils::hook::nop(0x7215D9, 6);

// ^ for smodels
// 0x72173F -> 2 byte -> jne 0072175F
// ^ for smodels - TODO - make dvar for this?
utils::hook::nop(0x72173F, 2);

// never cull brushmodels via dpvs
utils::hook::nop(0x74784D, 2);
Expand Down

0 comments on commit b4db81a

Please sign in to comment.