Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI Test #526

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions source_files/ddf/line.h
Original file line number Diff line number Diff line change
Expand Up @@ -965,6 +965,9 @@ class sectortype_c
float floor_bob;
float ceiling_bob;

rgbcol_t fog_color;
float fog_density;

private:
// disable copy construct and assignment operator
explicit sectortype_c(sectortype_c &rhs) { (void) rhs; }
Expand Down
9 changes: 9 additions & 0 deletions source_files/ddf/sector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ static const commandlist_t sect_commands[] =
DF("FLOOR_BOB", floor_bob, DDF_MainGetFloat),
DF("CEILING_BOB", ceiling_bob, DDF_MainGetFloat),

DF("FOG_COLOR", fog_color, DDF_MainGetRGB),
DF("FOG_DENSITY", fog_density, DDF_MainGetPercent),

DDF_CMD_END
};

Expand Down Expand Up @@ -516,6 +519,9 @@ void sectortype_c::CopyDetail(sectortype_c &src)

floor_bob = src.floor_bob;
ceiling_bob = src.ceiling_bob;

fog_color = src.fog_color;
fog_density = src.fog_density;
}

//
Expand Down Expand Up @@ -557,6 +563,9 @@ void sectortype_c::Default()

floor_bob = 0.0f;
ceiling_bob = 0.0f;

fog_color = RGB_NO_VALUE;
fog_density = 0;
}


Expand Down
2 changes: 1 addition & 1 deletion source_files/edge/m_option.cc
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ static menuinfo_t gameplay_optmenu =
static optmenuitem_t perfoptions[] =
{
{OPT_Boolean, "Draw Distance Culling", YesNo, 2,
&r_culling.d, M_UpdateCVARFromInt, NULL, &r_culling},
&r_culling.d, M_UpdateCVARFromInt, "Sector Fog will be disabled when this is On", &r_culling},
{OPT_FracSlider, "Maximum Draw Distance", NULL, 0,
&r_culldist.f, M_UpdateCVARFromFloat, "Only effective when Draw Distance Culling is On", &r_culldist, 200.0f, 1000.0f, 8000.0f, "%g Units"},
{OPT_Switch, "Outdoor Culling Fog Color", "Match Sky/White/Grey/Black", 4,
Expand Down
24 changes: 24 additions & 0 deletions source_files/edge/p_setup.cc
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,12 @@ static void LoadSectors(int lump)
ss->props.viscosity = VISCOSITY;
ss->props.drag = DRAG;

if (ss->props.special && ss->props.special->fog_color != RGB_NO_VALUE)
{
ss->props.fog_color = ss->props.special->fog_color;
ss->props.fog_density = 0.01f * ss->props.special->fog_density;
}

ss->p = &ss->props;

ss->sound_player = -1;
Expand Down Expand Up @@ -1451,6 +1457,8 @@ static void LoadUDMFSectors()
{
float cz = 0.0f, fz = 0.0f;
int light = 160, type = 0, tag = 0;
rgbcol_t fog_color = RGB_NO_VALUE;
int fog_density = 0;
char floor_tex[10];
char ceil_tex[10];
strcpy(floor_tex, "-");
Expand Down Expand Up @@ -1495,6 +1503,10 @@ static void LoadUDMFSectors()
type = epi::LEX_Int(value);
else if (key == "id")
tag = epi::LEX_Int(value);
else if (key == "fadecolor")
fog_color = epi::LEX_Int(value);
else if (key == "fogdensity")
fog_density = CLAMP(0, epi::LEX_Int(value), 100);
}
sector_t *ss = sectors + cur_sector;
ss->f_h = fz;
Expand Down Expand Up @@ -1547,6 +1559,18 @@ static void LoadUDMFSectors()
ss->props.viscosity = VISCOSITY;
ss->props.drag = DRAG;

// Allow UDMF sector fog information to override DDFSECT types
if (fog_color != RGB_NO_VALUE)
{
ss->props.fog_color = fog_color;
ss->props.fog_density = 0.0001f * fog_density;
}
else if (ss->props.special && ss->props.special->fog_color != RGB_NO_VALUE)
{
ss->props.fog_color = ss->props.special->fog_color;
ss->props.fog_density = 0.01f * ss->props.special->fog_density;
}

ss->p = &ss->props;

ss->sound_player = -1;
Expand Down
15 changes: 13 additions & 2 deletions source_files/edge/r_colormap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -660,10 +660,13 @@ class colormap_shader_c : public abstract_shader_c

rgbcol_t whites[32];

rgbcol_t fog_color;
float fog_density;

public:
colormap_shader_c(const colourmap_c *CM) : colmap(CM),
light_lev(255), fade_tex(0),
simple_cmap(true), lt_model(LMODEL_Doom)
simple_cmap(true), lt_model(LMODEL_Doom), fog_color(RGB_NO_VALUE), fog_density(0)
{ }

virtual ~colormap_shader_c()
Expand Down Expand Up @@ -739,7 +742,7 @@ class colormap_shader_c : public abstract_shader_c
local_gl_vert_t * glvert = RGL_BeginUnit(shape, num_vert,
GL_MODULATE, tex,
(simple_cmap || r_dumbmulti.d) ? GL_MODULATE : GL_DECAL,
fade_tex, *pass_var, blending);
fade_tex, *pass_var, blending, fog_color, fog_density);

