ioquake3 resync to commit f9547e45 from 93abc60a

OpenGL2: Fix sun rays being affected by the viewport size
OpenGL2: Fix merged lightmap hacks to have real lightmap index
OpenGL2: Fix using merged lightmaps with tcGen environment
OpenGL2: Fix hack for tcMod transform on merged lightmaps
OpenGL2: Fix flares behind mirror being visible
Fix running on Windows XP
Fix GitHub Actions CI deprecation warnings
OpenGL2: Don't mix drawing to default framebuffer and FBO
This commit is contained in:
Zack Middleton 2024-03-02 05:38:55 -06:00
parent d8dcb28d04
commit 6f62f2806a
11 changed files with 131 additions and 75 deletions

View file

@ -6,7 +6,7 @@ jobs:
name: Linux name: Linux
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
- name: Install Dependencies - name: Install Dependencies
run: | run: |
sudo apt-get update sudo apt-get update
@ -15,7 +15,7 @@ jobs:
run: make release -C engine run: make release -C engine
env: env:
ARCHIVE: 1 ARCHIVE: 1
- uses: actions/upload-artifact@v3 - uses: actions/upload-artifact@v4
with: with:
name: Linux name: Linux
path: engine/build/*.zip path: engine/build/*.zip
@ -23,14 +23,14 @@ jobs:
name: Windows name: Windows
runs-on: windows-2019 runs-on: windows-2019
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
- name: Compile - name: Compile
run: | run: |
choco install zip choco install zip
make release -C engine make release -C engine
env: env:
ARCHIVE: 1 ARCHIVE: 1
- uses: actions/upload-artifact@v3 - uses: actions/upload-artifact@v4
with: with:
name: Windows name: Windows
path: engine/build/*.zip path: engine/build/*.zip
@ -38,12 +38,12 @@ jobs:
name: macOS name: macOS
runs-on: macos-11 runs-on: macos-11
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
- name: Compile - name: Compile
run: make release -C engine run: make release -C engine
env: env:
ARCHIVE: 1 ARCHIVE: 1
- uses: actions/upload-artifact@v3 - uses: actions/upload-artifact@v4
with: with:
name: macOS name: macOS
path: engine/build/*.zip path: engine/build/*.zip

View file

@ -48,7 +48,7 @@ ifndef BUILD_AUTOUPDATER # DON'T build unless you mean to!
endif endif
# ioquake3 git commit that this is based on # ioquake3 git commit that this is based on
IOQ3_REVISION = 93abc60a IOQ3_REVISION = f9547e45
############################################################################# #############################################################################
# #

View file

@ -342,7 +342,7 @@ void RB_BeginDrawingView (void) {
{ {
FBO_t *fbo = backEnd.viewParms.targetFbo; FBO_t *fbo = backEnd.viewParms.targetFbo;
if (fbo == NULL && (!r_postProcess->integer || !(backEnd.refdef.rdflags & RDF_NOWORLDMODEL))) if (fbo == NULL)
fbo = tr.renderFbo; fbo = tr.renderFbo;
if (tr.renderCubeFbo && fbo == tr.renderCubeFbo) if (tr.renderCubeFbo && fbo == tr.renderCubeFbo)
@ -455,7 +455,7 @@ void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) {
for (i = 0, drawSurf = drawSurfs ; i < numDrawSurfs ; i++, drawSurf++) { for (i = 0, drawSurf = drawSurfs ; i < numDrawSurfs ; i++, drawSurf++) {
if ( drawSurf->sort == oldSort && drawSurf->cubemapIndex == oldCubemapIndex) { if ( drawSurf->sort == oldSort && drawSurf->cubemapIndex == oldCubemapIndex) {
if (backEnd.depthFill && shader && shader->sort != SS_OPAQUE) if (backEnd.depthFill && shader && (shader->sort != SS_OPAQUE && shader->sort != SS_PORTAL))
continue; continue;
// fast path, same as previous sort // fast path, same as previous sort
@ -484,7 +484,7 @@ void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) {
oldCubemapIndex = cubemapIndex; oldCubemapIndex = cubemapIndex;
} }
if (backEnd.depthFill && shader && shader->sort != SS_OPAQUE) if (backEnd.depthFill && shader && (shader->sort != SS_OPAQUE && shader->sort != SS_PORTAL))
continue; continue;
// //
@ -708,7 +708,7 @@ void RE_StretchRaw (int x, int y, int w, int h, int cols, int rows, const byte *
if (glRefConfig.framebufferObject) if (glRefConfig.framebufferObject)
{ {
FBO_Bind(r_postProcess->integer ? NULL : tr.renderFbo); FBO_Bind(tr.renderFbo);
} }
RB_SetGL2D(); RB_SetGL2D();
@ -793,7 +793,7 @@ const void *RB_StretchPic ( const void *data ) {
cmd = (const stretchPicCommand_t *)data; cmd = (const stretchPicCommand_t *)data;
if (glRefConfig.framebufferObject) if (glRefConfig.framebufferObject)
FBO_Bind(r_postProcess->integer ? NULL : tr.renderFbo); FBO_Bind(tr.renderFbo);
RB_SetGL2D(); RB_SetGL2D();
@ -1202,15 +1202,12 @@ const void *RB_DrawBuffer( const void *data ) {
// clear screen for debugging // clear screen for debugging
if ( r_clear->integer ) { if ( r_clear->integer ) {
qglClearColor( 1, 0, 0.5, 1 );
qglClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
if (glRefConfig.framebufferObject && tr.renderFbo) { if (glRefConfig.framebufferObject && tr.renderFbo) {
FBO_Bind(tr.renderFbo); FBO_Bind(tr.renderFbo);
qglClearColor( 1, 0, 0.5, 1 );
qglClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
} }
qglClearColor( 1, 0, 0.5, 1 );
qglClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
} }
return (const void *)(cmd + 1); return (const void *)(cmd + 1);
@ -1381,18 +1378,15 @@ const void *RB_SwapBuffers( const void *data ) {
if (glRefConfig.framebufferObject) if (glRefConfig.framebufferObject)
{ {
if (!r_postProcess->integer) if (tr.msaaResolveFbo && r_hdr->integer)
{ {
if (tr.msaaResolveFbo && r_hdr->integer) // Resolving an RGB16F MSAA FBO to the screen messes with the brightness, so resolve to an RGB16F FBO first
{ FBO_FastBlit(tr.renderFbo, NULL, tr.msaaResolveFbo, NULL, GL_COLOR_BUFFER_BIT, GL_NEAREST);
// Resolving an RGB16F MSAA FBO to the screen messes with the brightness, so resolve to an RGB16F FBO first FBO_FastBlit(tr.msaaResolveFbo, NULL, NULL, NULL, GL_COLOR_BUFFER_BIT, GL_NEAREST);
FBO_FastBlit(tr.renderFbo, NULL, tr.msaaResolveFbo, NULL, GL_COLOR_BUFFER_BIT, GL_NEAREST); }
FBO_FastBlit(tr.msaaResolveFbo, NULL, NULL, NULL, GL_COLOR_BUFFER_BIT, GL_NEAREST); else if (tr.renderFbo)
} {
else if (tr.renderFbo) FBO_FastBlit(tr.renderFbo, NULL, NULL, NULL, GL_COLOR_BUFFER_BIT, GL_NEAREST);
{
FBO_FastBlit(tr.renderFbo, NULL, NULL, NULL, GL_COLOR_BUFFER_BIT, GL_NEAREST);
}
} }
} }
@ -1454,7 +1448,7 @@ RB_PostProcess
const void *RB_PostProcess(const void *data) const void *RB_PostProcess(const void *data)
{ {
const postProcessCommand_t *cmd = data; const postProcessCommand_t *cmd = data;
FBO_t *srcFbo; FBO_t *srcFbo, *dstFbo;
ivec4_t srcBox, dstBox; ivec4_t srcBox, dstBox;
qboolean autoExposure; qboolean autoExposure;
@ -1475,6 +1469,8 @@ const void *RB_PostProcess(const void *data)
} }
srcFbo = tr.renderFbo; srcFbo = tr.renderFbo;
dstFbo = tr.renderFbo;
if (tr.msaaResolveFbo) if (tr.msaaResolveFbo)
{ {
// Resolve the MSAA before anything else // Resolve the MSAA before anything else
@ -1508,13 +1504,13 @@ const void *RB_PostProcess(const void *data)
if (r_hdr->integer && (r_toneMap->integer || r_forceToneMap->integer)) if (r_hdr->integer && (r_toneMap->integer || r_forceToneMap->integer))
{ {
autoExposure = r_autoExposure->integer || r_forceAutoExposure->integer; autoExposure = r_autoExposure->integer || r_forceAutoExposure->integer;
RB_ToneMap(srcFbo, srcBox, NULL, dstBox, autoExposure);
// Use an intermediate FBO because it can't blit to the same FBO directly
// and can't read from an MSAA dstFbo later.
RB_ToneMap(srcFbo, srcBox, tr.screenScratchFbo, srcBox, autoExposure);
FBO_FastBlit(tr.screenScratchFbo, srcBox, srcFbo, srcBox, GL_COLOR_BUFFER_BIT, GL_NEAREST);
} }
else if (r_cameraExposure->value == 0.0f) else if (r_cameraExposure->value != 0.0f)
{
FBO_FastBlit(srcFbo, srcBox, NULL, dstBox, GL_COLOR_BUFFER_BIT, GL_NEAREST);
}
else
{ {
vec4_t color; vec4_t color;
@ -1523,17 +1519,20 @@ const void *RB_PostProcess(const void *data)
color[2] = pow(2, r_cameraExposure->value); //exp2(r_cameraExposure->value); color[2] = pow(2, r_cameraExposure->value); //exp2(r_cameraExposure->value);
color[3] = 1.0f; color[3] = 1.0f;
FBO_Blit(srcFbo, srcBox, NULL, NULL, dstBox, NULL, color, 0); FBO_BlitFromTexture(tr.whiteImage, NULL, NULL, srcFbo, srcBox, NULL, color, GLS_SRCBLEND_DST_COLOR | GLS_DSTBLEND_ZERO);
} }
} }
if (r_drawSunRays->integer) if (r_drawSunRays->integer)
RB_SunRays(NULL, srcBox, NULL, dstBox); RB_SunRays(srcFbo, srcBox, srcFbo, srcBox);
if (1) if (1)
RB_BokehBlur(NULL, srcBox, NULL, dstBox, backEnd.refdef.blurFactor); RB_BokehBlur(srcFbo, srcBox, srcFbo, srcBox, backEnd.refdef.blurFactor);
else else
RB_GaussianBlur(backEnd.refdef.blurFactor); RB_GaussianBlur(srcFbo, srcFbo, backEnd.refdef.blurFactor);
if (srcFbo != dstFbo)
FBO_FastBlit(srcFbo, srcBox, dstFbo, dstBox, GL_COLOR_BUFFER_BIT, GL_NEAREST);
#if 0 #if 0
if (0) if (0)
@ -1549,7 +1548,7 @@ const void *RB_PostProcess(const void *data)
if (scale < 0.01f) if (scale < 0.01f)
scale = 5.0f; scale = 5.0f;
FBO_FastBlit(NULL, NULL, tr.quarterFbo[0], NULL, GL_COLOR_BUFFER_BIT, GL_LINEAR); FBO_FastBlit(dstFbo, NULL, tr.quarterFbo[0], NULL, GL_COLOR_BUFFER_BIT, GL_LINEAR);
iQtrBox[0] = backEnd.viewParms.viewportX * tr.quarterImage[0]->width / (float)glConfig.vidWidth; iQtrBox[0] = backEnd.viewParms.viewportX * tr.quarterImage[0]->width / (float)glConfig.vidWidth;
iQtrBox[1] = backEnd.viewParms.viewportY * tr.quarterImage[0]->height / (float)glConfig.vidHeight; iQtrBox[1] = backEnd.viewParms.viewportY * tr.quarterImage[0]->height / (float)glConfig.vidHeight;
@ -1595,7 +1594,7 @@ const void *RB_PostProcess(const void *data)
SetViewportAndScissor(); SetViewportAndScissor();
FBO_FastBlit(tr.quarterFbo[1], NULL, NULL, NULL, GL_COLOR_BUFFER_BIT, GL_LINEAR); FBO_FastBlit(tr.quarterFbo[1], NULL, dstFbo, NULL, GL_COLOR_BUFFER_BIT, GL_LINEAR);
FBO_Bind(NULL); FBO_Bind(NULL);
} }
#endif #endif
@ -1604,42 +1603,42 @@ const void *RB_PostProcess(const void *data)
{ {
ivec4_t dstBox; ivec4_t dstBox;
VectorSet4(dstBox, 0, glConfig.vidHeight - 128, 128, 128); VectorSet4(dstBox, 0, glConfig.vidHeight - 128, 128, 128);
FBO_BlitFromTexture(tr.sunShadowDepthImage[0], NULL, NULL, NULL, dstBox, NULL, NULL, 0); FBO_BlitFromTexture(tr.sunShadowDepthImage[0], NULL, NULL, dstFbo, dstBox, NULL, NULL, 0);
VectorSet4(dstBox, 128, glConfig.vidHeight - 128, 128, 128); VectorSet4(dstBox, 128, glConfig.vidHeight - 128, 128, 128);
FBO_BlitFromTexture(tr.sunShadowDepthImage[1], NULL, NULL, NULL, dstBox, NULL, NULL, 0); FBO_BlitFromTexture(tr.sunShadowDepthImage[1], NULL, NULL, dstFbo, dstBox, NULL, NULL, 0);
VectorSet4(dstBox, 256, glConfig.vidHeight - 128, 128, 128); VectorSet4(dstBox, 256, glConfig.vidHeight - 128, 128, 128);
FBO_BlitFromTexture(tr.sunShadowDepthImage[2], NULL, NULL, NULL, dstBox, NULL, NULL, 0); FBO_BlitFromTexture(tr.sunShadowDepthImage[2], NULL, NULL, dstFbo, dstBox, NULL, NULL, 0);
VectorSet4(dstBox, 384, glConfig.vidHeight - 128, 128, 128); VectorSet4(dstBox, 384, glConfig.vidHeight - 128, 128, 128);
FBO_BlitFromTexture(tr.sunShadowDepthImage[3], NULL, NULL, NULL, dstBox, NULL, NULL, 0); FBO_BlitFromTexture(tr.sunShadowDepthImage[3], NULL, NULL, dstFbo, dstBox, NULL, NULL, 0);
} }
if (0 && r_shadows->integer == 4) if (0 && r_shadows->integer == 4)
{ {
ivec4_t dstBox; ivec4_t dstBox;
VectorSet4(dstBox, 512 + 0, glConfig.vidHeight - 128, 128, 128); VectorSet4(dstBox, 512 + 0, glConfig.vidHeight - 128, 128, 128);
FBO_BlitFromTexture(tr.pshadowMaps[0], NULL, NULL, NULL, dstBox, NULL, NULL, 0); FBO_BlitFromTexture(tr.pshadowMaps[0], NULL, NULL, dstFbo, dstBox, NULL, NULL, 0);
VectorSet4(dstBox, 512 + 128, glConfig.vidHeight - 128, 128, 128); VectorSet4(dstBox, 512 + 128, glConfig.vidHeight - 128, 128, 128);
FBO_BlitFromTexture(tr.pshadowMaps[1], NULL, NULL, NULL, dstBox, NULL, NULL, 0); FBO_BlitFromTexture(tr.pshadowMaps[1], NULL, NULL, dstFbo, dstBox, NULL, NULL, 0);
VectorSet4(dstBox, 512 + 256, glConfig.vidHeight - 128, 128, 128); VectorSet4(dstBox, 512 + 256, glConfig.vidHeight - 128, 128, 128);
FBO_BlitFromTexture(tr.pshadowMaps[2], NULL, NULL, NULL, dstBox, NULL, NULL, 0); FBO_BlitFromTexture(tr.pshadowMaps[2], NULL, NULL, dstFbo, dstBox, NULL, NULL, 0);
VectorSet4(dstBox, 512 + 384, glConfig.vidHeight - 128, 128, 128); VectorSet4(dstBox, 512 + 384, glConfig.vidHeight - 128, 128, 128);
FBO_BlitFromTexture(tr.pshadowMaps[3], NULL, NULL, NULL, dstBox, NULL, NULL, 0); FBO_BlitFromTexture(tr.pshadowMaps[3], NULL, NULL, dstFbo, dstBox, NULL, NULL, 0);
} }
if (0) if (0)
{ {
ivec4_t dstBox; ivec4_t dstBox;
VectorSet4(dstBox, 256, glConfig.vidHeight - 256, 256, 256); VectorSet4(dstBox, 256, glConfig.vidHeight - 256, 256, 256);
FBO_BlitFromTexture(tr.renderDepthImage, NULL, NULL, NULL, dstBox, NULL, NULL, 0); FBO_BlitFromTexture(tr.renderDepthImage, NULL, NULL, dstFbo, dstBox, NULL, NULL, 0);
VectorSet4(dstBox, 512, glConfig.vidHeight - 256, 256, 256); VectorSet4(dstBox, 512, glConfig.vidHeight - 256, 256, 256);
FBO_BlitFromTexture(tr.screenShadowImage, NULL, NULL, NULL, dstBox, NULL, NULL, 0); FBO_BlitFromTexture(tr.screenShadowImage, NULL, NULL, dstFbo, dstBox, NULL, NULL, 0);
} }
if (0) if (0)
{ {
ivec4_t dstBox; ivec4_t dstBox;
VectorSet4(dstBox, 256, glConfig.vidHeight - 256, 256, 256); VectorSet4(dstBox, 256, glConfig.vidHeight - 256, 256, 256);
FBO_BlitFromTexture(tr.sunRaysImage, NULL, NULL, NULL, dstBox, NULL, NULL, 0); FBO_BlitFromTexture(tr.sunRaysImage, NULL, NULL, dstFbo, dstBox, NULL, NULL, 0);
} }
#if 0 #if 0
@ -1651,8 +1650,8 @@ const void *RB_PostProcess(const void *data)
if (cubemapIndex) if (cubemapIndex)
{ {
VectorSet4(dstBox, 0, glConfig.vidHeight - 256, 256, 256); VectorSet4(dstBox, 0, glConfig.vidHeight - 256, 256, 256);
//FBO_BlitFromTexture(tr.renderCubeImage, NULL, NULL, NULL, dstBox, &tr.testcubeShader, NULL, 0); //FBO_BlitFromTexture(tr.renderCubeImage, NULL, NULL, dstFbo, dstBox, &tr.testcubeShader, NULL, 0);
FBO_BlitFromTexture(tr.cubemaps[cubemapIndex - 1].image, NULL, NULL, NULL, dstBox, &tr.testcubeShader, NULL, 0); FBO_BlitFromTexture(tr.cubemaps[cubemapIndex - 1].image, NULL, NULL, dstFbo, dstBox, &tr.testcubeShader, NULL, 0);
} }
} }
#endif #endif

View file

@ -617,7 +617,7 @@ static shader_t *ShaderForShaderNum( int shaderNum, int lightmapNum ) {
lightmapNum = LIGHTMAP_WHITEIMAGE; lightmapNum = LIGHTMAP_WHITEIMAGE;
} }
shader = R_FindShader( dsh->shader, lightmapNum, qtrue ); shader = R_FindShaderEx( dsh->shader, FatLightmap( lightmapNum ), qtrue, lightmapNum );
// if the shader had errors, just use default shader // if the shader had errors, just use default shader
if ( shader->defaultShader ) { if ( shader->defaultShader ) {
@ -706,7 +706,7 @@ static void ParseFace( dsurface_t *ds, drawVert_t *verts, float *hdrVertColors,
surf->fogIndex = LittleLong( ds->fogNum ) + 1; surf->fogIndex = LittleLong( ds->fogNum ) + 1;
// get shader value // get shader value
surf->shader = ShaderForShaderNum( ds->shaderNum, FatLightmap(realLightmapNum) ); surf->shader = ShaderForShaderNum( ds->shaderNum, realLightmapNum );
if ( r_singleShader->integer && !surf->shader->isSky ) { if ( r_singleShader->integer && !surf->shader->isSky ) {
surf->shader = tr.defaultShader; surf->shader = tr.defaultShader;
} }
@ -813,7 +813,7 @@ static void ParseMesh ( dsurface_t *ds, drawVert_t *verts, float *hdrVertColors,
surf->fogIndex = LittleLong( ds->fogNum ) + 1; surf->fogIndex = LittleLong( ds->fogNum ) + 1;
// get shader value // get shader value
surf->shader = ShaderForShaderNum( ds->shaderNum, FatLightmap(realLightmapNum) ); surf->shader = ShaderForShaderNum( ds->shaderNum, realLightmapNum );
if ( r_singleShader->integer && !surf->shader->isSky ) { if ( r_singleShader->integer && !surf->shader->isSky ) {
surf->shader = tr.defaultShader; surf->shader = tr.defaultShader;
} }

View file

@ -648,10 +648,30 @@ void FBO_FastBlit(FBO_t *src, ivec4_t srcBox, FBO_t *dst, ivec4_t dstBox, int bu
int width = dst ? dst->width : glConfig.vidWidth; int width = dst ? dst->width : glConfig.vidWidth;
int height = dst ? dst->height : glConfig.vidHeight; int height = dst ? dst->height : glConfig.vidHeight;
qglScissor(0, 0, width, height);
VectorSet4(dstBoxFinal, 0, 0, width, height); VectorSet4(dstBoxFinal, 0, 0, width, height);
} }
else else
{ {
ivec4_t scissorBox;
Vector4Copy(dstBox, scissorBox);
if (scissorBox[2] < 0)
{
scissorBox[0] += scissorBox[2];
scissorBox[2] = fabsf(scissorBox[2]);
}
if (scissorBox[3] < 0)
{
scissorBox[1] += scissorBox[3];
scissorBox[3] = fabsf(scissorBox[3]);
}
qglScissor(scissorBox[0], scissorBox[1], scissorBox[2], scissorBox[3]);
VectorSet4(dstBoxFinal, dstBox[0], dstBox[1], dstBox[0] + dstBox[2], dstBox[1] + dstBox[3]); VectorSet4(dstBoxFinal, dstBox[0], dstBox[1], dstBox[0] + dstBox[2], dstBox[1] + dstBox[3]);
} }

View file

@ -2766,7 +2766,7 @@ void R_CreateBuiltinImages( void ) {
tr.renderImage = R_CreateImage("_render", NULL, width, height, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, hdrFormat); tr.renderImage = R_CreateImage("_render", NULL, width, height, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, hdrFormat);
if (r_shadowBlur->integer) if (r_shadowBlur->integer || r_hdr->integer)
tr.screenScratchImage = R_CreateImage("screenScratch", NULL, width, height, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, rgbFormat); tr.screenScratchImage = R_CreateImage("screenScratch", NULL, width, height, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, rgbFormat);
if (r_shadowBlur->integer || r_ssao->integer) if (r_shadowBlur->integer || r_ssao->integer)

View file

@ -1995,6 +1995,7 @@ const void *RB_TakeVideoFrameCmd( const void *data );
// tr_shader.c // tr_shader.c
// //
shader_t *R_FindShader( const char *name, int lightmapIndex, qboolean mipRawImage ); shader_t *R_FindShader( const char *name, int lightmapIndex, qboolean mipRawImage );
shader_t *R_FindShaderEx( const char *name, int lightmapIndex, qboolean mipRawImage, int realLightmapIndex );
shader_t *R_GetShaderByHandle( qhandle_t hShader ); shader_t *R_GetShaderByHandle( qhandle_t hShader );
shader_t *R_GetShaderByState( int index, long *cycleTime ); shader_t *R_GetShaderByState( int index, long *cycleTime );
shader_t *R_FindShaderByName( const char *name ); shader_t *R_FindShaderByName( const char *name );

View file

@ -447,7 +447,7 @@ static void RB_VBlur(FBO_t *srcFbo, FBO_t *dstFbo, float strength)
RB_BlurAxis(srcFbo, dstFbo, strength, qfalse); RB_BlurAxis(srcFbo, dstFbo, strength, qfalse);
} }
void RB_GaussianBlur(float blur) void RB_GaussianBlur(FBO_t *srcFbo, FBO_t *dstFbo, float blur)
{ {
//float mul = 1.f; //float mul = 1.f;
float factor = Com_Clamp(0.f, 1.f, blur); float factor = Com_Clamp(0.f, 1.f, blur);
@ -462,7 +462,7 @@ void RB_GaussianBlur(float blur)
VectorSet4(color, 1, 1, 1, 1); VectorSet4(color, 1, 1, 1, 1);
// first, downsample the framebuffer // first, downsample the framebuffer
FBO_FastBlit(NULL, NULL, tr.quarterFbo[0], NULL, GL_COLOR_BUFFER_BIT, GL_LINEAR); FBO_FastBlit(srcFbo, NULL, tr.quarterFbo[0], NULL, GL_COLOR_BUFFER_BIT, GL_LINEAR);
FBO_FastBlit(tr.quarterFbo[0], NULL, tr.textureScratchFbo[0], NULL, GL_COLOR_BUFFER_BIT, GL_LINEAR); FBO_FastBlit(tr.quarterFbo[0], NULL, tr.textureScratchFbo[0], NULL, GL_COLOR_BUFFER_BIT, GL_LINEAR);
// set the alpha channel // set the alpha channel
@ -478,6 +478,6 @@ void RB_GaussianBlur(float blur)
VectorSet4(srcBox, 0, 0, tr.textureScratchFbo[0]->width, tr.textureScratchFbo[0]->height); VectorSet4(srcBox, 0, 0, tr.textureScratchFbo[0]->width, tr.textureScratchFbo[0]->height);
VectorSet4(dstBox, 0, 0, glConfig.vidWidth, glConfig.vidHeight); VectorSet4(dstBox, 0, 0, glConfig.vidWidth, glConfig.vidHeight);
color[3] = factor; color[3] = factor;
FBO_Blit(tr.textureScratchFbo[0], srcBox, NULL, NULL, dstBox, NULL, color, GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA); FBO_Blit(tr.textureScratchFbo[0], srcBox, NULL, dstFbo, dstBox, NULL, color, GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA);
} }
} }

View file

@ -28,6 +28,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
void RB_ToneMap(FBO_t *hdrFbo, ivec4_t hdrBox, FBO_t *ldrFbo, ivec4_t ldrBox, int autoExposure); void RB_ToneMap(FBO_t *hdrFbo, ivec4_t hdrBox, FBO_t *ldrFbo, ivec4_t ldrBox, int autoExposure);
void RB_BokehBlur(FBO_t *src, ivec4_t srcBox, FBO_t *dst, ivec4_t dstBox, float blur); void RB_BokehBlur(FBO_t *src, ivec4_t srcBox, FBO_t *dst, ivec4_t dstBox, float blur);
void RB_SunRays(FBO_t *srcFbo, ivec4_t srcBox, FBO_t *dstFbo, ivec4_t dstBox); void RB_SunRays(FBO_t *srcFbo, ivec4_t srcBox, FBO_t *dstFbo, ivec4_t dstBox);
void RB_GaussianBlur(float blur); void RB_GaussianBlur(FBO_t *srcFbo, FBO_t *dstFbo, float blur);
#endif #endif

View file

@ -30,6 +30,7 @@ static char *s_shaderText;
static shaderStage_t stages[MAX_SHADER_STAGES]; static shaderStage_t stages[MAX_SHADER_STAGES];
static shader_t shader; static shader_t shader;
static texModInfo_t texMods[MAX_SHADER_STAGES][TR_MAX_TEXMODS]; static texModInfo_t texMods[MAX_SHADER_STAGES][TR_MAX_TEXMODS];
static int shader_realLightmapIndex;
#define FILE_HASH_SIZE 1024 #define FILE_HASH_SIZE 1024
static shader_t* hashTable[FILE_HASH_SIZE]; static shader_t* hashTable[FILE_HASH_SIZE];
@ -2929,7 +2930,7 @@ static void FixFatLightmapTexCoords(void)
return; return;
} }
lightmapnum = shader.lightmapIndex; lightmapnum = shader_realLightmapIndex;
if (tr.worldDeluxeMapping) if (tr.worldDeluxeMapping)
lightmapnum >>= 1; lightmapnum >>= 1;
@ -2943,21 +2944,44 @@ static void FixFatLightmapTexCoords(void)
break; break;
} }
// fix tcMod transform for internal lightmaps, it may be used by q3map2 lightstyles
if ( pStage->bundle[0].isLightmap ) { if ( pStage->bundle[0].isLightmap ) {
for ( i = 0; i < pStage->bundle[0].numTexMods; i++ ) { // fix tcMod transform for internal lightmaps, it may be used by q3map2 lightstyles
tmi = &pStage->bundle[0].texMods[i]; if ( pStage->bundle[0].tcGen == TCGEN_LIGHTMAP ) {
for ( i = 0; i < pStage->bundle[0].numTexMods; i++ ) {
tmi = &pStage->bundle[0].texMods[i];
if ( tmi->type == TMOD_TRANSFORM ) { if ( tmi->type == TMOD_TRANSFORM ) {
tmi->translate[0] /= (float)tr.fatLightmapCols; tmi->translate[0] /= (float)tr.fatLightmapCols;
tmi->translate[1] /= (float)tr.fatLightmapRows; tmi->translate[1] /= (float)tr.fatLightmapRows;
}
}
}
// fix tcGen environment for internal lightmaps to be limited to the sub-image of the atlas
// this is done last so other tcMods are applied first in the 0.0 to 1.0 space
if ( pStage->bundle[0].tcGen == TCGEN_ENVIRONMENT_MAPPED ) {
if ( pStage->bundle[0].numTexMods == TR_MAX_TEXMODS ) {
ri.Printf( PRINT_DEVELOPER, "WARNING: too many tcmods to fix lightmap texcoords for r_mergeLightmaps in shader '%s'", shader.name );
} else {
tmi = &pStage->bundle[0].texMods[pStage->bundle[0].numTexMods];
pStage->bundle[0].numTexMods++;
tmi->matrix[0][0] = 1.0f / tr.fatLightmapCols;
tmi->matrix[0][1] = 0;
tmi->matrix[1][0] = 0;
tmi->matrix[1][1] = 1.0f / tr.fatLightmapRows;
tmi->translate[0] = ( lightmapnum % tr.fatLightmapCols ) / (float)tr.fatLightmapCols;
tmi->translate[1] = ( lightmapnum / tr.fatLightmapCols ) / (float)tr.fatLightmapRows;
tmi->type = TMOD_TRANSFORM;
} }
} }
} }
// add a tcMod transform for external lightmaps to convert back to the original texcoords // add a tcMod transform for external lightmaps to convert back to the original texcoords
else if ( pStage->bundle[0].tcGen == TCGEN_LIGHTMAP ) { else if ( pStage->bundle[0].tcGen == TCGEN_LIGHTMAP ) {
if ( pStage->bundle[0].numTexMods == TR_MAX_TEXMODS ) { if ( pStage->bundle[0].numTexMods == TR_MAX_TEXMODS ) {
ri.Printf( PRINT_DEVELOPER, "WARNING: too many tcmods to fix external lightmap texcoords for r_mergeLightmaps in shader '%s'", shader.name ); ri.Printf( PRINT_DEVELOPER, "WARNING: too many tcmods to fix lightmap texcoords for r_mergeLightmaps in shader '%s'", shader.name );
} else { } else {
size = pStage->bundle[0].numTexMods * sizeof( texModInfo_t ); size = pStage->bundle[0].numTexMods * sizeof( texModInfo_t );
@ -2973,8 +2997,8 @@ static void FixFatLightmapTexCoords(void)
tmi->matrix[1][0] = 0; tmi->matrix[1][0] = 0;
tmi->matrix[1][1] = tr.fatLightmapRows; tmi->matrix[1][1] = tr.fatLightmapRows;
tmi->translate[0] = -(lightmapnum % tr.fatLightmapCols); tmi->translate[0] = -( lightmapnum % tr.fatLightmapCols );
tmi->translate[1] = -(lightmapnum / tr.fatLightmapCols); tmi->translate[1] = -( lightmapnum / tr.fatLightmapCols );
tmi->type = TMOD_TRANSFORM; tmi->type = TMOD_TRANSFORM;
} }
@ -2987,7 +3011,7 @@ static void FixFatLightmapTexCoords(void)
InitShader InitShader
=============== ===============
*/ */
static void InitShader( const char *name, int lightmapIndex ) { static void InitShaderEx( const char *name, int lightmapIndex, int realLightmapIndex ) {
int i; int i;
// clear the global shader // clear the global shader
@ -2996,6 +3020,7 @@ static void InitShader( const char *name, int lightmapIndex ) {
Q_strncpyz( shader.name, name, sizeof( shader.name ) ); Q_strncpyz( shader.name, name, sizeof( shader.name ) );
shader.lightmapIndex = lightmapIndex; shader.lightmapIndex = lightmapIndex;
shader_realLightmapIndex = realLightmapIndex;
for ( i = 0 ; i < MAX_SHADER_STAGES ; i++ ) { for ( i = 0 ; i < MAX_SHADER_STAGES ; i++ ) {
stages[i].bundle[0].texMods = texMods[i]; stages[i].bundle[0].texMods = texMods[i];
@ -3016,6 +3041,10 @@ static void InitShader( const char *name, int lightmapIndex ) {
} }
} }
static void InitShader( const char *name, int lightmapIndex ) {
InitShaderEx( name, lightmapIndex, lightmapIndex );
}
/* /*
========================= =========================
FinishShader FinishShader
@ -3337,6 +3366,10 @@ most world construction surfaces.
=============== ===============
*/ */
shader_t *R_FindShader( const char *name, int lightmapIndex, qboolean mipRawImage ) { shader_t *R_FindShader( const char *name, int lightmapIndex, qboolean mipRawImage ) {
return R_FindShaderEx( name, lightmapIndex, mipRawImage, lightmapIndex );
}
shader_t *R_FindShaderEx( const char *name, int lightmapIndex, qboolean mipRawImage, int realLightmapIndex ) {
char strippedName[MAX_QPATH]; char strippedName[MAX_QPATH];
int hash; int hash;
char *shaderText; char *shaderText;
@ -3376,7 +3409,7 @@ shader_t *R_FindShader( const char *name, int lightmapIndex, qboolean mipRawImag
} }
} }
InitShader( strippedName, lightmapIndex ); InitShaderEx( strippedName, lightmapIndex, realLightmapIndex );
// //
// attempt to define shader from an explicit parameter file // attempt to define shader from an explicit parameter file

View file

@ -20,6 +20,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
=========================================================================== ===========================================================================
*/ */
// Use EnumProcesses() with Windows XP compatibility
#define PSAPI_VERSION 1
#include "../qcommon/q_shared.h" #include "../qcommon/q_shared.h"
#include "../qcommon/qcommon.h" #include "../qcommon/qcommon.h"
#include "sys_local.h" #include "sys_local.h"