cvar_t r_bloom = {CVAR_SAVE, "r_bloom", "0", "enables bloom effect (makes bright pixels affect neighboring pixels)"};
cvar_t r_bloom_colorscale = {CVAR_SAVE, "r_bloom_colorscale", "1", "how bright the glow is"};
-cvar_t r_bloom_brighten = {CVAR_SAVE, "r_bloom_brighten", "2", "how bright the glow is, after subtract/power"};
+cvar_t r_bloom_brighten = {CVAR_SAVE, "r_bloom_brighten", "1", "how bright the glow is, after subtract/power"};
cvar_t r_bloom_blur = {CVAR_SAVE, "r_bloom_blur", "4", "how large the glow is"};
cvar_t r_bloom_resolution = {CVAR_SAVE, "r_bloom_resolution", "320", "what resolution to perform the bloom effect at (independent of screen resolution)"};
cvar_t r_bloom_colorexponent = {CVAR_SAVE, "r_bloom_colorexponent", "1", "how exagerated the glow is"};
-cvar_t r_bloom_colorsubtract = {CVAR_SAVE, "r_bloom_colorsubtract", "0.125", "reduces bloom colors by a certain amount"};
+cvar_t r_bloom_colorsubtract = {CVAR_SAVE, "r_bloom_colorsubtract", "0", "reduces bloom colors by a certain amount"};
cvar_t r_hdr = {CVAR_SAVE, "r_hdr", "0", "enables High Dynamic Range bloom effect (higher quality version of r_bloom)"};
cvar_t r_hdr_scenebrightness = {CVAR_SAVE, "r_hdr_scenebrightness", "1", "global rendering brightness"};
cvar_t r_hdr_glowintensity = {CVAR_SAVE, "r_hdr_glowintensity", "1", "how bright light emitting textures should appear"};
+cvar_t r_hdr_range = {CVAR_SAVE, "r_hdr_range", "4", "how much dynamic range to render bloom with (equivilant to multiplying r_bloom_brighten by this value and dividing r_bloom_colorscale by this value)"};
cvar_t r_smoothnormals_areaweighting = {0, "r_smoothnormals_areaweighting", "1", "uses significantly faster (and supposedly higher quality) area-weighted vertex normals and tangent vectors rather than summing normalized triangle normals and tangents"};
Cvar_RegisterVariable(&r_hdr);
Cvar_RegisterVariable(&r_hdr_scenebrightness);
Cvar_RegisterVariable(&r_hdr_glowintensity);
+ Cvar_RegisterVariable(&r_hdr_range);
Cvar_RegisterVariable(&r_smoothnormals_areaweighting);
Cvar_RegisterVariable(&developer_texturelogging);
Cvar_RegisterVariable(&gl_lightmaps);
void R_Bloom_MakeTexture(void)
{
int x, range, dir;
- float xoffset, yoffset, r;
+ float xoffset, yoffset, r, brighten;
r_refdef.stats.bloom++;
}
range = r_bloom_blur.integer * r_bloomstate.bloomwidth / 320;
+ brighten = r_bloom_brighten.value;
+ if (r_hdr.integer)
+ brighten *= r_hdr_range.value;
R_Mesh_TexBind(0, R_GetTexture(r_bloomstate.texture_bloom));
R_Mesh_TexCoordPointer(0, 2, r_bloomstate.offsettexcoord2f);
// black at the edges
// (probably not realistic but looks good enough)
//r = ((range*range+1)/((float)(x*x+1)))/(range*2+1);
- //r = (dir ? 1.0f : r_bloom_brighten.value)/(range*2+1);
- r = (dir ? 1.0f : r_bloom_brighten.value)/(range*2+1)*(1 - x*x/(float)(range*range));
+ //r = (dir ? 1.0f : brighten)/(range*2+1);
+ r = (dir ? 1.0f : brighten)/(range*2+1)*(1 - x*x/(float)(range*range));
GL_Color(r, r, r, 1);
R_Mesh_Draw(0, 4, 2, polygonelements);
r_refdef.stats.bloom_drawpixels += r_bloomstate.bloomwidth * r_bloomstate.bloomheight;
// TODO: add fp16 framebuffer support
r_view.colorscale = r_bloom_colorscale.value * r_hdr_scenebrightness.value;
+ if (r_hdr.integer)
+ r_view.colorscale /= r_hdr_range.value;
R_RenderScene();
R_ResetViewRendering2D();
extern cvar_t r_hdr;
extern cvar_t r_hdr_scenebrightness;
extern cvar_t r_hdr_glowintensity;
+extern cvar_t r_hdr_range;
extern cvar_t gl_picmip;
static void M_Menu_Options_Graphics_AdjustSliders (int dir)
else if (options_graphics_cursor == optnum++) Cvar_SetValueQuick (&r_shadow_realtime_world_lightmaps, bound(0, r_shadow_realtime_world_lightmaps.value + dir * 0.1, 1));
else if (options_graphics_cursor == optnum++) Cvar_SetValueQuick (&r_shadow_realtime_world_shadows, !r_shadow_realtime_world_shadows.integer);
else if (options_graphics_cursor == optnum++) Cvar_SetValueQuick (&r_bloom, !r_bloom.integer);
+ else if (options_graphics_cursor == optnum++) Cvar_SetValueQuick (&r_hdr_scenebrightness, bound(0.25, r_hdr_scenebrightness.value + dir * 0.125, 4));
else if (options_graphics_cursor == optnum++) Cvar_SetValueQuick (&r_hdr, !r_hdr.integer);
+ else if (options_graphics_cursor == optnum++) Cvar_SetValueQuick (&r_hdr_range, bound(1, r_hdr_range.value + dir * 0.25, 16));
else if (options_graphics_cursor == optnum++) Cvar_SetValueQuick (&r_hdr_glowintensity, bound(0, r_hdr_glowintensity.value + dir * 0.25, 4));
else if (options_graphics_cursor == optnum++) Cvar_SetValueQuick (&r_bloom_colorscale, bound(0.0625, r_bloom_colorscale.value + dir * 0.0625, 1));
else if (options_graphics_cursor == optnum++) Cvar_SetValueQuick (&r_bloom_colorsubtract, bound(0, r_bloom_colorsubtract.value + dir * 0.0625, 1-0.0625));
else if (options_graphics_cursor == optnum++) Cvar_SetValueQuick (&r_bloom_colorexponent, bound(1, r_bloom_colorexponent.value *= (dir > 0 ? 2 : 0.5), 8));
else if (options_graphics_cursor == optnum++) Cvar_SetValueQuick (&r_bloom_blur, bound(1, r_bloom_blur.value + dir * 1, 16));
else if (options_graphics_cursor == optnum++) Cvar_SetValueQuick (&r_bloom_resolution, bound(64, r_bloom_resolution.value + dir * 64, 2048));
- else if (options_graphics_cursor == optnum++) Cvar_SetValueQuick (&r_hdr_scenebrightness, bound(0.25, r_hdr_scenebrightness.value + dir * 0.125, 4));
else if (options_graphics_cursor == optnum++) Cvar_SetValueQuick (&gl_picmip, bound(0, gl_picmip.value - dir, 3));
else if (options_graphics_cursor == optnum++) Cbuf_AddText ("r_restart\n");
}
M_Options_PrintCheckbox("RT World DLight Shadows", true, r_shadow_realtime_world_dlightshadows.integer);
M_Options_PrintSlider( " RT World Lightmaps", true, r_shadow_realtime_world_lightmaps.value, 0, 1);
M_Options_PrintCheckbox(" RT World Shadow", true, r_shadow_realtime_world_shadows.integer);
+ M_Options_PrintSlider( " Scene Brightness", true, r_hdr_scenebrightness.value, 0.25, 4);
M_Options_PrintCheckbox(" Bloom Effect", !r_hdr.integer, r_bloom.integer);
M_Options_PrintCheckbox(" HDR Bloom Effect", r_hdr.integer, r_hdr.integer);
+ M_Options_PrintSlider( " HDR Dynamic Range", true, r_hdr_range.value, 1, 16);
M_Options_PrintSlider( " HDR Glow Intensity", r_hdr.integer, r_hdr_glowintensity.value, 0, 4);
M_Options_PrintSlider( " Bloom Color Scale", r_hdr.integer || r_bloom.integer, r_bloom_colorscale.value, 0.0625, 1);
M_Options_PrintSlider( " Bloom Color Subtract", r_hdr.integer || r_bloom.integer, r_bloom_colorsubtract.value, 0, 1-0.0625);
M_Options_PrintSlider( " Bloom Intensity", r_hdr.integer || r_bloom.integer, r_bloom_colorscale.value, 0.125, 4);
M_Options_PrintSlider( " Bloom Blur", r_hdr.integer || r_bloom.integer, r_bloom_blur.value, 1, 16);
M_Options_PrintSlider( " Bloom Resolution", r_hdr.integer || r_bloom.integer, r_bloom_resolution.value, 64, 2048);
- M_Options_PrintSlider( " Scene Brightness", true, r_hdr_scenebrightness.value, 0.25, 4);
M_Options_PrintSlider( " Texture Quality", true, gl_picmip.value, 3, 0);
M_Options_PrintCommand( " Restart Renderer", true);
}