for (int v_idx=0; v_idx < num_vert; v_idx++)
{
Expand Down Expand Up @@ -904,6 +907,12 @@ class colormap_shader_c : public abstract_shader_c
{
light_lev = _level;
}

void SetFog(rgbcol_t _fog_color, float _fog_density)
{
fog_color = _fog_color;
fog_density = _fog_density;
}
};


Expand Down Expand Up @@ -950,6 +959,8 @@ abstract_shader_c *R_GetColormapShader(const struct region_properties_s *props,

shader->SetLight(lit_Nom);

shader->SetFog(props->fog_color, props->fog_density);

return shader;
}

Expand Down
4 changes: 4 additions & 0 deletions source_files/edge/r_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ typedef struct region_properties_s
vec3_t net_push = {0,0,0};

vec3_t old_push = {0,0,0};

// sector fog
rgbcol_t fog_color = RGB_NO_VALUE;
float fog_density = 0;
}
region_properties_t;

Expand Down
4 changes: 1 addition & 3 deletions source_files/edge/r_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ DEF_CVAR(r_culling, "0", CVAR_ARCHIVE)
DEF_CVAR_CLAMPED(r_culldist, "3000", CVAR_ARCHIVE, 1000.0f, 16000.0f)
DEF_CVAR(r_cullfog, "0", CVAR_ARCHIVE)

DEF_CVAR(r_fogofwar, "0", CVAR_ARCHIVE)

//
// RGL_SetupMatrices2D
//
Expand Down Expand Up @@ -222,7 +220,7 @@ void RGL_SoftInit(void)
glCullFace(GL_BACK);
glDisable(GL_CULL_FACE);

glHint(GL_FOG_HINT, GL_FASTEST);
glHint(GL_FOG_HINT, GL_NICEST);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
}

Expand Down
7 changes: 5 additions & 2 deletions source_files/edge/r_md2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
extern float P_ApproxDistance(float dx, float dy, float dz);

extern cvar_c r_culling;
extern cvar_c r_fogofwar;

// #define DEBUG_MD2_LOAD 1

Expand Down Expand Up @@ -1231,12 +1230,16 @@ I_Debugf("Render model: bad frame %d\n", frame1);
glAlphaFunc(GL_GREATER, trans * 0.66f);
}

if (r_fogofwar.d || r_culling.d)
if (r_culling.d || props->fog_color != RGB_NO_VALUE)
{
if (pass > 0)
{
glDisable(GL_FOG);
}
else
{
glEnable(GL_FOG);
}
}

glActiveTexture(GL_TEXTURE1);
Expand Down
7 changes: 5 additions & 2 deletions source_files/edge/r_mdl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
extern float P_ApproxDistance(float dx, float dy, float dz);

extern cvar_c r_culling;
extern cvar_c r_fogofwar;

/*============== MDL FORMAT DEFINITIONS ====================*/

Expand Down Expand Up @@ -916,12 +915,16 @@ I_Debugf("Render model: bad frame %d\n", frame1);
glAlphaFunc(GL_GREATER, trans * 0.66f);
}

if (r_fogofwar.d || r_culling.d)
if (r_culling.d || props->fog_color != RGB_NO_VALUE)
{
if (pass > 0)
{
glDisable(GL_FOG);
}
else
{
glEnable(GL_FOG);
}
}

glActiveTexture(GL_TEXTURE1);
Expand Down
37 changes: 36 additions & 1 deletion source_files/edge/r_sky.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ extern epi::image_data_c *ReadAsEpiBlock(image_c *rim);

extern cvar_c r_culling;

static GLfloat sky_cap_color[4];
static GLfloat sky_cap_color[3];

static skystretch_e current_sky_stretch = SKS_Unset;

Expand Down Expand Up @@ -441,6 +441,21 @@ static void RGL_DrawSkyCylinder(void)
solid_sky_h = sky_h_ratio * 0.75f;
float cap_z = dist * sky_h_ratio;

