- always use glPolygonOffset to render translucent geometry.

This commit is contained in:
Christoph Oelckers 2014-09-20 09:04:36 +02:00
parent 92dcf2e5ef
commit 43e2d704a3
2 changed files with 21 additions and 19 deletions

View file

@ -100,19 +100,20 @@ void FLightBuffer::Clear()
int FLightBuffer::UploadLights(FDynLightData &data) int FLightBuffer::UploadLights(FDynLightData &data)
{ {
unsigned int size0 = data.arrays[0].Size()/4; int size0 = data.arrays[0].Size()/4;
unsigned int size1 = data.arrays[1].Size()/4; int size1 = data.arrays[1].Size()/4;
unsigned int size2 = data.arrays[2].Size()/4; int size2 = data.arrays[2].Size()/4;
unsigned int totalsize = size0 + size1 + size2 + 1; int totalsize = size0 + size1 + size2 + 1;
if (mBlockAlign > 0 && totalsize + (mIndex % mBlockAlign) > mBlockSize) // pointless type casting because some compilers can't print enough warnings.
if (mBlockAlign > 0 && (unsigned int)totalsize + (mIndex % mBlockAlign) > mBlockSize)
{ {
mIndex = ((mIndex + mBlockAlign) / mBlockAlign) * mBlockAlign; mIndex = ((mIndex + mBlockAlign) / mBlockAlign) * mBlockAlign;
// can't be rendered all at once. // can't be rendered all at once.
if (totalsize > mBlockSize) if ((unsigned int)totalsize > mBlockSize)
{ {
int diff = totalsize - mBlockSize; int diff = totalsize - (int)mBlockSize;
size2 -= diff; size2 -= diff;
if (size2 < 0) if (size2 < 0)

View file

@ -238,7 +238,11 @@ void GLWall::RenderFogBoundary()
gl_SetFog(lightlevel, rel, &Colormap, false); gl_SetFog(lightlevel, rel, &Colormap, false);
gl_RenderState.SetEffect(EFF_FOGBOUNDARY); gl_RenderState.SetEffect(EFF_FOGBOUNDARY);
gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f); gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f);
glEnable(GL_POLYGON_OFFSET_FILL);
glPolygonOffset(-1.0f, -128.0f);
RenderWall(RWF_BLANK); RenderWall(RWF_BLANK);
glPolygonOffset(0.0f, 0.0f);
glDisable(GL_POLYGON_OFFSET_FILL);
gl_RenderState.SetEffect(EFF_NONE); gl_RenderState.SetEffect(EFF_NONE);
} }
} }
@ -368,12 +372,6 @@ void GLWall::Draw(int pass)
#endif #endif
if (type == RENDERWALL_COLORLAYER && pass != GLPASS_LIGHTSONLY)
{
glEnable(GL_POLYGON_OFFSET_FILL);
glPolygonOffset(-1.0f, -128.0f);
}
switch (pass) switch (pass)
{ {
case GLPASS_LIGHTSONLY: case GLPASS_LIGHTSONLY:
@ -396,6 +394,8 @@ void GLWall::Draw(int pass)
break; break;
case GLPASS_TRANSLUCENT: case GLPASS_TRANSLUCENT:
switch (type) switch (type)
{ {
case RENDERWALL_MIRRORSURFACE: case RENDERWALL_MIRRORSURFACE:
@ -406,15 +406,16 @@ void GLWall::Draw(int pass)
RenderFogBoundary(); RenderFogBoundary();
break; break;
case RENDERWALL_COLORLAYER:
glEnable(GL_POLYGON_OFFSET_FILL);
glPolygonOffset(-1.0f, -128.0f);
RenderTranslucentWall();
glDisable(GL_POLYGON_OFFSET_FILL);
glPolygonOffset(0, 0);
default: default:
RenderTranslucentWall(); RenderTranslucentWall();
break; break;
} }
} }
if (type == RENDERWALL_COLORLAYER && pass != GLPASS_LIGHTSONLY)
{
glDisable(GL_POLYGON_OFFSET_FILL);
glPolygonOffset(0, 0);
}
} }