diff options
-rw-r--r-- | src/rend2/tr_backend.c | 133 | ||||
-rw-r--r-- | src/rend2/tr_fbo.c | 13 | ||||
-rw-r--r-- | src/rend2/tr_image.c | 6 | ||||
-rw-r--r-- | src/rend2/tr_init.c | 13 | ||||
-rw-r--r-- | src/rend2/tr_local.h | 18 | ||||
-rw-r--r-- | src/rend2/tr_postprocess.c | 36 | ||||
-rw-r--r-- | src/rend2/tr_postprocess.h | 2 | ||||
-rw-r--r-- | src/rend2/tr_scene.c | 6 | ||||
-rw-r--r-- | src/rend2/tr_shader.c | 25 | ||||
-rw-r--r-- | src/rend2/tr_sky.c | 75 | ||||
-rw-r--r-- | src/rend2/tr_surface.c | 22 |
11 files changed, 123 insertions, 226 deletions
diff --git a/src/rend2/tr_backend.c b/src/rend2/tr_backend.c index 4e6ab2dd..0834176b 100644 --- a/src/rend2/tr_backend.c +++ b/src/rend2/tr_backend.c @@ -149,12 +149,6 @@ void GL_BindToTMU( image_t *image, int tmu ) ** GL_Cull */ void GL_Cull( int cullType ) { -#ifdef REACTION - // Makro - flip culling if needed - qboolean flip = (backEnd.currentEntity != NULL && backEnd.currentEntity->mirrored != qfalse && cullType != CT_TWO_SIDED); - cullType ^= flip; // this assumes CT_BACK_SIDED and CT_FRONT_SIDED are 0 or 1 -#endif - if ( glState.faceCulling == cullType ) { return; } @@ -176,6 +170,11 @@ void GL_Cull( int cullType ) { cullFront = !cullFront; } + if ( backEnd.currentEntity && backEnd.currentEntity->mirrored ) + { + cullFront = !cullFront; + } + qglCullFace( cullFront ? GL_FRONT : GL_BACK ); } } @@ -548,10 +547,6 @@ void RB_BeginDrawingView (void) { // we will only draw a sun if there was sky rendered in this view backEnd.skyRenderedThisView = qfalse; -#ifdef REACTION - backEnd.viewHasSunFlare = qfalse; -#endif - // clip to the plane of the portal if ( backEnd.viewParms.isPortal ) { #if 0 @@ -594,9 +589,7 @@ void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) { FBO_t* fbo = NULL; qboolean inQuery = qfalse; -#if 1 //def REACTION float depth[2]; -#endif // save original time for entity shader offsets @@ -616,10 +609,8 @@ void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) { oldSort = -1; depthRange = qfalse; -#if 1 //def REACTION depth[0] = 0.f; depth[1] = 1.f; -#endif backEnd.pc.c_surfaces += numDrawSurfs; @@ -662,22 +653,6 @@ void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) { qboolean sunflare = qfalse; depthRange = isCrosshair = qfalse; -#ifdef REACTION - // if we were rendering to a FBO and the previous entity was a sunflare - // and the current one isn't, switch back to the main fbo - if (oldEntityNum != -1 && fbo && !backEnd.depthFill && - RF_SUNFLARE == (backEnd.refdef.entities[oldEntityNum].e.renderfx & RF_SUNFLARE) && - 0 == (backEnd.refdef.entities[entityNum].e.renderfx & RF_SUNFLARE)) - { - if (inQuery) { - inQuery = qfalse; - qglEndQueryARB(GL_SAMPLES_PASSED_ARB); - } - FBO_Bind(fbo); - qglDepthRange(depth[0], depth[1]); - } -#endif - if ( entityNum != REFENTITYNUM_WORLD ) { backEnd.currentEntity = &backEnd.refdef.entities[entityNum]; backEnd.refdef.floatTime = originalTime - backEnd.currentEntity->e.shaderTime; @@ -693,31 +668,6 @@ void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) { R_TransformDlights( backEnd.refdef.num_dlights, backEnd.refdef.dlights, &backEnd.or ); } -#ifdef REACTION - // if the current entity is a sunflare - if(backEnd.currentEntity->e.renderfx & RF_SUNFLARE && !backEnd.depthFill) { - // if we're rendering to a fbo - if (fbo) { - VectorCopy(backEnd.currentEntity->e.origin, backEnd.sunFlarePos); - // switch FBO - FBO_Bind(tr.godRaysFbo); - - qglClearColor( 0.0f, 0.0f, 0.0f, 1.0f ); - qglClear( GL_COLOR_BUFFER_BIT ); - - qglDepthRange(1.f, 1.f); - if (glRefConfig.occlusionQuery && !inQuery && !backEnd.viewHasSunFlare) { - inQuery = qtrue; - tr.sunFlareQueryActive[tr.sunFlareQueryIndex] = qtrue; - qglBeginQueryARB(GL_SAMPLES_PASSED_ARB, tr.sunFlareQuery[tr.sunFlareQueryIndex]); - } - sunflare = qtrue; - } else { - depthRange = qtrue; - } - } -#endif - if(backEnd.currentEntity->e.renderfx & RF_DEPTHHACK) { // hack the depth range to prevent view model from poking into walls @@ -766,14 +716,12 @@ void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) { } } -#if 1 //def REACTION if(!oldDepthRange) { depth[0] = 0; depth[1] = 0.3f; qglDepthRange (depth[0], depth[1]); } -#endif } else { @@ -784,10 +732,9 @@ void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) { if (!sunflare) qglDepthRange (0, 1); -#if 1 //def REACTION + depth[0] = 0; depth[1] = 1; -#endif } oldDepthRange = depthRange; @@ -812,16 +759,6 @@ void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) { inQuery = qfalse; qglEndQueryARB(GL_SAMPLES_PASSED_ARB); } -#ifdef REACTION - // HACK: flip Z and render black to god rays buffer - if (backEnd.frameHasSunFlare && !backEnd.depthFill) - { - 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 if (glRefConfig.framebufferObject) FBO_Bind(fbo); @@ -829,9 +766,8 @@ void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) { // go back to the world modelview matrix GL_SetModelviewMatrix( backEnd.viewParms.world.modelMatrix ); - //if ( depthRange ) { - qglDepthRange (0, 1); - //} + + qglDepthRange (0, 1); } @@ -1420,9 +1356,35 @@ const void *RB_DrawSurfs( const void *data ) { { RB_RenderDrawSurfList( cmd->drawSurfs, cmd->numDrawSurfs ); -#if 0 - RB_DrawSun(); -#endif + if (r_drawSun->integer) + { + RB_DrawSun(0.1, tr.sunShader); + } + + if (r_drawSunRays->integer) + { + FBO_t *oldFbo = glState.currentFBO; + FBO_Bind(tr.sunRaysFbo); + + qglClearColor( 0.0f, 0.0f, 0.0f, 1.0f ); + qglClear( GL_COLOR_BUFFER_BIT ); + + if (glRefConfig.occlusionQuery) + { + tr.sunFlareQueryActive[tr.sunFlareQueryIndex] = qtrue; + qglBeginQueryARB(GL_SAMPLES_PASSED_ARB, tr.sunFlareQuery[tr.sunFlareQueryIndex]); + } + + RB_DrawSun(0.3, tr.sunFlareShader); + + if (glRefConfig.occlusionQuery) + { + qglEndQueryARB(GL_SAMPLES_PASSED_ARB); + } + + FBO_Bind(oldFbo); + } + // darken down any stencil shadows RB_ShadowFinish(); @@ -1672,9 +1634,6 @@ const void *RB_SwapBuffers( const void *data ) { backEnd.framePostProcessed = qfalse; backEnd.projection2D = qfalse; -#ifdef REACTION - backEnd.frameHasSunFlare = qfalse; -#endif return (const void *)(cmd + 1); } @@ -1764,17 +1723,13 @@ const void *RB_PostProcess(const void *data) } } -#ifdef REACTION - if (1) - { - RB_GodRays(); + if (r_drawSunRays->integer) + RB_SunRays(); - if (1) - RB_BokehBlur(backEnd.refdef.blurFactor); - else - RB_GaussianBlur(backEnd.refdef.blurFactor); - } -#endif + if (1) + RB_BokehBlur(backEnd.refdef.blurFactor); + else + RB_GaussianBlur(backEnd.refdef.blurFactor); if (0) { @@ -1800,7 +1755,7 @@ const void *RB_PostProcess(const void *data) { vec4i_t dstBox; VectorSet4(dstBox, 256, glConfig.vidHeight - 256, 256, 256); - FBO_BlitFromTexture(tr.renderImage, NULL, NULL, tr.screenScratchFbo, dstBox, NULL, NULL, 0); + FBO_BlitFromTexture(tr.sunRaysImage, NULL, NULL, tr.screenScratchFbo, dstBox, NULL, NULL, 0); } backEnd.framePostProcessed = qtrue; diff --git a/src/rend2/tr_fbo.c b/src/rend2/tr_fbo.c index b498fe70..0ad08b20 100644 --- a/src/rend2/tr_fbo.c +++ b/src/rend2/tr_fbo.c @@ -452,20 +452,17 @@ void FBO_Init(void) FBO_Bind(NULL); } -#ifdef REACTION + if (r_drawSunRays->integer) { - tr.godRaysFbo = FBO_Create("_godRays", tr.renderDepthImage->width, tr.renderDepthImage->height); - FBO_Bind(tr.godRaysFbo); + tr.sunRaysFbo = FBO_Create("_sunRays", tr.renderDepthImage->width, tr.renderDepthImage->height); + FBO_Bind(tr.sunRaysFbo); - //FBO_CreateBuffer(tr.godRaysFbo, GL_RGBA8, 0, multisample); - FBO_AttachTextureImage(tr.godRaysImage, 0); + FBO_AttachTextureImage(tr.sunRaysImage, 0); - //FBO_CreateBuffer(tr.godRaysFbo, GL_DEPTH_COMPONENT24_ARB, 0, multisample); R_AttachFBOTextureDepth(tr.renderDepthImage->texnum); - R_CheckFBO(tr.godRaysFbo); + R_CheckFBO(tr.sunRaysFbo); } -#endif // FIXME: Don't use separate color/depth buffers for a shadow buffer for( i = 0; i < MAX_DRAWN_PSHADOWS; i++) diff --git a/src/rend2/tr_image.c b/src/rend2/tr_image.c index 13dda827..8a1f574f 100644 --- a/src/rend2/tr_image.c +++ b/src/rend2/tr_image.c @@ -2959,9 +2959,9 @@ void R_CreateBuiltinImages( void ) { hdrFormat = GL_RGB16F_ARB; tr.renderImage = R_CreateImage("_render", NULL, width, height, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, hdrFormat); -#ifdef REACTION - tr.godRaysImage = R_CreateImage("*godRays", NULL, width, height, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_RGBA8); -#endif + + if (r_drawSunRays->integer) + tr.sunRaysImage = R_CreateImage("*sunRays", NULL, width, height, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_RGBA8); if (r_softOverbright->integer) { diff --git a/src/rend2/tr_init.c b/src/rend2/tr_init.c index ce2f6176..99f4ecaf 100644 --- a/src/rend2/tr_init.c +++ b/src/rend2/tr_init.c @@ -144,6 +144,7 @@ cvar_t *r_forceSun; cvar_t *r_forceSunMapLightScale; cvar_t *r_forceSunLightScale; cvar_t *r_forceSunAmbientScale; +cvar_t *r_drawSunRays; cvar_t *r_sunShadows; cvar_t *r_shadowFilter; cvar_t *r_shadowMapSize; @@ -1108,6 +1109,8 @@ void R_Register( void ) r_forceSunMapLightScale = ri.Cvar_Get( "r_forceSunMapLightScale", "0.5", CVAR_CHEAT ); r_forceSunLightScale = ri.Cvar_Get( "r_forceSunLightScale", "0.5", CVAR_CHEAT ); r_forceSunAmbientScale = ri.Cvar_Get( "r_forceSunAmbientScale", "0.2", CVAR_CHEAT ); + r_drawSunRays = ri.Cvar_Get( "r_drawSunRays", "0", CVAR_ARCHIVE | CVAR_LATCH ); + r_sunShadows = ri.Cvar_Get( "r_sunShadows", "1", CVAR_ARCHIVE | CVAR_LATCH ); r_shadowFilter = ri.Cvar_Get( "r_shadowFilter", "1", CVAR_ARCHIVE | CVAR_LATCH ); r_shadowMapSize = ri.Cvar_Get( "r_shadowMapSize", "1024", CVAR_ARCHIVE | CVAR_LATCH ); @@ -1228,9 +1231,8 @@ void R_InitQueries(void) if (!glRefConfig.occlusionQuery) return; -#ifdef REACTION - qglGenQueriesARB(ARRAY_LEN(tr.sunFlareQuery), tr.sunFlareQuery); -#endif + if (r_drawSunRays->integer) + qglGenQueriesARB(ARRAY_LEN(tr.sunFlareQuery), tr.sunFlareQuery); } void R_ShutDownQueries(void) @@ -1238,9 +1240,8 @@ void R_ShutDownQueries(void) if (!glRefConfig.occlusionQuery) return; -#ifdef REACTION - qglDeleteQueriesARB(ARRAY_LEN(tr.sunFlareQuery), tr.sunFlareQuery); -#endif + if (r_drawSunRays->integer) + qglDeleteQueriesARB(ARRAY_LEN(tr.sunFlareQuery), tr.sunFlareQuery); } /* diff --git a/src/rend2/tr_local.h b/src/rend2/tr_local.h index 4b46f612..a5d57d35 100644 --- a/src/rend2/tr_local.h +++ b/src/rend2/tr_local.h @@ -80,10 +80,8 @@ typedef struct { qboolean needDlights; // true for bmodels that touch a dlight qboolean lightingCalculated; -#ifdef REACTION // JBravo: Mirrored models qboolean mirrored; // mirrored matrix, needs reversed culling -#endif vec3_t lightDir; // normalized direction towards light vec3_t ambientLight; // color normalized to 0-255 int ambientLightInt; // 32 bit rgba packed @@ -1755,12 +1753,6 @@ typedef struct { trRefEntity_t *currentEntity; qboolean skyRenderedThisView; // flag for drawing sun -#ifdef REACTION - vec3_t sunFlarePos; - qboolean viewHasSunFlare; - qboolean frameHasSunFlare; -#endif - qboolean projection2D; // if qtrue, drawstretchpic doesn't need to change modes byte color2D[4]; qboolean vertexes2D; // shader needs to be finished @@ -1814,7 +1806,7 @@ typedef struct { image_t *renderImage; - image_t *godRaysImage; + image_t *sunRaysImage; image_t *renderDepthImage; image_t *pshadowMaps[MAX_DRAWN_PSHADOWS]; image_t *textureScratchImage[2]; @@ -1832,7 +1824,7 @@ typedef struct { FBO_t *renderFbo; FBO_t *msaaResolveFbo; - FBO_t *godRaysFbo; + FBO_t *sunRaysFbo; FBO_t *depthFbo; FBO_t *pshadowFbos[MAX_DRAWN_PSHADOWS]; FBO_t *textureScratchFbo[2]; @@ -1851,6 +1843,7 @@ typedef struct { shader_t *flareShader; shader_t *sunShader; + shader_t *sunFlareShader; int numLightmaps; int lightmapSize; @@ -1940,11 +1933,9 @@ typedef struct { int numSkins; skin_t *skins[MAX_SKINS]; -#ifdef REACTION GLuint sunFlareQuery[2]; int sunFlareQueryIndex; qboolean sunFlareQueryActive[2]; -#endif float sinTable[FUNCTABLE_SIZE]; float squareTable[FUNCTABLE_SIZE]; @@ -2124,6 +2115,7 @@ extern cvar_t *r_forceSun; extern cvar_t *r_forceSunMapLightScale; extern cvar_t *r_forceSunLightScale; extern cvar_t *r_forceSunAmbientScale; +extern cvar_t *r_drawSunRays; extern cvar_t *r_sunShadows; extern cvar_t *r_shadowFilter; extern cvar_t *r_shadowMapSize; @@ -2481,7 +2473,7 @@ SKIES void R_BuildCloudData( shaderCommands_t *shader ); void R_InitSkyTexCoords( float cloudLayerHeight ); void R_DrawSkyBox( shaderCommands_t *shader ); -void RB_DrawSun( void ); +void RB_DrawSun( float scale, shader_t *shader ); void RB_ClipSkyPolygons( shaderCommands_t *shader ); /* diff --git a/src/rend2/tr_postprocess.c b/src/rend2/tr_postprocess.c index 73fa7175..a15c9b7a 100644 --- a/src/rend2/tr_postprocess.c +++ b/src/rend2/tr_postprocess.c @@ -210,7 +210,6 @@ void RB_BokehBlur(float blur) } -#ifdef REACTION static void RB_RadialBlur(FBO_t *srcFbo, FBO_t *dstFbo, int passes, float stretch, float x, float y, float w, float h, float xcenter, float ycenter, float alpha) { vec4i_t srcBox, dstBox; @@ -285,11 +284,10 @@ static qboolean RB_UpdateSunFlareVis(void) return sampleCount > 0; } -void RB_GodRays(void) +void RB_SunRays(void) { vec4i_t srcBox, dstBox; vec4_t color; - vec3_t dir; float dot; const float cutoff = 0.25f; qboolean colorize = qtrue; @@ -298,26 +296,31 @@ void RB_GodRays(void) matrix_t mvp; vec4_t pos, hpos; - if (!backEnd.viewHasSunFlare) - return; - - VectorSubtract(backEnd.sunFlarePos, backEnd.viewParms.or.origin, dir); - VectorNormalize(dir); - - dot = DotProduct(dir, backEnd.viewParms.or.axis[0]); + dot = DotProduct(tr.sunDirection, backEnd.viewParms.or.axis[0]); if (dot < cutoff) return; if (!RB_UpdateSunFlareVis()) return; - VectorCopy(backEnd.sunFlarePos, pos); - pos[3] = 1.f; + // From RB_DrawSun() + { + float dist; + matrix_t trans, model, mvp; + + Matrix16Translation( backEnd.viewParms.or.origin, trans ); + Matrix16Multiply( backEnd.viewParms.world.modelMatrix, trans, model ); + Matrix16Multiply(backEnd.viewParms.projectionMatrix, model, mvp); + + dist = backEnd.viewParms.zFar / 1.75; // div sqrt(3) + + VectorScale( tr.sunDirection, dist, pos ); + } // project sun point - Matrix16Multiply(backEnd.viewParms.projectionMatrix, backEnd.viewParms.world.modelMatrix, mvp); + //Matrix16Multiply(backEnd.viewParms.projectionMatrix, backEnd.viewParms.world.modelMatrix, mvp); Matrix16Transform(mvp, pos, hpos); - + // transform to UV coords hpos[3] = 0.5f / hpos[3]; @@ -345,11 +348,11 @@ void RB_GodRays(void) if (colorize) { FBO_FastBlit(tr.screenScratchFbo, NULL, tr.quarterFbo[0], NULL, GL_COLOR_BUFFER_BIT, GL_LINEAR); - FBO_Blit(tr.godRaysFbo, NULL, NULL, tr.quarterFbo[0], NULL, NULL, color, GLS_SRCBLEND_DST_COLOR | GLS_DSTBLEND_ZERO); + FBO_Blit(tr.sunRaysFbo, NULL, NULL, tr.quarterFbo[0], NULL, NULL, color, GLS_SRCBLEND_DST_COLOR | GLS_DSTBLEND_ZERO); } else { - FBO_FastBlit(tr.godRaysFbo, NULL, tr.quarterFbo[0], NULL, GL_COLOR_BUFFER_BIT, GL_LINEAR); + FBO_FastBlit(tr.sunRaysFbo, NULL, tr.quarterFbo[0], NULL, GL_COLOR_BUFFER_BIT, GL_LINEAR); } } @@ -380,7 +383,6 @@ void RB_GodRays(void) FBO_Blit(tr.quarterFbo[0], srcBox, texScale, tr.screenScratchFbo, dstBox, &tr.textureColorShader, color, GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE); } } -#endif static void RB_BlurAxis(FBO_t *srcFbo, FBO_t *dstFbo, float strength, qboolean horizontal) { diff --git a/src/rend2/tr_postprocess.h b/src/rend2/tr_postprocess.h index d4c22658..1e5ebefe 100644 --- a/src/rend2/tr_postprocess.h +++ b/src/rend2/tr_postprocess.h @@ -27,7 +27,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA void RB_ToneMap(FBO_t *hdrFbo, int autoExposure); void RB_BokehBlur(float blur); -void RB_GodRays(void); +void RB_SunRays(void); void RB_GaussianBlur(float blur); #endif diff --git a/src/rend2/tr_scene.c b/src/rend2/tr_scene.c index c7a414f2..14c18339 100644 --- a/src/rend2/tr_scene.c +++ b/src/rend2/tr_scene.c @@ -202,10 +202,8 @@ RE_AddRefEntityToScene ===================== */ void RE_AddRefEntityToScene( const refEntity_t *ent ) { -#ifdef REACTION // JBravo: Mirrored models vec3_t cross; -#endif if ( !tr.registered ) { return; @@ -229,11 +227,9 @@ void RE_AddRefEntityToScene( const refEntity_t *ent ) { backEndData->entities[r_numentities].e = *ent; backEndData->entities[r_numentities].lightingCalculated = qfalse; -#ifdef REACTION // JBravo: Mirrored models CrossProduct(ent->axis[0], ent->axis[1], cross); backEndData->entities[r_numentities].mirrored = (DotProduct(ent->axis[2], cross) < 0.f); -#endif r_numentities++; } @@ -406,7 +402,6 @@ void RE_RenderScene( const refdef_t *fd ) { tr.refdef.toneMinAvgMaxLinear[2] = pow(2, tr.toneMinAvgMaxLevel[2]); } -//#ifdef REACTION // Makro - copy exta info if present if (fd->rdflags & RDF_EXTRA) { const refdefex_t* extra = (const refdefex_t*) (fd+1); @@ -424,7 +419,6 @@ void RE_RenderScene( const refdef_t *fd ) { { tr.refdef.blurFactor = 0.0f; } -//#endif // derived info diff --git a/src/rend2/tr_shader.c b/src/rend2/tr_shader.c index 04aa73ae..8cad4b6b 100644 --- a/src/rend2/tr_shader.c +++ b/src/rend2/tr_shader.c @@ -3696,6 +3696,31 @@ static void CreateExternalShaders( void ) { } tr.sunShader = R_FindShader( "sun", LIGHTMAP_NONE, qtrue ); + + tr.sunFlareShader = R_FindShader( "gfx/2d/sunflare", LIGHTMAP_NONE, qtrue); + + // HACK: if sunflare is missing, make one using the flare image or dlight image + if (tr.sunFlareShader->defaultShader) + { + image_t *image; + + if (!tr.flareShader->defaultShader && tr.flareShader->stages[0] && tr.flareShader->stages[0]->bundle[0].image[0]) + image = tr.flareShader->stages[0]->bundle[0].image[0]; + else + image = tr.dlightImage; + + Com_Memset( &shader, 0, sizeof( shader ) ); + Com_Memset( &stages, 0, sizeof( stages ) ); + + Q_strncpyz( shader.name, "gfx/2d/sunflare", sizeof( shader.name ) ); + + shader.lightmapIndex = LIGHTMAP_NONE; + stages[0].bundle[0].image[0] = image; + stages[0].active = qtrue; + stages[0].stateBits = GLS_DEFAULT; + tr.sunFlareShader = FinishShader(); + } + } /* diff --git a/src/rend2/tr_sky.c b/src/rend2/tr_sky.c index 62f0cadd..b6efedc0 100644 --- a/src/rend2/tr_sky.c +++ b/src/rend2/tr_sky.c @@ -793,32 +793,28 @@ void R_InitSkyTexCoords( float heightCloud ) /* ** RB_DrawSun */ -void RB_DrawSun( void ) { +void RB_DrawSun( float scale, shader_t *shader ) { float size; float dist; vec3_t origin, vec1, vec2; - vec3_t temp; if ( !backEnd.skyRenderedThisView ) { return; } - if ( !r_drawSun->integer ) { - return; - } //qglLoadMatrixf( backEnd.viewParms.world.modelMatrix ); //qglTranslatef (backEnd.viewParms.or.origin[0], backEnd.viewParms.or.origin[1], backEnd.viewParms.or.origin[2]); { // FIXME: this could be a lot cleaner - matrix_t trans, product; + matrix_t translation, modelview; - Matrix16Translation( backEnd.viewParms.or.origin, trans ); - Matrix16Multiply( backEnd.viewParms.world.modelMatrix, trans, product ); - GL_SetModelviewMatrix( product ); + Matrix16Translation( backEnd.viewParms.or.origin, translation ); + Matrix16Multiply( backEnd.viewParms.world.modelMatrix, translation, modelview ); + GL_SetModelviewMatrix( modelview ); } dist = backEnd.viewParms.zFar / 1.75; // div sqrt(3) - size = dist * 0.4; + size = dist * scale; VectorScale( tr.sunDirection, dist, origin ); PerpendicularVector( vec1, tr.sunDirection ); @@ -830,58 +826,13 @@ void RB_DrawSun( void ) { // farthest depth range qglDepthRange( 1.0, 1.0 ); - // FIXME: use quad stamp - RB_BeginSurface( tr.sunShader, tess.fogNum ); - VectorCopy( origin, temp ); - VectorSubtract( temp, vec1, temp ); - VectorSubtract( temp, vec2, temp ); - VectorCopy( temp, tess.xyz[tess.numVertexes] ); - tess.texCoords[tess.numVertexes][0][0] = 0; - tess.texCoords[tess.numVertexes][0][1] = 0; - tess.vertexColors[tess.numVertexes][0] = 1.0f; - tess.vertexColors[tess.numVertexes][1] = 1.0f; - tess.vertexColors[tess.numVertexes][2] = 1.0f; - tess.numVertexes++; - - VectorCopy( origin, temp ); - VectorAdd( temp, vec1, temp ); - VectorSubtract( temp, vec2, temp ); - VectorCopy( temp, tess.xyz[tess.numVertexes] ); - tess.texCoords[tess.numVertexes][0][0] = 0; - tess.texCoords[tess.numVertexes][0][1] = 1; - tess.vertexColors[tess.numVertexes][0] = 1.0f; - tess.vertexColors[tess.numVertexes][1] = 1.0f; - tess.vertexColors[tess.numVertexes][2] = 1.0f; - tess.numVertexes++; - - VectorCopy( origin, temp ); - VectorAdd( temp, vec1, temp ); - VectorAdd( temp, vec2, temp ); - VectorCopy( temp, tess.xyz[tess.numVertexes] ); - tess.texCoords[tess.numVertexes][0][0] = 1; - tess.texCoords[tess.numVertexes][0][1] = 1; - tess.vertexColors[tess.numVertexes][0] = 1.0f; - tess.vertexColors[tess.numVertexes][1] = 1.0f; - tess.vertexColors[tess.numVertexes][2] = 1.0f; - tess.numVertexes++; - - VectorCopy( origin, temp ); - VectorSubtract( temp, vec1, temp ); - VectorAdd( temp, vec2, temp ); - VectorCopy( temp, tess.xyz[tess.numVertexes] ); - tess.texCoords[tess.numVertexes][0][0] = 1; - tess.texCoords[tess.numVertexes][0][1] = 0; - tess.vertexColors[tess.numVertexes][0] = 1.0f; - tess.vertexColors[tess.numVertexes][1] = 1.0f; - tess.vertexColors[tess.numVertexes][2] = 1.0f; - tess.numVertexes++; - - tess.indexes[tess.numIndexes++] = 0; - tess.indexes[tess.numIndexes++] = 1; - tess.indexes[tess.numIndexes++] = 2; - tess.indexes[tess.numIndexes++] = 0; - tess.indexes[tess.numIndexes++] = 2; - tess.indexes[tess.numIndexes++] = 3; + RB_BeginSurface( shader, 0 ); + + { + vec4_t color; + color[0] = color[1] = color[2] = color[3] = 1; + RB_AddQuadStamp(origin, vec1, vec2, color); + } RB_EndSurface(); diff --git a/src/rend2/tr_surface.c b/src/rend2/tr_surface.c index 406c7a26..ad7f5a5f 100644 --- a/src/rend2/tr_surface.c +++ b/src/rend2/tr_surface.c @@ -300,27 +300,7 @@ static void RB_SurfaceSprite( void ) { VectorSubtract( vec3_origin, left, left ); } -#ifdef REACTION - if (ent->e.renderfx & RF_SUNFLARE) - { - if (backEnd.viewHasSunFlare) - { - ri.Printf(PRINT_WARNING, "Multiple sun flares not supported\n"); - return; - } - if (R_CullPointAndRadiusEx(ent->e.origin, ent->e.radius, backEnd.viewParms.frustum, (backEnd.viewParms.flags & VPF_FARPLANEFRUSTUM) ? 5 : 4) == CULL_OUT) - return; - colors[0] = colors[1] = colors[2] = colors[3] = ent->e.shaderRGBA[glRefConfig.framebufferObject] / 255.0f; - if (colors[0] == 0) - return; - backEnd.viewHasSunFlare = qtrue; - backEnd.frameHasSunFlare = qtrue; - } - else -#endif - { - VectorScale4(ent->e.shaderRGBA, 1.0f / 255.0f, colors); - } + VectorScale4(ent->e.shaderRGBA, 1.0f / 255.0f, colors); RB_AddQuadStamp( ent->e.origin, left, up, colors ); } |