mirror of
https://github.com/ReactionQuake3/reaction.git
synced 2025-02-21 11:21:41 +00:00
Fix sun flare with sky portals. Sun flare must be inside sky portal.
This commit is contained in:
parent
ab4f586e72
commit
0e6eed98c0
6 changed files with 33 additions and 11 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
- Fix sun flare with sky portals. Sun flare must be inside sky portal.
|
||||||
- Speed up tone mapping
|
- Speed up tone mapping
|
||||||
- Add fast light shader path when r_normalMapping and r_specularMapping are 0
|
- Add fast light shader path when r_normalMapping and r_specularMapping are 0
|
||||||
- Revise FBO blitting code (Still needs more work)
|
- Revise FBO blitting code (Still needs more work)
|
||||||
|
|
|
@ -227,12 +227,16 @@ void GL_State( unsigned long stateBits )
|
||||||
//
|
//
|
||||||
// check depthFunc bits
|
// check depthFunc bits
|
||||||
//
|
//
|
||||||
if ( diff & GLS_DEPTHFUNC_EQUAL )
|
if ( diff & GLS_DEPTHFUNC_BITS )
|
||||||
{
|
{
|
||||||
if ( stateBits & GLS_DEPTHFUNC_EQUAL )
|
if ( stateBits & GLS_DEPTHFUNC_EQUAL )
|
||||||
{
|
{
|
||||||
qglDepthFunc( GL_EQUAL );
|
qglDepthFunc( GL_EQUAL );
|
||||||
}
|
}
|
||||||
|
else if ( stateBits & GLS_DEPTHFUNC_GREATER)
|
||||||
|
{
|
||||||
|
qglDepthFunc( GL_GREATER );
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
qglDepthFunc( GL_LEQUAL );
|
qglDepthFunc( GL_LEQUAL );
|
||||||
|
@ -533,7 +537,7 @@ void RB_BeginDrawingView (void) {
|
||||||
backEnd.skyRenderedThisView = qfalse;
|
backEnd.skyRenderedThisView = qfalse;
|
||||||
|
|
||||||
#ifdef REACTION
|
#ifdef REACTION
|
||||||
backEnd.hasSunFlare = qfalse;
|
backEnd.viewHasSunFlare = qfalse;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// clip to the plane of the portal
|
// clip to the plane of the portal
|
||||||
|
@ -687,12 +691,11 @@ void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) {
|
||||||
qglClear( GL_COLOR_BUFFER_BIT );
|
qglClear( GL_COLOR_BUFFER_BIT );
|
||||||
|
|
||||||
qglDepthRange(1.f, 1.f);
|
qglDepthRange(1.f, 1.f);
|
||||||
if (glRefConfig.occlusionQuery && !inQuery && !backEnd.hasSunFlare) {
|
if (glRefConfig.occlusionQuery && !inQuery && !backEnd.viewHasSunFlare) {
|
||||||
inQuery = qtrue;
|
inQuery = qtrue;
|
||||||
tr.sunFlareQueryActive[tr.sunFlareQueryIndex] = qtrue;
|
tr.sunFlareQueryActive[tr.sunFlareQueryIndex] = qtrue;
|
||||||
qglBeginQueryARB(GL_SAMPLES_PASSED_ARB, tr.sunFlareQuery[tr.sunFlareQueryIndex]);
|
qglBeginQueryARB(GL_SAMPLES_PASSED_ARB, tr.sunFlareQuery[tr.sunFlareQueryIndex]);
|
||||||
}
|
}
|
||||||
//backEnd.hasSunFlare = qtrue;
|
|
||||||
sunflare = qtrue;
|
sunflare = qtrue;
|
||||||
} else {
|
} else {
|
||||||
depthRange = qtrue;
|
depthRange = qtrue;
|
||||||
|
@ -794,6 +797,17 @@ void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) {
|
||||||
inQuery = qfalse;
|
inQuery = qfalse;
|
||||||
qglEndQueryARB(GL_SAMPLES_PASSED_ARB);
|
qglEndQueryARB(GL_SAMPLES_PASSED_ARB);
|
||||||
}
|
}
|
||||||
|
#ifdef REACTION
|
||||||
|
// HACK: flip Z and render black to god rays buffer
|
||||||
|
if (backEnd.frameHasSunFlare)
|
||||||
|
{
|
||||||
|
vec4_t black;
|
||||||
|
VectorSet4(black, 0, 0, 0, 1);
|
||||||
|
qglDepthRange (1, 1);
|
||||||
|
FBO_BlitFromTexture(tr.whiteImage, NULL, NULL, tr.godRaysFbo, NULL, NULL, black, GLS_DEPTHFUNC_GREATER);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
FBO_Bind(fbo);
|
FBO_Bind(fbo);
|
||||||
|
|
||||||
// go back to the world modelview matrix
|
// go back to the world modelview matrix
|
||||||
|
@ -1405,6 +1419,9 @@ const void *RB_SwapBuffers( const void *data ) {
|
||||||
|
|
||||||
backEnd.framePostProcessed = qfalse;
|
backEnd.framePostProcessed = qfalse;
|
||||||
backEnd.projection2D = qfalse;
|
backEnd.projection2D = qfalse;
|
||||||
|
#ifdef REACTION
|
||||||
|
backEnd.frameHasSunFlare = qfalse;
|
||||||
|
#endif
|
||||||
|
|
||||||
return (const void *)(cmd + 1);
|
return (const void *)(cmd + 1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -701,7 +701,7 @@ void FBO_BlitFromTexture(struct image_s *src, vec4i_t inSrcBox, vec2_t inSrcTexS
|
||||||
invTexRes[0] = 1.0f / src->width * srcTexScale[0];
|
invTexRes[0] = 1.0f / src->width * srcTexScale[0];
|
||||||
invTexRes[1] = 1.0f / src->height * srcTexScale[1];
|
invTexRes[1] = 1.0f / src->height * srcTexScale[1];
|
||||||
|
|
||||||
GL_State( blend | GLS_DEPTHTEST_DISABLE );
|
GL_State( blend );
|
||||||
|
|
||||||
RB_InstantQuad2(quadVerts, texCoords, color, shaderProgram, invTexRes);
|
RB_InstantQuad2(quadVerts, texCoords, color, shaderProgram, invTexRes);
|
||||||
}
|
}
|
||||||
|
@ -726,7 +726,7 @@ void FBO_Blit(FBO_t *src, vec4i_t inSrcBox, vec2_t srcTexScale, FBO_t *dst, vec4
|
||||||
VectorSet4(srcBox, 0, src->height, src->width, -src->height);
|
VectorSet4(srcBox, 0, src->height, src->width, -src->height);
|
||||||
}
|
}
|
||||||
|
|
||||||
FBO_BlitFromTexture(src->colorImage[0], srcBox, srcTexScale, dst, dstBox, shaderProgram, color, blend);
|
FBO_BlitFromTexture(src->colorImage[0], srcBox, srcTexScale, dst, dstBox, shaderProgram, color, blend | GLS_DEPTHTEST_DISABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FBO_FastBlit(FBO_t *src, vec4i_t srcBox, FBO_t *dst, vec4i_t dstBox, int buffers, int filter)
|
void FBO_FastBlit(FBO_t *src, vec4i_t srcBox, FBO_t *dst, vec4i_t dstBox, int buffers, int filter)
|
||||||
|
|
|
@ -1675,7 +1675,8 @@ typedef struct {
|
||||||
|
|
||||||
#ifdef REACTION
|
#ifdef REACTION
|
||||||
vec3_t sunFlarePos;
|
vec3_t sunFlarePos;
|
||||||
qboolean hasSunFlare;
|
qboolean viewHasSunFlare;
|
||||||
|
qboolean frameHasSunFlare;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
qboolean projection2D; // if qtrue, drawstretchpic doesn't need to change modes
|
qboolean projection2D; // if qtrue, drawstretchpic doesn't need to change modes
|
||||||
|
@ -2116,6 +2117,8 @@ void GL_Cull( int cullType );
|
||||||
|
|
||||||
#define GLS_DEPTHTEST_DISABLE 0x00010000
|
#define GLS_DEPTHTEST_DISABLE 0x00010000
|
||||||
#define GLS_DEPTHFUNC_EQUAL 0x00020000
|
#define GLS_DEPTHFUNC_EQUAL 0x00020000
|
||||||
|
#define GLS_DEPTHFUNC_GREATER 0x00040000
|
||||||
|
#define GLS_DEPTHFUNC_BITS 0x00060000
|
||||||
|
|
||||||
#define GLS_ATEST_GT_0 0x10000000
|
#define GLS_ATEST_GT_0 0x10000000
|
||||||
#define GLS_ATEST_LT_80 0x20000000
|
#define GLS_ATEST_LT_80 0x20000000
|
||||||
|
|
|
@ -296,7 +296,7 @@ void RB_GodRays(void)
|
||||||
matrix_t mvp;
|
matrix_t mvp;
|
||||||
vec4_t pos, hpos;
|
vec4_t pos, hpos;
|
||||||
|
|
||||||
if (!backEnd.hasSunFlare)
|
if (!backEnd.viewHasSunFlare)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
VectorSubtract(backEnd.sunFlarePos, backEnd.viewParms.or.origin, dir);
|
VectorSubtract(backEnd.sunFlarePos, backEnd.viewParms.or.origin, dir);
|
||||||
|
@ -473,7 +473,7 @@ void RB_GaussianBlur(float blur)
|
||||||
VectorSet4(srcBox, 0, 0, tr.whiteImage->width, tr.whiteImage->height);
|
VectorSet4(srcBox, 0, 0, tr.whiteImage->width, tr.whiteImage->height);
|
||||||
VectorSet4(dstBox, 0, 0, tr.textureScratchFbo[0]->width, tr.textureScratchFbo[0]->height);
|
VectorSet4(dstBox, 0, 0, tr.textureScratchFbo[0]->width, tr.textureScratchFbo[0]->height);
|
||||||
qglColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_TRUE);
|
qglColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_TRUE);
|
||||||
FBO_BlitFromTexture(tr.whiteImage, srcBox, texScale, tr.textureScratchFbo[0], dstBox, &tr.textureColorShader, color, 0);
|
FBO_BlitFromTexture(tr.whiteImage, srcBox, texScale, tr.textureScratchFbo[0], dstBox, &tr.textureColorShader, color, GLS_DEPTHTEST_DISABLE);
|
||||||
qglColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
qglColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
||||||
|
|
||||||
// blur the tiny buffer horizontally and vertically
|
// blur the tiny buffer horizontally and vertically
|
||||||
|
|
|
@ -297,7 +297,7 @@ static void RB_SurfaceSprite( void ) {
|
||||||
#ifdef REACTION
|
#ifdef REACTION
|
||||||
if (ent->e.renderfx & RF_SUNFLARE)
|
if (ent->e.renderfx & RF_SUNFLARE)
|
||||||
{
|
{
|
||||||
if (backEnd.hasSunFlare)
|
if (backEnd.viewHasSunFlare)
|
||||||
{
|
{
|
||||||
ri.Printf(PRINT_WARNING, "Multiple sun flares not supported\n");
|
ri.Printf(PRINT_WARNING, "Multiple sun flares not supported\n");
|
||||||
return;
|
return;
|
||||||
|
@ -307,7 +307,8 @@ static void RB_SurfaceSprite( void ) {
|
||||||
colors[0] = colors[1] = colors[2] = colors[3] = ent->e.shaderRGBA[glRefConfig.framebufferObject] / 255.0f;
|
colors[0] = colors[1] = colors[2] = colors[3] = ent->e.shaderRGBA[glRefConfig.framebufferObject] / 255.0f;
|
||||||
if (colors[0] == 0)
|
if (colors[0] == 0)
|
||||||
return;
|
return;
|
||||||
backEnd.hasSunFlare = qtrue;
|
backEnd.viewHasSunFlare = qtrue;
|
||||||
|
backEnd.frameHasSunFlare = qtrue;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue