Added MSAA. Set r_ext_framebuffer_multisample to desired strength.

Fixed buggy stretched shadows in cg_shadows 4.
Improved LDR to HDR lightmap promotion in dark areas.
This commit is contained in:
James Canete 2012-02-23 10:54:10 +00:00
parent 053a51c3db
commit e244db27e5
11 changed files with 4805 additions and 4667 deletions

File diff suppressed because it is too large Load Diff

View File

@ -538,6 +538,7 @@ void RB_BeginDrawingView (void) {
// clip to the plane of the portal
if ( backEnd.viewParms.isPortal ) {
#if 0
float plane[4];
double plane2[4];
@ -550,7 +551,7 @@ void RB_BeginDrawingView (void) {
plane2[1] = DotProduct (backEnd.viewParms.or.axis[1], plane);
plane2[2] = DotProduct (backEnd.viewParms.or.axis[2], plane);
plane2[3] = DotProduct (plane, backEnd.viewParms.or.origin) - plane[3];
#endif
GL_SetModelviewMatrix( s_flipMatrix );
}
}
@ -950,8 +951,8 @@ void RE_StretchRaw (int x, int y, int w, int h, int cols, int rows, const byte *
tess.xyz[tess.numVertexes][3] = 1;
tess.texCoords[tess.numVertexes][0][0] = 0.5f / cols;
tess.texCoords[tess.numVertexes][0][1] = 0.5f / rows;
tess.texCoords[tess.numVertexes][0][2] = 0;
tess.texCoords[tess.numVertexes][0][3] = 1;
tess.texCoords[tess.numVertexes][1][0] = 0;
tess.texCoords[tess.numVertexes][1][1] = 1;
tess.numVertexes++;
tess.xyz[tess.numVertexes][0] = x + w;
@ -960,8 +961,8 @@ void RE_StretchRaw (int x, int y, int w, int h, int cols, int rows, const byte *
tess.xyz[tess.numVertexes][3] = 1;
tess.texCoords[tess.numVertexes][0][0] = (cols - 0.5f) / cols;
tess.texCoords[tess.numVertexes][0][1] = 0.5f / rows;
tess.texCoords[tess.numVertexes][0][2] = 0;
tess.texCoords[tess.numVertexes][0][3] = 1;
tess.texCoords[tess.numVertexes][1][0] = 0;
tess.texCoords[tess.numVertexes][1][1] = 1;
tess.numVertexes++;
tess.xyz[tess.numVertexes][0] = x + w;
@ -970,8 +971,8 @@ void RE_StretchRaw (int x, int y, int w, int h, int cols, int rows, const byte *
tess.xyz[tess.numVertexes][3] = 1;
tess.texCoords[tess.numVertexes][0][0] = (cols - 0.5f) / cols;
tess.texCoords[tess.numVertexes][0][1] = (rows - 0.5f) / rows;
tess.texCoords[tess.numVertexes][0][2] = 0;
tess.texCoords[tess.numVertexes][0][3] = 1;
tess.texCoords[tess.numVertexes][1][0] = 0;
tess.texCoords[tess.numVertexes][1][1] = 1;
tess.numVertexes++;
tess.xyz[tess.numVertexes][0] = x;
@ -980,8 +981,8 @@ void RE_StretchRaw (int x, int y, int w, int h, int cols, int rows, const byte *
tess.xyz[tess.numVertexes][3] = 1;
tess.texCoords[tess.numVertexes][0][0] = 0.5f / cols;
tess.texCoords[tess.numVertexes][0][1] = (rows - 0.5f) / rows;
tess.texCoords[tess.numVertexes][0][2] = 0;
tess.texCoords[tess.numVertexes][0][3] = 1;
tess.texCoords[tess.numVertexes][1][0] = 0;
tess.texCoords[tess.numVertexes][1][1] = 1;
tess.numVertexes++;
tess.indexes[tess.numIndexes++] = 0;
@ -1356,10 +1357,21 @@ const void *RB_SwapBuffers( const void *data ) {
}
else
{
// frame still in render fbo, copy from there
VectorSet4(srcBox, 0, 0, tr.renderFbo->width, tr.renderFbo->height);
// frame still in render fbo, possibly resolve then copy from there
FBO_t *hdrFbo;
FBO_Blit(tr.renderFbo, srcBox, texScale, NULL, dstBox, &tr.textureColorShader, white, 0);
if (tr.msaaResolveFbo)
{
// Resolve the MSAA before anything else
FBO_ResolveMSAA(tr.renderFbo, tr.msaaResolveFbo);
hdrFbo = tr.msaaResolveFbo;
}
else
hdrFbo = tr.renderFbo;
VectorSet4(srcBox, 0, 0, hdrFbo->width, hdrFbo->height);
FBO_Blit(hdrFbo, srcBox, texScale, NULL, dstBox, &tr.textureColorShader, white, 0);
}
}
@ -1416,14 +1428,21 @@ RB_PostProcess
const void *RB_PostProcess(const void *data)
{
const postProcessCommand_t *cmd = data;
vec4_t white;
FBO_t *hdrFbo;
vec2_t texScale;
qboolean autoExposure;
texScale[0] =
texScale[1] = 1.0f;
VectorSet4(white, 1, 1, 1, 1);
if (tr.msaaResolveFbo)
{
// Resolve the MSAA before anything else
FBO_ResolveMSAA(tr.renderFbo, tr.msaaResolveFbo);
hdrFbo = tr.msaaResolveFbo;
}
else
hdrFbo = tr.renderFbo;
if (!r_postProcess->integer)
{
@ -1432,7 +1451,7 @@ const void *RB_PostProcess(const void *data)
{
vec4_t srcBox, dstBox, color;
VectorSet4(srcBox, 0, 0, tr.renderFbo->width, tr.renderFbo->height);
VectorSet4(srcBox, 0, 0, hdrFbo->width, hdrFbo->height);
//VectorSet4(dstBox, 0, 0, glConfig.vidWidth, glConfig.vidHeight);
VectorSet4(dstBox, 0, 0, tr.screenScratchFbo->width, tr.screenScratchFbo->height);
@ -1441,8 +1460,8 @@ const void *RB_PostProcess(const void *data)
color[2] = pow(2, r_cameraExposure->value); //exp2(r_cameraExposure->value);
color[3] = 1.0f;
//FBO_Blit(tr.renderFbo, srcBox, texScale, NULL, dstBox, &tr.textureColorShader, color, 0);
FBO_Blit(tr.renderFbo, srcBox, texScale, tr.screenScratchFbo, dstBox, &tr.textureColorShader, color, 0);
//FBO_Blit(hdrFbo, srcBox, texScale, NULL, dstBox, &tr.textureColorShader, color, 0);
FBO_Blit(hdrFbo, srcBox, texScale, tr.screenScratchFbo, dstBox, &tr.textureColorShader, color, 0);
}
backEnd.framePostProcessed = qtrue;
@ -1462,13 +1481,13 @@ const void *RB_PostProcess(const void *data)
if (r_hdr->integer && (r_toneMap->integer == 2 || (r_toneMap->integer == 1 && tr.autoExposure)))
{
autoExposure = (r_autoExposure->integer == 1 && tr.autoExposure) || (r_autoExposure->integer == 2);
RB_ToneMap(autoExposure);
RB_ToneMap(hdrFbo, autoExposure);
}
else
{
vec4_t srcBox, dstBox, color;
VectorSet4(srcBox, 0, 0, tr.renderFbo->width, tr.renderFbo->height);
VectorSet4(srcBox, 0, 0, hdrFbo->width, hdrFbo->height);
VectorSet4(dstBox, 0, 0, tr.screenScratchFbo->width, tr.screenScratchFbo->height);
color[0] =
@ -1476,7 +1495,7 @@ const void *RB_PostProcess(const void *data)
color[2] = pow(2, r_cameraExposure->value); //exp2(r_cameraExposure->value);
color[3] = 1.0f;
FBO_Blit(tr.renderFbo, srcBox, texScale, tr.screenScratchFbo, dstBox, &tr.textureColorShader, color, 0);
FBO_Blit(hdrFbo, srcBox, texScale, tr.screenScratchFbo, dstBox, &tr.textureColorShader, color, 0);
}
#ifdef REACTION
@ -1487,18 +1506,7 @@ const void *RB_PostProcess(const void *data)
else
RB_GaussianBlur(backEnd.refdef.blurFactor);
#endif
/*
if (glRefConfig.framebufferObject)
{
// copy final image to screen
vec4_t srcBox, dstBox;
VectorSet4(srcBox, 0, 0, tr.screenScratchFbo->width, tr.screenScratchFbo->height);
VectorSet4(dstBox, 0, 0, glConfig.vidWidth, glConfig.vidHeight);
FBO_Blit(tr.screenScratchFbo, srcBox, texScale, NULL, dstBox, &tr.textureColorShader, white, 0);
}
*/
backEnd.framePostProcessed = qtrue;
return (const void *)(cmd + 1);

File diff suppressed because it is too large Load Diff

View File

@ -164,7 +164,15 @@ void (APIENTRY * qglGetQueryivARB)(GLenum target, GLenum pname, GLint *params);
void (APIENTRY * qglGetQueryObjectivARB)(GLuint id, GLenum pname, GLint *params);
void (APIENTRY * qglGetQueryObjectuivARB)(GLuint id, GLenum pname, GLuint *params);
// GL_EXT_framebuffer_blit
void (APIENTRY * qglBlitFramebufferEXT)(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
GLbitfield mask, GLenum filter);
// GL_EXT_framebuffer_multisample
void (APIENTRY * qglRenderbufferStorageMultisampleEXT)(GLenum target, GLsizei samples,
GLenum internalformat, GLsizei width, GLsizei height);
static qboolean GLimp_HaveExtension(const char *ext)
{
const char *ptr = Q_stristr( glConfig.extensions_string, ext );
@ -519,4 +527,33 @@ void GLimp_InitExtraExtensions()
{
ri.Printf(PRINT_ALL, "...%s not found\n", extension);
}
// GL_EXT_framebuffer_blit
extension = "GL_EXT_framebuffer_blit";
glRefConfig.framebufferBlit = qfalse;
if (GLimp_HaveExtension(extension))
{
qglBlitFramebufferEXT = (void *)SDL_GL_GetProcAddress("glBlitFramebufferEXT");
glRefConfig.framebufferBlit = qtrue;
ri.Printf(PRINT_ALL, "...%s %s\n", action[glRefConfig.framebufferBlit], extension);
}
else
{
ri.Printf(PRINT_ALL, "...%s not found\n", extension);
}
// GL_EXT_framebuffer_multisample
extension = "GL_EXT_framebuffer_multisample";
glRefConfig.framebufferMultisample = qfalse;
if (GLimp_HaveExtension(extension))
{
qglRenderbufferStorageMultisampleEXT = (void *)SDL_GL_GetProcAddress("glRenderbufferStorageMultisampleEXT");
glRefConfig.framebufferMultisample = qtrue;
ri.Printf(PRINT_ALL, "...%s %s\n", action[glRefConfig.framebufferMultisample], extension);
}
else
{
ri.Printf(PRINT_ALL, "...%s not found\n", extension);
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,63 +1,64 @@
/*
===========================================================================
Copyright (C) 2010 James Canete (use.less01@gmail.com)
This file is part of Quake III Arena source code.
Quake III Arena source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
Quake III Arena source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Quake III Arena source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
// tr_fbo.h
#ifndef __TR_FBO_H__
#define __TR_FBO_H__
struct image_s;
struct shaderProgram_s;
typedef struct FBO_s
{
char name[MAX_QPATH];
int index;
uint32_t frameBuffer;
uint32_t colorBuffers[16];
int colorFormat;
struct image_s *colorImage[16];
uint32_t depthBuffer;
int depthFormat;
uint32_t stencilBuffer;
int stencilFormat;
uint32_t packedDepthStencilBuffer;
int packedDepthStencilFormat;
int width;
int height;
} FBO_t;
void FBO_Bind(FBO_t *fbo);
void FBO_Init(void);
void FBO_Shutdown(void);
void FBO_BlitFromTexture(struct image_s *src, vec4_t srcBox, vec2_t srcTexScale, FBO_t *dst, vec4_t dstBox, struct shaderProgram_s *shaderProgram, vec4_t color, int blend);
void FBO_Blit(FBO_t *src, vec4_t srcBox, vec2_t srcTexScale, FBO_t *dst, vec4_t dstBox, struct shaderProgram_s *shaderProgram, vec4_t color, int blend);
#endif
/*
===========================================================================
Copyright (C) 2010 James Canete (use.less01@gmail.com)
This file is part of Quake III Arena source code.
Quake III Arena source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
Quake III Arena source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Quake III Arena source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
// tr_fbo.h
#ifndef __TR_FBO_H__
#define __TR_FBO_H__
struct image_s;
struct shaderProgram_s;
typedef struct FBO_s
{
char name[MAX_QPATH];
int index;
uint32_t frameBuffer;
uint32_t colorBuffers[16];
int colorFormat;
struct image_s *colorImage[16];
uint32_t depthBuffer;
int depthFormat;
uint32_t stencilBuffer;
int stencilFormat;
uint32_t packedDepthStencilBuffer;
int packedDepthStencilFormat;
int width;
int height;
} FBO_t;
void FBO_Bind(FBO_t *fbo);
void FBO_Init(void);
void FBO_Shutdown(void);
void FBO_BlitFromTexture(struct image_s *src, vec4_t srcBox, vec2_t srcTexScale, FBO_t *dst, vec4_t dstBox, struct shaderProgram_s *shaderProgram, vec4_t color, int blend);
void FBO_Blit(FBO_t *src, vec4_t srcBox, vec2_t srcTexScale, FBO_t *dst, vec4_t dstBox, struct shaderProgram_s *shaderProgram, vec4_t color, int blend);
void FBO_ResolveMSAA(FBO_t *src, FBO_t *dst);
#endif

View File

@ -174,12 +174,12 @@ static const char *fallbackFogPassShader_vp =
"n, u_FogDistance);\r\n\tfloat t = dot(position, u_FogDepth);\r\n\r\n\tif (t"
" >= 1.0)\r\n\t{\r\n\t\ts *= t / (t - min(u_FogEyeT, 0.0));\r\n\t}\r\n\telse"
"\r\n\t{\r\n\t\ts *= max(t + sign(u_FogEyeT), 0.0);\r\n\t}\r\n\r\n\tvar_Scal"
"e = clamp(s * 8.0, 0.0, 1.0);\r\n}\r\n";
"e = s * 8.0;\r\n}\r\n";
static const char *fallbackFogPassShader_fp =
"uniform vec4 u_Color;\r\n\r\nvarying float var_Scale;\r\n\r\nvoid main()\r"
"\n{\r\n\tgl_FragColor = u_Color;\r\n\tgl_FragColor.a *= sqrt(var_Scale);\r"
"\n}\r\n";
"\n{\r\n\tgl_FragColor = u_Color;\r\n\tgl_FragColor.a *= sqrt(clamp(var_Scal"
"e, 0.0, 1.0));\r\n}\r\n";
static const char *fallbackDlightShader_vp =
"attribute vec4 attr_Position;\r\nattribute vec4 attr_TexCoord0;\r\nattribut"
@ -470,34 +470,37 @@ static const char *fallbackPshadowShader_fp =
"3 var_Position;\r\nvarying vec3 var_Normal;\r\n\r\nfloat sampleDi"
"stMap(sampler2D texMap, vec2 uv, float scale)\r\n{\r\n\tvec3 distv = textur"
"e2D(texMap, uv).xyz;\r\n\treturn dot(distv, vec3(1.0 / (256.0 * 256.0), 1.0"
" / 256.0, 1.0)) * scale;\r\n}\r\n\r\nvoid main()\r\n{\r\n\tvec2 st;\r\n\t\r"
"\n\tvec3 lightToPos = var_Position - u_LightOrigin.xyz;\r\n\t\r\n\tst.s = -"
"dot(u_LightRight, lightToPos);\r\n\tst.t = dot(u_LightUp, lightToPos);\r\n"
"\t\r\n\tst = st * 0.5 + vec2(0.5);\r\n\r\n#if defined(USE_SOLID_PSHADOWS)\r"
"\n\tfloat intensity = max(sign(u_LightRadius - length(lightToPos)), 0.0);\r"
"\n#else\r\n\tfloat intensity = clamp((1.0 - dot(lightToPos, lightToPos) / ("
"u_LightRadius * u_LightRadius)) * 2.0, 0.0, 1.0);\r\n#endif\r\n\t\r\n\tfloa"
"t lightDist = length(lightToPos);\r\n\tfloat dist;\r\n\r\n#if defined(USE_D"
"ISCARD)\r\n\tif (dot(u_LightForward, lightToPos) <= 0.0)\r\n\t{\r\n\t\tdisc"
"ard;\r\n\t}\r\n\r\n\tif (dot(var_Normal, lightToPos) > 0.0)\r\n\t{\r\n\t\td"
"iscard;\r\n\t}\r\n#else\r\n\tintensity *= max(sign(dot(u_LightForward, ligh"
"tToPos)), 0.0);\r\n\tintensity *= max(sign(-dot(var_Normal, lightToPos)), 0"
".0);\r\n#endif\r\n\t\r\n#if defined(USE_PCF)\r\n\tfloat part;\r\n\t\r\n\tdi"
"st = sampleDistMap(u_ShadowMap, st + vec2(-1.0/256.0, -1.0/256.0), u_LightR"
"adius);\r\n\tpart = max(sign(lightDist - dist), 0.0);\r\n\r\n\tdist = samp"
"leDistMap(u_ShadowMap, st + vec2( 1.0/256.0, -1.0/256.0), u_LightRadius);\r"
"\n\tpart += max(sign(lightDist - dist), 0.0);\r\n\r\n\tdist = sampleDistMap"
"(u_ShadowMap, st + vec2(-1.0/256.0, 1.0/256.0), u_LightRadius);\r\n\tpart "
"+= max(sign(lightDist - dist), 0.0);\r\n\r\n\tdist = sampleDistMap(u_Shadow"
"Map, st + vec2( 1.0/256.0, 1.0/256.0), u_LightRadius);\r\n\tpart += max(si"
"gn(lightDist - dist), 0.0);\r\n\r\n #if defined(USE_DISCARD)\r\n\tif (part "
"<= 0.0)\r\n\t{\r\n\t\tdiscard;\r\n\t}\r\n #endif\r\n\r\n\tintensity *= part"
" * 0.25;\r\n#else\r\n\tdist = sampleDistMap(u_ShadowMap, st, u_LightRadius)"
";\r\n\r\n #if defined(USE_DISCARD)\r\n\tif (lightDist - dist <= 0.0)\r\n\t{"
"\r\n\t\tdiscard;\r\n\t}\r\n #endif\r\n\t\t\t\r\n\t//intensity *= max(sign(2"
"54.0 / 255.0 - dist / u_LightRadius), 0.0);\r\n\tintensity *= max(sign(ligh"
"tDist - dist), 0.0);\r\n#endif\r\n\t\t\r\n\tgl_FragColor.rgb = vec3(0);\r\n"
"\tgl_FragColor.a = clamp(intensity, 0.0, 0.75);\r\n}\r\n";
" / 256.0, 1.0)) * scale;\r\n}\r\n\r\nvoid main()\r\n{\r\n\tvec3 lightToPos "
"= var_Position - u_LightOrigin.xyz;\r\n\tvec2 st = vec2(-dot(u_LightRight, "
"lightToPos), dot(u_LightUp, lightToPos));\r\n\t\r\n\tfloat fade = length(st"
");\r\n\t\r\n#if defined(USE_DISCARD)\r\n\tif (fade >= 1.0)\r\n\t{\r\n\t\tdi"
"scard;\r\n\t}\r\n#endif\r\n\r\n\tfade = clamp(8.0 - fade * 8.0, 0.0, 1.0);"
"\r\n\t\r\n\tst = st * 0.5 + vec2(0.5);\r\n\r\n#if defined(USE_SOLID_PSHADOW"
"S)\r\n\tfloat intensity = max(sign(u_LightRadius - length(lightToPos)), 0.0"
");\r\n#else\r\n\tfloat intensity = clamp((1.0 - dot(lightToPos, lightToPos)"
" / (u_LightRadius * u_LightRadius)) * 2.0, 0.0, 1.0);\r\n#endif\r\n\t\r\n\t"
"float lightDist = length(lightToPos);\r\n\tfloat dist;\r\n\r\n#if defined(U"
"SE_DISCARD)\r\n\tif (dot(u_LightForward, lightToPos) <= 0.0)\r\n\t{\r\n\t\t"
"discard;\r\n\t}\r\n\r\n\tif (dot(var_Normal, lightToPos) > 0.0)\r\n\t{\r\n"
"\t\tdiscard;\r\n\t}\r\n#else\r\n\tintensity *= max(sign(dot(u_LightForward,"
" lightToPos)), 0.0);\r\n\tintensity *= max(sign(-dot(var_Normal, lightToPos"
")), 0.0);\r\n#endif\r\n\r\n\tintensity *= fade;\r\n\t\r\n#if defined(USE_PC"
"F)\r\n\tfloat part;\r\n\t\r\n\tdist = sampleDistMap(u_ShadowMap, st + vec2("
"-1.0/256.0, -1.0/256.0), u_LightRadius);\r\n\tpart = max(sign(lightDist - "
"dist), 0.0);\r\n\r\n\tdist = sampleDistMap(u_ShadowMap, st + vec2( 1.0/256."
"0, -1.0/256.0), u_LightRadius);\r\n\tpart += max(sign(lightDist - dist), 0."
"0);\r\n\r\n\tdist = sampleDistMap(u_ShadowMap, st + vec2(-1.0/256.0, 1.0/2"
"56.0), u_LightRadius);\r\n\tpart += max(sign(lightDist - dist), 0.0);\r\n\r"
"\n\tdist = sampleDistMap(u_ShadowMap, st + vec2( 1.0/256.0, 1.0/256.0), u_"
"LightRadius);\r\n\tpart += max(sign(lightDist - dist), 0.0);\r\n\r\n #if de"
"fined(USE_DISCARD)\r\n\tif (part <= 0.0)\r\n\t{\r\n\t\tdiscard;\r\n\t}\r\n "
"#endif\r\n\r\n\tintensity *= part * 0.25;\r\n#else\r\n\tdist = sampleDistMa"
"p(u_ShadowMap, st, u_LightRadius);\r\n\r\n #if defined(USE_DISCARD)\r\n\tif"
" (lightDist - dist <= 0.0)\r\n\t{\r\n\t\tdiscard;\r\n\t}\r\n #endif\r\n\t\t"
"\t\r\n\t//intensity *= max(sign(254.0 / 255.0 - dist / u_LightRadius), 0.0)"
";\r\n\tintensity *= max(sign(lightDist - dist), 0.0);\r\n#endif\r\n\t\t\r\n"
"\tgl_FragColor.rgb = vec3(0);\r\n\tgl_FragColor.a = clamp(intensity, 0.0, 0"
".75);\r\n}\r\n";
static const char *fallbackDown4xShader_vp =
"attribute vec4 attr_Position;\r\nattribute vec4 attr_TexCoord0;\r\n\r\nunif"

View File

@ -96,6 +96,7 @@ cvar_t *r_ext_multi_draw_arrays;
cvar_t *r_ext_framebuffer_object;
cvar_t *r_ext_texture_float;
cvar_t *r_arb_half_float_pixel;
cvar_t *r_ext_framebuffer_multisample;
cvar_t *r_mergeMultidraws;
cvar_t *r_mergeLeafSurfaces;
@ -1079,6 +1080,7 @@ void R_Register( void )
r_ext_framebuffer_object = ri.Cvar_Get( "r_ext_framebuffer_object", "1", CVAR_ARCHIVE | CVAR_LATCH);
r_ext_texture_float = ri.Cvar_Get( "r_ext_texture_float", "1", CVAR_ARCHIVE | CVAR_LATCH);
r_arb_half_float_pixel = ri.Cvar_Get( "r_arb_half_float_pixel", "1", CVAR_ARCHIVE | CVAR_LATCH);
r_ext_framebuffer_multisample = ri.Cvar_Get( "r_ext_framebuffer_multisample", "0", CVAR_ARCHIVE | CVAR_LATCH);
r_ext_texture_filter_anisotropic = ri.Cvar_Get( "r_ext_texture_filter_anisotropic",
"0", CVAR_ARCHIVE | CVAR_LATCH );

View File

@ -1100,7 +1100,7 @@ typedef struct
// culling information
cplane_t plane;
vec3_t bounds[2];
// vec3_t bounds[2];
// triangle definitions
int numTriangles;
@ -1129,7 +1129,7 @@ typedef struct
int pshadowBits[SMP_FRAMES];
// culling information
vec3_t bounds[2];
// vec3_t bounds[2];
// triangle definitions
int numTriangles;
@ -1599,6 +1599,9 @@ typedef struct {
qboolean textureFloat;
qboolean halfFloatPixel;
qboolean packedDepthStencil;
qboolean framebufferMultisample;
qboolean framebufferBlit;
} glRefConfig_t;
@ -1716,6 +1719,7 @@ typedef struct {
image_t *textureDepthImage;
FBO_t *renderFbo;
FBO_t *msaaResolveFbo;
FBO_t *godRaysFbo;
FBO_t *depthFbo;
FBO_t *pshadowFbos[MAX_DRAWN_PSHADOWS];
@ -1909,6 +1913,7 @@ extern cvar_t *r_ext_multi_draw_arrays;
extern cvar_t *r_ext_framebuffer_object;
extern cvar_t *r_ext_texture_float;
extern cvar_t *r_arb_half_float_pixel;
extern cvar_t *r_ext_framebuffer_multisample;
extern cvar_t *r_nobind; // turns off binding to appropriate textures
extern cvar_t *r_singleShader; // make most world faces use default shader

View File

@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "tr_local.h"
void RB_ToneMap(int autoExposure)
void RB_ToneMap(FBO_t *hdrFbo, int autoExposure)
{
vec4_t white;
vec2_t texScale;
@ -38,10 +38,10 @@ void RB_ToneMap(int autoExposure)
vec4_t srcBox, dstBox, color;
int size = 256, currentScratch, nextScratch, tmp;
VectorSet4(srcBox, 0, 0, tr.renderFbo->width, tr.renderFbo->height);
VectorSet4(srcBox, 0, 0, hdrFbo->width, hdrFbo->height);
VectorSet4(dstBox, 0, 0, 256, 256);
FBO_Blit(tr.renderFbo, srcBox, texScale, tr.textureScratchFbo[0], dstBox, &tr.calclevels4xShader[0], white, 0);
FBO_Blit(hdrFbo, srcBox, texScale, tr.textureScratchFbo[0], dstBox, &tr.calclevels4xShader[0], white, 0);
currentScratch = 0;
nextScratch = 1;
@ -79,7 +79,7 @@ void RB_ToneMap(int autoExposure)
// tonemap
vec4_t srcBox, dstBox, color;
VectorSet4(srcBox, 0, 0, tr.renderFbo->width, tr.renderFbo->height);
VectorSet4(srcBox, 0, 0, hdrFbo->width, hdrFbo->height);
VectorSet4(dstBox, 0, 0, tr.screenScratchFbo->width, tr.screenScratchFbo->height);
color[0] =
@ -93,9 +93,9 @@ void RB_ToneMap(int autoExposure)
GL_BindToTMU(tr.fixedLevelsImage, TB_LEVELSMAP);
if (r_hdr->integer)
FBO_Blit(tr.renderFbo, srcBox, texScale, tr.screenScratchFbo, dstBox, &tr.tonemapShader, color, 0);
FBO_Blit(hdrFbo, srcBox, texScale, tr.screenScratchFbo, dstBox, &tr.tonemapShader, color, 0);
else
FBO_Blit(tr.renderFbo, srcBox, texScale, tr.screenScratchFbo, dstBox, &tr.textureColorShader, color, 0);
FBO_Blit(hdrFbo, srcBox, texScale, tr.screenScratchFbo, dstBox, &tr.textureColorShader, color, 0);
}
}

View File

@ -23,7 +23,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#ifndef TR_POSTPROCESS_H
#define TR_POSTPROCESS_H
void RB_ToneMap(int autoExposure);
#include "tr_fbo.h"
void RB_ToneMap(FBO_t *hdrFbo, int autoExposure);
void RB_BokehBlur(float blur);
void RB_GodRays(void);
void RB_GaussianBlur(float blur);