Skip to content

Commit 1c04be9

Browse files
authored
Merge pull request scp-fs2open#1624 from asarium/cleanup/grFog
Remove gr_set_fog
2 parents 6d52cab + c463709 commit 1c04be9

10 files changed

Lines changed: 44 additions & 113 deletions

File tree

code/graphics/2d.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,6 @@ typedef struct screen {
632632

633633
int current_alphablend_mode; // See GR_ALPHABLEND defines above
634634
int current_bitblt_mode; // See GR_BITBLT_MODE defines above
635-
int current_fog_mode; // See GR_FOGMODE_* defines above
636635
int current_bitmap;
637636
color current_color;
638637
color current_fog_color; // current fog color
@@ -695,9 +694,6 @@ typedef struct screen {
695694
// grab a region of the screen. assumes data is large enough
696695
void (*gf_get_region)(int front, int w, int h, ubyte *data);
697696

698-
// set fog attributes
699-
void (*gf_fog_set)(int fog_mode, int r, int g, int b, float fog_near, float fog_far);
700-
701697
// poly culling
702698
int (*gf_set_cull)(int cull);
703699

@@ -929,11 +925,6 @@ void gr_shield_icon(coord2d coords[6], const int resize_mode = GR_RESIZE_FULL);
929925

930926
#define gr_get_region GR_CALL(gr_screen.gf_get_region)
931927

932-
__inline void gr_fog_set(int fog_mode, int r, int g, int b, float fog_near = -1.0f, float fog_far = -1.0f)
933-
{
934-
(*gr_screen.gf_fog_set)(fog_mode, r, g, b, fog_near, fog_far);
935-
}
936-
937928
#define gr_set_cull GR_CALL(gr_screen.gf_set_cull)
938929
#define gr_set_color_buffer GR_CALL(gr_screen.gf_set_color_buffer)
939930

code/graphics/grstub.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -438,8 +438,6 @@ bool gr_stub_init()
438438

439439
gr_screen.gf_set_gamma = gr_stub_set_gamma;
440440

441-
gr_screen.gf_fog_set = gr_stub_fog_set;
442-
443441
// UnknownPlayer : Don't recognize this - MAY NEED DEBUGGING
444442
gr_screen.gf_get_region = gr_stub_get_region;
445443

code/graphics/material.cpp

Lines changed: 25 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -195,13 +195,6 @@ Depth_bias(0)
195195
Texture_maps[TM_SPEC_GLOSS_TYPE] = -1;
196196
Texture_maps[TM_AMBIENT_TYPE] = -1;
197197

198-
Fog_params.dist_near = -1.0f;
199-
Fog_params.dist_far = -1.0f;
200-
Fog_params.r = 0;
201-
Fog_params.g = 0;
202-
Fog_params.b = 0;
203-
Fog_params.enabled = false;
204-
205198
Clip_params.enabled = false;
206199

207200
Color_mask.x = true;
@@ -302,31 +295,6 @@ int material::get_texture_addressing() const
302295
return Texture_addressing;
303296
}
304297

305-
void material::set_fog(int r, int g, int b, float _near, float _far)
306-
{
307-
Fog_params.enabled = true;
308-
Fog_params.r = r;
309-
Fog_params.g = g;
310-
Fog_params.b = b;
311-
Fog_params.dist_near = _near;
312-
Fog_params.dist_far = _far;
313-
}
314-
315-
void material::set_fog()
316-
{
317-
Fog_params.enabled = false;
318-
}
319-
320-
bool material::is_fogged() const
321-
{
322-
return Fog_params.enabled;
323-
}
324-
325-
const material::fog& material::get_fog() const
326-
{
327-
return Fog_params;
328-
}
329-
330298
void material::set_depth_mode(gr_zbuffer_type mode)
331299
{
332300
Depth_mode = mode;
@@ -654,6 +622,31 @@ float model_material::get_normal_extrude_width() const
654622
return Normal_extrude_width;
655623
}
656624

625+
void model_material::set_fog(int r, int g, int b, float _near, float _far)
626+
{
627+
Fog_params.enabled = true;
628+
Fog_params.r = r;
629+
Fog_params.g = g;
630+
Fog_params.b = b;
631+
Fog_params.dist_near = _near;
632+
Fog_params.dist_far = _far;
633+
}
634+
635+
void model_material::set_fog()
636+
{
637+
Fog_params.enabled = false;
638+
}
639+
640+
bool model_material::is_fogged() const
641+
{
642+
return Fog_params.enabled;
643+
}
644+
645+
const model_material::fog& model_material::get_fog() const
646+
{
647+
return Fog_params;
648+
}
649+
657650
uint model_material::get_shader_flags() const
658651
{
659652
uint Shader_flags = 0;

code/graphics/material.h

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,6 @@ enum class StencilOperation {
3030
class material
3131
{
3232
public:
33-
struct fog
34-
{
35-
bool enabled;
36-
int r;
37-
int g;
38-
int b;
39-
float dist_near;
40-
float dist_far;
41-
};
42-
4333
struct clip_plane
4434
{
4535
bool enabled;
@@ -74,7 +64,6 @@ class material
7464

7565
clip_plane Clip_params;
7666
int Texture_addressing;
77-
fog Fog_params;
7867
gr_zbuffer_type Depth_mode;
7968
gr_alpha_blend Blend_mode;
8069
bool Cull_mode;
@@ -112,11 +101,6 @@ class material
112101
void set_texture_addressing(int addressing);
113102
int get_texture_addressing() const;
114103

115-
void set_fog(int r, int g, int b, float near, float far);
116-
void set_fog();
117-
bool is_fogged() const;
118-
const fog& get_fog() const;
119-
120104
void set_depth_mode(gr_zbuffer_type mode);
121105
gr_zbuffer_type get_depth_mode() const;
122106

@@ -165,6 +149,18 @@ class material
165149

166150
class model_material : public material
167151
{
152+
public:
153+
struct fog
154+
{
155+
bool enabled = false;
156+
int r = 0;
157+
int g = 0;
158+
int b = 0;
159+
float dist_near = -1.0f;
160+
float dist_far = -1.0f;
161+
};
162+
163+
private:
168164
bool Desaturate = false;
169165

170166
bool Shadow_casting = false;
@@ -193,6 +189,7 @@ class model_material : public material
193189
bool Normal_extrude = false;
194190
float Normal_extrude_width = -1.0f;
195191

192+
fog Fog_params;
196193
public:
197194
model_material();
198195

@@ -244,6 +241,11 @@ class model_material : public material
244241
bool is_batched() const;
245242

246243
virtual uint get_shader_flags() const override;
244+
245+
void set_fog(int r, int g, int b, float near, float far);
246+
void set_fog();
247+
bool is_fogged() const;
248+
const fog& get_fog() const;
247249
};
248250

249251
class particle_material : public material

code/graphics/opengl/gropengl.cpp

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -409,21 +409,6 @@ void gr_opengl_cleanup(bool closing, int minimize)
409409
graphic_operations.reset();
410410
}
411411

412-
void gr_opengl_fog_set(int fog_mode, int r, int g, int b, float fog_near, float fog_far)
413-
{
414-
// mprintf(("gr_opengl_fog_set(%d,%d,%d,%d,%f,%f)\n",fog_mode,r,g,b,fog_near,fog_far));
415-
416-
Assert((r >= 0) && (r < 256));
417-
Assert((g >= 0) && (g < 256));
418-
Assert((b >= 0) && (b < 256));
419-
420-
if (fog_mode == GR_FOGMODE_NONE) {
421-
gr_screen.current_fog_mode = fog_mode;
422-
423-
return;
424-
}
425-
}
426-
427412
int gr_opengl_set_cull(int cull)
428413
{
429414
GLboolean enabled = GL_FALSE;
@@ -1107,8 +1092,6 @@ void opengl_setup_function_pointers()
11071092

11081093
gr_screen.gf_set_gamma = gr_opengl_set_gamma;
11091094

1110-
gr_screen.gf_fog_set = gr_opengl_fog_set;
1111-
11121095
// UnknownPlayer : Don't recognize this - MAY NEED DEBUGGING
11131096
gr_screen.gf_get_region = gr_opengl_get_region;
11141097

code/graphics/opengl/gropengltnl.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -669,14 +669,6 @@ void opengl_tnl_set_material(material* material_info, bool set_base_map, bool se
669669

670670
gr_set_fill_mode(material_info->get_fill_mode());
671671

672-
auto& fog_params = material_info->get_fog();
673-
674-
if ( fog_params.enabled ) {
675-
gr_fog_set(GR_FOGMODE_FOG, fog_params.r, fog_params.g, fog_params.b, fog_params.dist_near, fog_params.dist_far);
676-
} else {
677-
gr_fog_set(GR_FOGMODE_NONE, 0, 0, 0);
678-
}
679-
680672
gr_set_texture_addressing(material_info->get_texture_addressing());
681673

682674
if (set_clipping) {

code/graphics/uniforms.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ void convert_model_material(model_uniform_data* data_out,
248248

249249

250250
if (shader_flags & SDR_FLAG_MODEL_FOG) {
251-
material::fog fog_params = material.get_fog();
251+
auto& fog_params = material.get_fog();
252252

253253
if (fog_params.enabled) {
254254
data_out->fogStart = fog_params.dist_near;

code/nebula/neb.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1074,7 +1074,6 @@ void neb2_render_player()
10741074
//gr_set_bitmap(Neb2_cubes[idx1][idx2][idx3].bmap, GR_ALPHABLEND_FILTER, GR_BITBLT_MODE_NORMAL, (alpha + Neb2_cubes[idx1][idx2][idx3].flash));
10751075

10761076
gr_set_lighting(false, false);
1077-
//gr_fog_set(GR_FOGMODE_NONE, 0, 0, 0);
10781077
//g3_draw_rotated_bitmap(&p, fl_radians(Neb2_cubes[idx1][idx2][idx3].rot), Nd->prad, TMAP_FLAG_TEXTURED);
10791078
material mat_params;
10801079
material_set_unlit(&mat_params, Neb2_cubes[idx1][idx2][idx3].bmap, alpha + Neb2_cubes[idx1][idx2][idx3].flash, true, true);

code/object/objectsort.cpp

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -265,12 +265,6 @@ void obj_render_all(void (*render_function)(object *objp), bool *draw_viewer_las
265265
// get the fog values
266266
neb2_get_adjusted_fog_values(&fog_near, &fog_far, obj);
267267

268-
// only reset fog if the fog mode has changed - since regenerating a fog table takes
269-
// a bit of time
270-
if((fog_near != gr_screen.fog_near) || (fog_far != gr_screen.fog_far)){
271-
gr_fog_set(GR_FOGMODE_FOG, gr_screen.current_fog_color.red, gr_screen.current_fog_color.green, gr_screen.current_fog_color.blue, fog_near, fog_far);
272-
}
273-
274268
// maybe skip rendering an object because its obscured by the nebula
275269
if(neb2_skip_render(obj, os->z)){
276270
continue;
@@ -308,12 +302,6 @@ void obj_render_all(void (*render_function)(object *objp), bool *draw_viewer_las
308302
// get the fog values
309303
neb2_get_adjusted_fog_values(&fog_near, &fog_far, obj);
310304

311-
// only reset fog if the fog mode has changed - since regenerating a fog table takes
312-
// a bit of time
313-
if((GR_FOGMODE_FOG != gr_screen.current_fog_mode) || (fog_near != gr_screen.fog_near) || (fog_far != gr_screen.fog_far)) {
314-
gr_fog_set(GR_FOGMODE_FOG, gr_screen.current_fog_color.red, gr_screen.current_fog_color.green, gr_screen.current_fog_color.blue, fog_near, fog_far);
315-
}
316-
317305
// maybe skip rendering an object because its obscured by the nebula
318306
if(neb2_skip_render(obj, os->z)){
319307
continue;
@@ -327,11 +315,6 @@ void obj_render_all(void (*render_function)(object *objp), bool *draw_viewer_las
327315

328316
batching_render_all();
329317
batching_render_all(true);
330-
331-
// if we're fullneb, switch off the fog effet
332-
if((The_mission.flags[Mission::Mission_Flags::Fullneb]) && (Neb2_render_mode != NEB2_RENDER_NONE)){
333-
gr_fog_set(GR_FOGMODE_NONE, 0, 0, 0);
334-
}
335318
}
336319

337320
void obj_render_queue_all()
@@ -417,11 +400,6 @@ void obj_render_queue_all()
417400

418401
gr_reset_lighting();
419402
gr_set_lighting(false, false);
420-
421-
// if we're fullneb, switch off the fog effet
422-
if((The_mission.flags[Mission::Mission_Flags::Fullneb]) && (Neb2_render_mode != NEB2_RENDER_NONE)){
423-
gr_fog_set(GR_FOGMODE_NONE, 0, 0, 0);
424-
}
425403

426404
batching_render_all();
427405

code/starfield/starfield.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1694,11 +1694,6 @@ void stars_draw_debris()
16941694

16951695
gr_set_color( 0, 0, 0 );
16961696

1697-
// turn off fogging
1698-
if (The_mission.flags[Mission::Mission_Flags::Fullneb]) {
1699-
gr_fog_set(GR_FOGMODE_NONE, 0, 0, 0);
1700-
}
1701-
17021697
old_debris * d = odebris;
17031698

17041699
for (i=0; i<MAX_DEBRIS; i++, d++ ) {

0 commit comments

Comments
 (0)