if (!r_culling.d && view_props->fog_color != RGB_NO_VALUE)
{
rgbcol_t frgb = view_props->fog_color;
GLfloat fc[4];
fc[0] = (float)RGB_RED(frgb)/255.0f;
fc[1] = (float)RGB_GRN(frgb)/255.0f;
fc[2] = (float)RGB_BLU(frgb)/255.0f;
fc[3] = 1.0f;
glClearColor(fc[0],fc[1],fc[2],fc[3]);
glFogi(GL_FOG_MODE, GL_EXP);
glFogfv(GL_FOG_COLOR, fc);
glFogf(GL_FOG_DENSITY, std::log1p(view_props->fog_density * 0.005f));
glEnable(GL_FOG);
}

// Render top cap
glColor4f(sky_cap_color[0],sky_cap_color[1],sky_cap_color[2],1.0);
glBegin(GL_QUADS);
Expand Down Expand Up @@ -545,6 +560,8 @@ static void RGL_DrawSkyCylinder(void)

glDisable(GL_BLEND);
glDisable(GL_ALPHA_TEST);
if (!r_culling.d && current_fog_rgb != RGB_NO_VALUE)
glDisable(GL_FOG);

RGL_RevertSkyMatrices();
}
Expand Down Expand Up @@ -584,6 +601,21 @@ static void RGL_DrawSkyBox(void)
else
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, col);

if (!r_culling.d && view_props->fog_color != RGB_NO_VALUE)
{
rgbcol_t frgb = view_props->fog_color;
GLfloat fc[4];
fc[0] = (float)RGB_RED(frgb)/255.0f;
fc[1] = (float)RGB_GRN(frgb)/255.0f;
fc[2] = (float)RGB_BLU(frgb)/255.0f;
fc[3] = 1.0f;
glClearColor(fc[0],fc[1],fc[2],fc[3]);
glFogi(GL_FOG_MODE, GL_EXP);
glFogfv(GL_FOG_COLOR, fc);
glFogf(GL_FOG_DENSITY, std::log1p(view_props->fog_density * 0.01f));
glEnable(GL_FOG);
}

// top
glBindTexture(GL_TEXTURE_2D, fake_box[SK].tex[WSKY_Top]);
glNormal3i(0, 0, -1);
Expand Down Expand Up @@ -669,6 +701,8 @@ static void RGL_DrawSkyBox(void)
glEnd();

glDisable(GL_TEXTURE_2D);
if (!r_culling.d && current_fog_rgb != RGB_NO_VALUE)
glDisable(GL_FOG);

RGL_RevertSkyMatrices();
}
Expand Down Expand Up @@ -833,6 +867,7 @@ int RGL_UpdateSkyBoxTextures(void)
cull_fog_color[0] = (float)temp_rgb[0] / 255.0f;
cull_fog_color[1] = (float)temp_rgb[1] / 255.0f;
cull_fog_color[2] = (float)temp_rgb[2] / 255.0f;
cull_fog_color[3] = 1.0f;
tmp_img_data->AverageColor(temp_rgb, 0, sky_image->actual_w, sky_image->actual_h * 3/4, sky_image->actual_h);
sky_cap_color[0] = (float)temp_rgb[0] / 255.0f;
sky_cap_color[1] = (float)temp_rgb[1] / 255.0f;
Expand Down
6 changes: 4 additions & 2 deletions source_files/edge/r_things.cc
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,8 @@ static void RGL_DrawPSprite(pspdef_t * psp, int which,
local_gl_vert_t * glvert = RGL_BeginUnit(GL_POLYGON, 4,
is_additive ? ENV_SKIP_RGB : GL_MODULATE, tex_id,
is_fuzzy ? GL_MODULATE : ENV_NONE, fuzz_tex,
pass, blending);
pass, blending, pass > 0 ? RGB_NO_VALUE: player->mo->subsector->sector->props.fog_color,
player->mo->subsector->sector->props.fog_density);

for (int v_idx=0; v_idx < 4; v_idx++)
{
Expand Down Expand Up @@ -1459,7 +1460,8 @@ void RGL_DrawThing(drawfloor_t *dfloor, drawthing_t *dthing)
local_gl_vert_t * glvert = RGL_BeginUnit(GL_POLYGON, 4,
is_additive ? ENV_SKIP_RGB : GL_MODULATE, tex_id,
is_fuzzy ? GL_MODULATE : ENV_NONE, fuzz_tex,
pass, blending);
pass, blending, pass > 0 ? RGB_NO_VALUE : dthing->mo->subsector->sector->props.fog_color,
dthing->mo->subsector->sector->props.fog_density);

for (int v_idx=0; v_idx < 4; v_idx++)
{
Expand Down
Loading
Loading