Skip to content

Commit 06f576b

Browse files
Merge pull request #6925 from wookieejedi/fix-skybox-zbuffer
Fix/enhance skybox submodel rendering
2 parents d0c5fe6 + f903180 commit 06f576b

3 files changed

Lines changed: 20 additions & 0 deletions

File tree

code/mod_table/mod_table.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
int Directive_wait_time;
2929
bool True_loop_argument_sexps;
30+
bool Skybox_internal_depth_consistency;
3031
bool Fixed_turret_collisions;
3132
bool Fixed_missile_detonation;
3233
bool Damage_impacted_subsystem_first;
@@ -1137,6 +1138,10 @@ void parse_mod_table(const char *filename)
11371138

11381139
}
11391140

1141+
if (optional_string("$Skybox internal depth consistency:")) {
1142+
stuff_boolean(&Skybox_internal_depth_consistency);
1143+
}
1144+
11401145
optional_string("#OTHER SETTINGS");
11411146

11421147
if (optional_string("$Fixed Turret Collisions:")) {
@@ -1640,6 +1645,7 @@ void mod_table_reset()
16401645
{
16411646
Directive_wait_time = 3000;
16421647
True_loop_argument_sexps = false;
1648+
Skybox_internal_depth_consistency = false;
16431649
Fixed_turret_collisions = false;
16441650
Fixed_missile_detonation = false;
16451651
Damage_impacted_subsystem_first = false;
@@ -1820,5 +1826,6 @@ void mod_table_set_version_flags()
18201826
Use_model_eyepoint_normals = true;
18211827
Fix_asteroid_bounding_box_check = true;
18221828
Disable_expensive_turret_target_check = true;
1829+
Skybox_internal_depth_consistency = true;
18231830
}
18241831
}

code/mod_table/mod_table.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ struct splash_screen {
4141

4242
extern int Directive_wait_time;
4343
extern bool True_loop_argument_sexps;
44+
extern bool Skybox_internal_depth_consistency;
4445
extern bool Fixed_turret_collisions;
4546
extern bool Fixed_missile_detonation;
4647
extern bool Damage_impacted_subsystem_first;

code/starfield/starfield.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2322,7 +2322,19 @@ void stars_draw_background()
23222322
if (Nmodel_instance_num >= 0)
23232323
render_info.set_replacement_textures(model_get_instance(Nmodel_instance_num)->texture_replace);
23242324

2325+
// if No Z-Buffer is on in FRED then check mod flag to see
2326+
// if skybox submodels should still have proper z-sorting
2327+
// wookieejedi
2328+
bool special_z_buff = ((Nmodel_flags & MR_NO_ZBUFFER) && Skybox_internal_depth_consistency);
2329+
if (special_z_buff) {
2330+
render_info.set_flags(Nmodel_flags & ~MR_NO_ZBUFFER);
2331+
}
2332+
23252333
model_render_immediate(&render_info, Nmodel_num, Nmodel_instance_num, &Nmodel_orient, &Eye_position, MODEL_RENDER_ALL, false);
2334+
2335+
if (special_z_buff) {
2336+
gr_zbuffer_clear(TRUE);
2337+
}
23262338
}
23272339

23282340
void stars_set_background_model(int new_model, int new_bitmap, uint64_t flags, float alpha)

0 commit comments

Comments
 (0)