mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2025-02-20 19:02:23 +00:00
GL3: Add hack to make lava glow, fix #1014
Normal warping surfaces (SURF_DRAWTURB) with water etc should use brightness 0.5*intensity (like they did before), but those with lava should be brighter, so use 1.0*intensity in the shader. The reason that intensity needs to be scaled down is that these surfaces have no lightmaps, so they'd be rendered fullbright otherwise. I'm using the simple heuristic of texturename contains "lava" to detect lava textures.
This commit is contained in:
parent
51cdc80525
commit
218ac53ce9
4 changed files with 34 additions and 12 deletions
|
@ -430,9 +430,10 @@ GL3_LoadPic(char *name, byte *pic, int width, int realwidth,
|
|||
if ((type == it_skin) && (bits == 8))
|
||||
{
|
||||
FloodFillSkin(pic, width, height);
|
||||
|
||||
}
|
||||
|
||||
image->is_lava = (strstr(name, "lava") != NULL);
|
||||
|
||||
// image->scrap = false; // TODO: reintroduce scrap? would allow optimizations in 2D rendering..
|
||||
|
||||
glGenTextures(1, &texNum);
|
||||
|
@ -810,29 +811,31 @@ GL3_ImageList_f(void)
|
|||
|
||||
texels += w*h;
|
||||
|
||||
char imageType = '?';
|
||||
switch (image->type)
|
||||
{
|
||||
case it_skin:
|
||||
R_Printf(PRINT_ALL, "M");
|
||||
imageType = 'M';
|
||||
break;
|
||||
case it_sprite:
|
||||
R_Printf(PRINT_ALL, "S");
|
||||
imageType = 'S';
|
||||
break;
|
||||
case it_wall:
|
||||
R_Printf(PRINT_ALL, "W");
|
||||
imageType = 'W';
|
||||
break;
|
||||
case it_pic:
|
||||
R_Printf(PRINT_ALL, "P");
|
||||
imageType = 'P';
|
||||
break;
|
||||
case it_sky:
|
||||
R_Printf(PRINT_ALL, "Y");
|
||||
imageType = 'Y';
|
||||
break;
|
||||
default:
|
||||
R_Printf(PRINT_ALL, "?");
|
||||
imageType = '?';
|
||||
break;
|
||||
}
|
||||
char isLava = image->is_lava ? 'L' : ' ';
|
||||
|
||||
R_Printf(PRINT_ALL, " %3i %3i %s %s: %s %s\n", w, h,
|
||||
R_Printf(PRINT_ALL, "%c%c %3i %3i %s %s: %s %s\n", imageType, isLava, w, h,
|
||||
formatstrings[image->has_alpha], potstrings[isNPOT], image->name, in_use);
|
||||
}
|
||||
|
||||
|
|
|
@ -367,9 +367,9 @@ static const char* vertexCommon3D = MULTILINE_STRING(
|
|||
float alpha;
|
||||
float overbrightbits;
|
||||
float particleFadeFactor;
|
||||
float lightScaleForTurb; // surfaces with SURF_DRAWTURB (water, lava) don't have lightmaps, use this instead
|
||||
float _pad_1; // AMDs legacy windows driver needs this, otherwise uni3D has wrong size
|
||||
float _pad_2;
|
||||
float _pad_3;
|
||||
};
|
||||
);
|
||||
|
||||
|
@ -399,9 +399,9 @@ static const char* fragmentCommon3D = MULTILINE_STRING(
|
|||
float alpha;
|
||||
float overbrightbits;
|
||||
float particleFadeFactor;
|
||||
float lightScaleForTurb; // surfaces with SURF_DRAWTURB (water, lava) don't have lightmaps, use this instead
|
||||
float _pad_1; // AMDs legacy windows driver needs this, otherwise uni3D has wrong size
|
||||
float _pad_2;
|
||||
float _pad_3;
|
||||
};
|
||||
);
|
||||
|
||||
|
@ -507,7 +507,7 @@ static const char* fragmentSrc3Dwater = MULTILINE_STRING(
|
|||
vec4 texel = texture(tex, tc);
|
||||
|
||||
// apply intensity and gamma
|
||||
texel.rgb *= intensity*0.5;
|
||||
texel.rgb *= intensity * lightScaleForTurb;
|
||||
outColor.rgb = pow(texel.rgb, vec3(gamma));
|
||||
outColor.a = texel.a*alpha; // I think alpha shouldn't be modified by gamma and intensity
|
||||
}
|
||||
|
@ -1172,6 +1172,7 @@ static void initUBOs(void)
|
|||
// gl3_overbrightbits 0 means "no scaling" which is equivalent to multiplying with 1
|
||||
gl3state.uni3DData.overbrightbits = (gl3_overbrightbits->value <= 0.0f) ? 1.0f : gl3_overbrightbits->value;
|
||||
gl3state.uni3DData.particleFadeFactor = gl3_particle_fade_factor->value;
|
||||
gl3state.uni3DData.lightScaleForTurb = 1.0f;
|
||||
|
||||
glGenBuffers(1, &gl3state.uni3DUBO);
|
||||
glBindBuffer(GL_UNIFORM_BUFFER, gl3state.uni3DUBO);
|
||||
|
|
|
@ -242,9 +242,25 @@ GL3_EmitWaterPolys(msurface_t *fa)
|
|||
}
|
||||
}
|
||||
|
||||
qboolean updateUni3D = false;
|
||||
if(gl3state.uni3DData.scroll != scroll)
|
||||
{
|
||||
gl3state.uni3DData.scroll = scroll;
|
||||
updateUni3D = true;
|
||||
}
|
||||
// these surfaces (mostly water and lava, I think?) don't have a lightmap.
|
||||
// rendering water at full brightness looks bad (esp. for water in dark environments)
|
||||
// so default use a factor of 0.5 (ontop of intensity)
|
||||
// but lava should be bright and glowing, so use full brightness there
|
||||
float lightScale = fa->texinfo->image->is_lava ? 1.0f : 0.5f;
|
||||
if(lightScale != gl3state.uni3DData.lightScaleForTurb)
|
||||
{
|
||||
gl3state.uni3DData.lightScaleForTurb = lightScale;
|
||||
updateUni3D = true;
|
||||
}
|
||||
|
||||
if(updateUni3D)
|
||||
{
|
||||
GL3_UpdateUBO3D();
|
||||
}
|
||||
|
||||
|
|
|
@ -164,7 +164,8 @@ typedef struct
|
|||
GLfloat overbrightbits; // gl3_overbrightbits, applied to lightmaps (and elsewhere to models)
|
||||
GLfloat particleFadeFactor; // gl3_particle_fade_factor, higher => less fading out towards edges
|
||||
|
||||
GLfloat _padding[3]; // again, some padding to ensure this has right size
|
||||
GLfloat lightScaleForTurb; // surfaces with SURF_DRAWTURB (water, lava) don't have lightmaps, use this instead
|
||||
GLfloat _padding[2]; // again, some padding to ensure this has right size
|
||||
} gl3Uni3D_t;
|
||||
|
||||
extern const hmm_mat4 gl3_identityMat4;
|
||||
|
@ -305,6 +306,7 @@ typedef struct image_s
|
|||
float sl, tl, sh, th; /* 0,0 - 1,1 unless part of the scrap */
|
||||
// qboolean scrap; // currently unused
|
||||
qboolean has_alpha;
|
||||
qboolean is_lava; // DG: added for lava brightness hack
|
||||
|
||||
} gl3image_t;
|
||||
|
||||
|
|
Loading…
Reference in a new issue