diff --git a/engine/gl/gl_bloom.c b/engine/gl/gl_bloom.c index 0283d4157..abe795dd2 100644 --- a/engine/gl/gl_bloom.c +++ b/engine/gl/gl_bloom.c @@ -37,37 +37,13 @@ extern vrect_t gl_truescreenrect; ============================================================================== */ -static float Diamond8x[8][8] = { - {0.0f, 0.0f, 0.0f, 0.1f, 0.1f, 0.0f, 0.0f, 0.0f}, - {0.0f, 0.0f, 0.2f, 0.3f, 0.3f, 0.2f, 0.0f, 0.0f}, - {0.0f, 0.2f, 0.4f, 0.6f, 0.6f, 0.4f, 0.2f, 0.0f}, - {0.1f, 0.3f, 0.6f, 0.9f, 0.9f, 0.6f, 0.3f, 0.1f}, - {0.1f, 0.3f, 0.6f, 0.9f, 0.9f, 0.6f, 0.3f, 0.1f}, - {0.0f, 0.2f, 0.4f, 0.6f, 0.6f, 0.4f, 0.2f, 0.0f}, - {0.0f, 0.0f, 0.2f, 0.3f, 0.3f, 0.2f, 0.0f, 0.0f}, - {0.0f, 0.0f, 0.0f, 0.1f, 0.1f, 0.0f, 0.0f, 0.0f} }; - -static float Diamond6x[6][6] = { - {0.0f, 0.0f, 0.1f, 0.1f, 0.0f, 0.0f}, - {0.0f, 0.3f, 0.5f, 0.5f, 0.3f, 0.0f}, - {0.1f, 0.5f, 0.9f, 0.9f, 0.5f, 0.1f}, - {0.1f, 0.5f, 0.9f, 0.9f, 0.5f, 0.1f}, - {0.0f, 0.3f, 0.5f, 0.5f, 0.3f, 0.0f}, - {0.0f, 0.0f, 0.1f, 0.1f, 0.0f, 0.0f} }; - -static float Diamond4x[4][4] = { - {0.3f, 0.4f, 0.4f, 0.3f}, - {0.4f, 0.9f, 0.9f, 0.4f}, - {0.4f, 0.9f, 0.9f, 0.4f}, - {0.3f, 0.4f, 0.4f, 0.3f} }; - - cvar_t r_bloom = FCVAR("r_bloom", "gl_bloom", "0", CVAR_ARCHIVE); - cvar_t r_bloom_alpha = SCVAR("r_bloom_alpha", "0.5"); - cvar_t r_bloom_diamond_size = SCVAR("r_bloom_diamond_size", "8"); - cvar_t r_bloom_intensity = SCVAR("r_bloom_intensity", "1"); - cvar_t r_bloom_darken = SCVAR("r_bloom_darken", "3"); - cvar_t r_bloom_sample_size = SCVARF("r_bloom_sample_size", "256", CVAR_RENDERERLATCH); - cvar_t r_bloom_fast_sample = SCVARF("r_bloom_fast_sample", "0", CVAR_RENDERERLATCH); +cvar_t r_bloom = FCVAR("r_bloom", "gl_bloom", "0", CVAR_ARCHIVE); +cvar_t r_bloom_alpha = SCVAR("r_bloom_alpha", "0.5"); +cvar_t r_bloom_diamond_size = SCVAR("r_bloom_diamond_size", "8"); +cvar_t r_bloom_intensity = SCVAR("r_bloom_intensity", "1"); +cvar_t r_bloom_darken = SCVAR("r_bloom_darken", "3"); +cvar_t r_bloom_sample_size = SCVARF("r_bloom_sample_size", "256", CVAR_RENDERERLATCH); +cvar_t r_bloom_fast_sample = SCVARF("r_bloom_fast_sample", "0", CVAR_RENDERERLATCH); typedef struct { //texture numbers @@ -162,7 +138,7 @@ void R_Bloom_InitEffectTexture(void) Cvar_SetValue (&r_bloom_sample_size, 32); //make sure bloom size is a power of 2 - bs.size_sample = r_bloom_sample_size.value; + bs.size_sample = min(r_bloom_sample_size.value, gl_max_size.value); bloomsizecheck = (float)bs.size_sample; while (bloomsizecheck > 1.0f) bloomsizecheck /= 2.0f; if (bloomsizecheck != 1.0f) @@ -436,54 +412,23 @@ void R_Bloom_GeneratexDiamonds(void) //qglBlendFunc(GL_ONE, GL_ONE); qglBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_COLOR); - if (r_bloom_diamond_size.value > 7 || r_bloom_diamond_size.value <= 3) { - if (r_bloom_diamond_size.value != 8) - Cvar_SetValue(&r_bloom_diamond_size, 8); + int size = r_bloom_diamond_size.value; + float rad = r_bloom_diamond_size.value / 2.0f; + float point = (r_bloom_diamond_size.value - 1) / 2.0f; + float mult = min(1.0f, r_bloom_intensity.value * 2.0f / rad); - for (i=0; i 5) - { - if (r_bloom_diamond_size.value != 6) - Cvar_SetValue(&r_bloom_diamond_size, 6); - - for(i=0; i 3) - { - if (r_bloom_diamond_size.value != 4) - Cvar_SetValue(&r_bloom_diamond_size, 4); - - for (i=0; i