Re: Doom 3 engine release and game code
if someone has an older gfx card i would be interrested to hear results as well.
Moderator: Inside3D Admins
// preload the shadows
if ( !external ) {
// glStencilOpSeparate if your card supports OpenGL2
if (glConfig.twoSidedStencilAvailable && r_useTwoSidedStencil.GetBool() && glConfig.glVersion >= 2.0) {
qglStencilOpSeparate( backEnd.viewDef->isMirror ? GL_FRONT : GL_BACK, GL_KEEP, tr.stencilDecr, tr.stencilDecr );
qglStencilOpSeparate( backEnd.viewDef->isMirror ? GL_BACK : GL_FRONT, GL_KEEP, tr.stencilIncr, tr.stencilIncr );
GL_Cull( CT_TWO_SIDED );
RB_DrawShadowElementsWithCounters( tri, numIndexes );
} else if (glConfig.twoSidedStencilAvailable && r_useTwoSidedStencil.GetBool()) {
// else fall back to old pre OpenGL2 twosided stencil.
qglEnable( GL_STENCIL_TEST_TWO_SIDE_EXT );
qglActiveStencilFaceEXT( backEnd.viewDef->isMirror ? GL_FRONT : GL_BACK );
qglStencilOp( GL_KEEP, tr.stencilDecr, tr.stencilDecr );
qglActiveStencilFaceEXT( backEnd.viewDef->isMirror ? GL_BACK : GL_FRONT );
qglStencilOp( GL_KEEP, tr.stencilIncr, tr.stencilIncr );
GL_Cull( CT_TWO_SIDED );
RB_DrawShadowElementsWithCounters( tri, numIndexes );
} else if (glConfig.atiTwoSidedStencilAvailable && r_useTwoSidedStencil.GetBool()) {
// if you got a newer ATI card use the ATI version of the OpenGL2 functions.
qglStencilOpSeparateATI( backEnd.viewDef->isMirror ? GL_FRONT : GL_BACK, GL_KEEP, tr.stencilDecr, tr.stencilDecr );
qglStencilOpSeparateATI( backEnd.viewDef->isMirror ? GL_BACK : GL_FRONT, GL_KEEP, tr.stencilIncr, tr.stencilIncr );
GL_Cull( CT_TWO_SIDED );
RB_DrawShadowElementsWithCounters( tri, numIndexes );
} else {
// if you got here your card is ancient good luck.
qglStencilOp( GL_KEEP, tr.stencilDecr, tr.stencilDecr );
GL_Cull( CT_FRONT_SIDED );
RB_DrawShadowElementsWithCounters( tri, numIndexes );
qglStencilOp( GL_KEEP, tr.stencilIncr, tr.stencilIncr );
GL_Cull( CT_BACK_SIDED );
RB_DrawShadowElementsWithCounters( tri, numIndexes );
}
}
// traditional depth-pass stencil shadows (not an else we allways draw this cap)
if (glConfig.twoSidedStencilAvailable && r_useTwoSidedStencil.GetBool() && glConfig.glVersion >= 2.0 ) {
qglStencilOpSeparate( backEnd.viewDef->isMirror ? GL_FRONT : GL_BACK, GL_KEEP, GL_KEEP, tr.stencilIncr );
qglStencilOpSeparate( backEnd.viewDef->isMirror ? GL_BACK : GL_FRONT, GL_KEEP, GL_KEEP, tr.stencilDecr );
GL_Cull( CT_TWO_SIDED );
RB_DrawShadowElementsWithCounters( tri, numIndexes );
} else if (glConfig.twoSidedStencilAvailable && r_useTwoSidedStencil.GetBool()) {
qglEnable( GL_STENCIL_TEST_TWO_SIDE_EXT );
qglActiveStencilFaceEXT( backEnd.viewDef->isMirror ? GL_FRONT : GL_BACK );
qglStencilOp( GL_KEEP, GL_KEEP, tr.stencilIncr );
qglActiveStencilFaceEXT( backEnd.viewDef->isMirror ? GL_BACK : GL_FRONT );
qglStencilOp( GL_KEEP, GL_KEEP, tr.stencilDecr );
GL_Cull( CT_TWO_SIDED );
RB_DrawShadowElementsWithCounters( tri, numIndexes );
} else if(glConfig.atiTwoSidedStencilAvailable && r_useTwoSidedStencil.GetBool()) {
qglStencilOpSeparateATI( backEnd.viewDef->isMirror ? GL_FRONT : GL_BACK, GL_KEEP, GL_KEEP, tr.stencilIncr );
qglStencilOpSeparateATI( backEnd.viewDef->isMirror ? GL_BACK : GL_FRONT, GL_KEEP, GL_KEEP, tr.stencilDecr );
GL_Cull( CT_TWO_SIDED );
RB_DrawShadowElementsWithCounters( tri, numIndexes );
} else {
qglStencilOp( GL_KEEP, GL_KEEP, tr.stencilIncr );
GL_Cull( CT_FRONT_SIDED );
RB_DrawShadowElementsWithCounters( tri, numIndexes );
qglStencilOp( GL_KEEP, GL_KEEP, tr.stencilDecr );
GL_Cull( CT_BACK_SIDED );
RB_DrawShadowElementsWithCounters( tri, numIndexes );
}void RB_StencilShadowPass( const drawSurf_t *drawSurfs ) {
if ( !r_shadows.GetBool() ) {
return;
}
if ( !drawSurfs ) {
return;
}
RB_LogComment( "---------- RB_StencilShadowPass ----------\n" );
globalImages->BindNull();
qglDisableClientState( GL_TEXTURE_COORD_ARRAY );
// for visualizing the shadows
if ( r_showShadows.GetInteger() ) {
if ( r_showShadows.GetInteger() == 2 ) {
// draw filled in
GL_State( GLS_DEPTHMASK | GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE | GLS_DEPTHFUNC_LESS );
} else {
// draw as lines, filling the depth buffer
GL_State( GLS_SRCBLEND_ONE | GLS_DSTBLEND_ZERO | GLS_POLYMODE_LINE | GLS_DEPTHFUNC_ALWAYS );
}
} else {
// don't write to the color buffer, just the stencil buffer
GL_State( GLS_DEPTHMASK | GLS_COLORMASK | GLS_ALPHAMASK | GLS_DEPTHFUNC_LESS );
}
if ( r_shadowPolygonFactor.GetFloat() || r_shadowPolygonOffset.GetFloat() ) {
qglPolygonOffset( r_shadowPolygonFactor.GetFloat(), -r_shadowPolygonOffset.GetFloat() );
qglEnable( GL_POLYGON_OFFSET_FILL );
}
qglStencilFunc( GL_ALWAYS, 1, 255 );
if ( glConfig.depthBoundsTestAvailable && r_useDepthBoundsTest.GetBool() ) {
qglEnable( GL_DEPTH_BOUNDS_TEST_EXT );
}
// LEITH: enable depth clamp
if ( glConfig.depthClampAvailable && r_useDepthClamp.GetBool() ) {
qglEnable( GL_DEPTH_CLAMP );
}
RB_RenderDrawSurfChainWithFunction( drawSurfs, RB_T_Shadow );
GL_Cull( CT_FRONT_SIDED );
if ( r_shadowPolygonFactor.GetFloat() || r_shadowPolygonOffset.GetFloat() ) {
qglDisable( GL_POLYGON_OFFSET_FILL );
}
if ( glConfig.depthBoundsTestAvailable && r_useDepthBoundsTest.GetBool() ) {
qglDisable( GL_DEPTH_BOUNDS_TEST_EXT );
}
// LEITH: disable depth clamp
if ( glConfig.depthClampAvailable && r_useDepthClamp.GetBool() ) {
qglDisable( GL_DEPTH_CLAMP );
}
qglEnableClientState( GL_TEXTURE_COORD_ARRAY );
qglStencilFunc( GL_GEQUAL, 128, 255 );
qglStencilOp( GL_KEEP, GL_KEEP, GL_KEEP );
}static void RB_T_Shadow( const drawSurf_t *surf ) {
const srfTriangles_t *tri;
// set the light position if we are using a vertex program to project the rear surfaces
if ( tr.backEndRendererHasVertexPrograms && r_useShadowVertexProgram.GetBool() && surf->space != backEnd.currentSpace ) {
idVec4 localLight;
R_GlobalPointToLocal( surf->space->modelMatrix, backEnd.vLight->globalLightOrigin, localLight.ToVec3() );
localLight.w = 0.0f;
qglProgramEnvParameter4fvARB( GL_VERTEX_PROGRAM_ARB, PP_LIGHT_ORIGIN, localLight.ToFloatPtr() );
}
tri = surf->geo;
if ( !tri->shadowCache ) {
return;
}
qglVertexPointer( 4, GL_FLOAT, sizeof( shadowCache_t ), vertexCache.Position(tri->shadowCache) );
// we always draw the sil planes, but we may not need to draw the front or rear caps
int numIndexes;
bool external = false;
if ( !r_useExternalShadows.GetInteger() ) {
numIndexes = tri->numIndexes;
} else if ( r_useExternalShadows.GetInteger() == 2 ) { // force to no caps for testing
numIndexes = tri->numShadowIndexesNoCaps;
external = true;
} else if ( ( glConfig.depthClampAvailable && r_useDepthClamp.GetBool() ) || !(surf->dsFlags & DSF_VIEW_INSIDE_SHADOW) ) {
// if we aren't inside the shadow projection, no caps are ever needed
// LEITH: also if depth clamp is enabled the near and far clip planes are disabled removing the need for any caps
numIndexes = tri->numShadowIndexesNoCaps;
external = true;
} else if ( !backEnd.vLight->viewInsideLight && !(surf->geo->shadowCapPlaneBits & SHADOW_CAP_INFINITE) ) {
// if we are inside the shadow projection, but outside the light, and drawing
// a non-infinite shadow, we can skip some caps
if ( backEnd.vLight->viewSeesShadowPlaneBits & surf->geo->shadowCapPlaneBits ) {
// we can see through a rear cap, so we need to draw it, but we can skip the
// caps on the actual surface
numIndexes = tri->numShadowIndexesNoFrontCaps;
} else {
// we don't need to draw any caps
numIndexes = tri->numShadowIndexesNoCaps;
}
external = true;
} else {
// must draw everything
numIndexes = tri->numIndexes;
}
// set depth bounds
if( glConfig.depthBoundsTestAvailable && r_useDepthBoundsTest.GetBool() ) {
qglDepthBoundsEXT( surf->scissorRect.zmin, surf->scissorRect.zmax );
}
// debug visualization
if ( r_showShadows.GetInteger() ) {
if ( r_showShadows.GetInteger() == 3 ) {
if ( external ) {
qglColor3f( 0.1/backEnd.overBright, 1/backEnd.overBright, 0.1/backEnd.overBright );
} else {
// these are the surfaces that require the reverse
qglColor3f( 1/backEnd.overBright, 0.1/backEnd.overBright, 0.1/backEnd.overBright );
}
} else {
// draw different color for turboshadows
if ( surf->geo->shadowCapPlaneBits & SHADOW_CAP_INFINITE ) {
if ( numIndexes == tri->numIndexes ) {
qglColor3f( 1/backEnd.overBright, 0.1/backEnd.overBright, 0.1/backEnd.overBright );
} else {
qglColor3f( 1/backEnd.overBright, 0.4/backEnd.overBright, 0.1/backEnd.overBright );
}
} else {
if ( numIndexes == tri->numIndexes ) {
qglColor3f( 0.1/backEnd.overBright, 1/backEnd.overBright, 0.1/backEnd.overBright );
} else if ( numIndexes == tri->numShadowIndexesNoFrontCaps ) {
qglColor3f( 0.1/backEnd.overBright, 1/backEnd.overBright, 0.6/backEnd.overBright );
} else {
qglColor3f( 0.6/backEnd.overBright, 1/backEnd.overBright, 0.1/backEnd.overBright );
}
}
}
qglStencilOp( GL_KEEP, GL_KEEP, GL_KEEP );
qglDisable( GL_STENCIL_TEST );
GL_Cull( CT_TWO_SIDED );
RB_DrawShadowElementsWithCounters( tri, numIndexes );
GL_Cull( CT_FRONT_SIDED );
qglEnable( GL_STENCIL_TEST );
return;
}
/* new code start */
// preload the shadows
if ( !external ) {
// use glStencilOpSeparate if your card supports OpenGL2
if (glConfig.twoSidedStencilAvailable && r_useTwoSidedStencil.GetBool() && glConfig.glVersion >= 2.0) {
qglStencilOpSeparate( backEnd.viewDef->isMirror ? GL_FRONT : GL_BACK, GL_KEEP, tr.stencilDecr, tr.stencilDecr );
qglStencilOpSeparate( backEnd.viewDef->isMirror ? GL_BACK : GL_FRONT, GL_KEEP, tr.stencilIncr, tr.stencilIncr );
GL_Cull( CT_TWO_SIDED );
RB_DrawShadowElementsWithCounters( tri, numIndexes );
} else if (glConfig.twoSidedStencilAvailable && r_useTwoSidedStencil.GetBool()) {
// else fall back to old pre OpenGL2 twosided stencil.
qglEnable( GL_STENCIL_TEST_TWO_SIDE_EXT );
qglActiveStencilFaceEXT( backEnd.viewDef->isMirror ? GL_FRONT : GL_BACK );
qglStencilOp( GL_KEEP, tr.stencilDecr, tr.stencilDecr );
qglActiveStencilFaceEXT( backEnd.viewDef->isMirror ? GL_BACK : GL_FRONT );
qglStencilOp( GL_KEEP, tr.stencilIncr, tr.stencilIncr );
GL_Cull( CT_TWO_SIDED );
RB_DrawShadowElementsWithCounters( tri, numIndexes );
} else if (glConfig.atiTwoSidedStencilAvailable && r_useTwoSidedStencil.GetBool()) {
// if you got a newer ATI card use the ATI version of the OpenGL2 functions.
qglStencilOpSeparateATI( backEnd.viewDef->isMirror ? GL_FRONT : GL_BACK, GL_KEEP, tr.stencilDecr, tr.stencilDecr );
qglStencilOpSeparateATI( backEnd.viewDef->isMirror ? GL_BACK : GL_FRONT, GL_KEEP, tr.stencilIncr, tr.stencilIncr );
GL_Cull( CT_TWO_SIDED );
RB_DrawShadowElementsWithCounters( tri, numIndexes );
} else {
// if you got here your card is ancient good luck.
qglStencilOp( GL_KEEP, tr.stencilDecr, tr.stencilDecr );
GL_Cull( CT_FRONT_SIDED );
RB_DrawShadowElementsWithCounters( tri, numIndexes );
qglStencilOp( GL_KEEP, tr.stencilIncr, tr.stencilIncr );
GL_Cull( CT_BACK_SIDED );
RB_DrawShadowElementsWithCounters( tri, numIndexes );
}
}
// traditional depth-pass stencil shadows (not an else we allways draw this cap)
if (glConfig.twoSidedStencilAvailable && r_useTwoSidedStencil.GetBool() && glConfig.glVersion >= 2.0 ) {
qglStencilOpSeparate( backEnd.viewDef->isMirror ? GL_FRONT : GL_BACK, GL_KEEP, GL_KEEP, tr.stencilIncr );
qglStencilOpSeparate( backEnd.viewDef->isMirror ? GL_BACK : GL_FRONT, GL_KEEP, GL_KEEP, tr.stencilDecr );
GL_Cull( CT_TWO_SIDED );
RB_DrawShadowElementsWithCounters( tri, numIndexes );
} else if (glConfig.twoSidedStencilAvailable && r_useTwoSidedStencil.GetBool()) {
qglEnable( GL_STENCIL_TEST_TWO_SIDE_EXT );
qglActiveStencilFaceEXT( backEnd.viewDef->isMirror ? GL_FRONT : GL_BACK );
qglStencilOp( GL_KEEP, GL_KEEP, tr.stencilIncr );
qglActiveStencilFaceEXT( backEnd.viewDef->isMirror ? GL_BACK : GL_FRONT );
qglStencilOp( GL_KEEP, GL_KEEP, tr.stencilDecr );
GL_Cull( CT_TWO_SIDED );
RB_DrawShadowElementsWithCounters( tri, numIndexes );
} else if(glConfig.atiTwoSidedStencilAvailable && r_useTwoSidedStencil.GetBool()) {
qglStencilOpSeparateATI( backEnd.viewDef->isMirror ? GL_FRONT : GL_BACK, GL_KEEP, GL_KEEP, tr.stencilIncr );
qglStencilOpSeparateATI( backEnd.viewDef->isMirror ? GL_BACK : GL_FRONT, GL_KEEP, GL_KEEP, tr.stencilDecr );
GL_Cull( CT_TWO_SIDED );
RB_DrawShadowElementsWithCounters( tri, numIndexes );
} else {
qglStencilOp( GL_KEEP, GL_KEEP, tr.stencilIncr );
GL_Cull( CT_FRONT_SIDED );
RB_DrawShadowElementsWithCounters( tri, numIndexes );
qglStencilOp( GL_KEEP, GL_KEEP, tr.stencilDecr );
GL_Cull( CT_BACK_SIDED );
RB_DrawShadowElementsWithCounters( tri, numIndexes );
}
/* new code end */
}void RB_StencilShadowPass( const drawSurf_t *drawSurfs ) {
if ( !r_shadows.GetBool() ) {
return;
}
if ( !drawSurfs ) {
return;
}
RB_LogComment( "---------- RB_StencilShadowPass ----------\n" );
globalImages->BindNull();
qglDisableClientState( GL_TEXTURE_COORD_ARRAY );
// for visualizing the shadows
if ( r_showShadows.GetInteger() ) {
if ( r_showShadows.GetInteger() == 2 ) {
// draw filled in
GL_State( GLS_DEPTHMASK | GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE | GLS_DEPTHFUNC_LESS );
} else {
// draw as lines, filling the depth buffer
GL_State( GLS_SRCBLEND_ONE | GLS_DSTBLEND_ZERO | GLS_POLYMODE_LINE | GLS_DEPTHFUNC_ALWAYS );
}
} else {
// don't write to the color buffer, just the stencil buffer
GL_State( GLS_DEPTHMASK | GLS_COLORMASK | GLS_ALPHAMASK | GLS_DEPTHFUNC_LESS );
}
if ( r_shadowPolygonFactor.GetFloat() || r_shadowPolygonOffset.GetFloat() ) {
qglPolygonOffset( r_shadowPolygonFactor.GetFloat(), -r_shadowPolygonOffset.GetFloat() );
qglEnable( GL_POLYGON_OFFSET_FILL );
}
qglStencilFunc( GL_ALWAYS, 1, 255 );
if ( glConfig.depthBoundsTestAvailable && r_useDepthBoundsTest.GetBool() ) {
qglEnable( GL_DEPTH_BOUNDS_TEST_EXT );
}
// LEITH: enable depth clamp
if ( glConfig.depthClampAvailable && r_useDepthClamp.GetBool() ) {
qglEnable( GL_DEPTH_CLAMP );
}
RB_RenderDrawSurfChainWithFunction( drawSurfs, RB_T_Shadow );
GL_Cull( CT_FRONT_SIDED );
if ( r_shadowPolygonFactor.GetFloat() || r_shadowPolygonOffset.GetFloat() ) {
qglDisable( GL_POLYGON_OFFSET_FILL );
}
if ( glConfig.depthBoundsTestAvailable && r_useDepthBoundsTest.GetBool() ) {
qglDisable( GL_DEPTH_BOUNDS_TEST_EXT );
}
// LEITH: disable depth clamp
if ( glConfig.depthClampAvailable && r_useDepthClamp.GetBool() ) {
qglDisable( GL_DEPTH_CLAMP );
}
qglEnableClientState( GL_TEXTURE_COORD_ARRAY );
qglStencilFunc( GL_GEQUAL, 128, 255 );
qglStencilOp( GL_KEEP, GL_KEEP, GL_KEEP );
}Btw i looked at your darkmod site and noticed you had some other projects running like a hexen mod also noticed that sikkmod seemed to be related to you. Sikkmod will bump doom3 to near crysis levels but it has a few bugs that the author couldnt sort out cause he lacked the full source when he made it. So my idea is to work the improvements from sikkmod into doom3 now that we have the full source. Any who can give a hand with this are welcome since my shader fu is somewhat lacking.

reckless wrote: adding 1024x1024 dds textures and using pom ....
Users browsing this forum: No registered users and 1 guest