- reinstated old code for rendering fog boundaries and mirrot surfaces without shaders.

- added code for filling the render list for textured dynamic lights. This is not yet active because no code is present to handle this data.
This commit is contained in:
Christoph Oelckers 2016-05-03 23:28:42 +02:00
parent 4ea3339e40
commit 0a94371974
5 changed files with 130 additions and 16 deletions

View File

@ -49,6 +49,7 @@
#include "gl/dynlights/gl_dynlight.h"
#include "gl/utility/gl_geometric.h"
#include "gl/renderer/gl_renderer.h"
#include "gl/renderer/gl_lightdata.h"
#include "gl/system/gl_interface.h"
#include "gl/system/gl_cvars.h"
#include "gl/renderer/gl_renderstate.h"
@ -452,7 +453,7 @@ bool gl_SetupLight(int group, Plane & p, ADynamicLight * light, Vector & nearPt,
bool gl_SetupLightTexture()
{
if (GLRenderer->gllight == NULL) return false;
if (GLRenderer->gllight == nullptr) return false;
FMaterial * pat = FMaterial::ValidateTexture(GLRenderer->gllight, false);
pat->Bind(CLAMP_XY, 0);
return true;
@ -464,6 +465,95 @@ bool gl_SetupLightTexture()
//
//==========================================================================
bool GLWall::PutWallCompat(int passflag)
{
static int list_indices[2][2] =
{ { GLLDL_WALLS_PLAIN, GLLDL_WALLS_FOG },{ GLLDL_WALLS_MASKED, GLLDL_WALLS_FOGMASKED } };
// are lights possible?
if (gl_fixedcolormap != CM_DEFAULT || !gl_lights || seg->sidedef == nullptr || type == RENDERWALL_M2SNF || !gltexture) return false;
// multipassing these is problematic.
if ((flags&GLWF_SKYHACK && type == RENDERWALL_M2S)) return false;
// Any lights affecting this wall?
if (!(seg->sidedef->Flags & WALLF_POLYOBJ))
{
if (seg->sidedef->lighthead == nullptr) return false;
}
else if (sub)
{
if (sub->lighthead != nullptr) return false;
}
bool foggy = (!gl_isBlack(Colormap.FadeColor) || level.flags&LEVEL_HASFADETABLE);
bool masked = passflag == 2 && gltexture->isMasked();
int list = list_indices[masked][foggy];
if (list == GLLDL_WALLS_PLAIN)
{
if (gltexture->tex->gl_info.Brightmap && gl.glslversion >= 0.f) list = GLLDL_WALLS_BRIGHT;
//if (flags & GLWF_GLOW) list = GLLDL_WALLS_BRIGHT;
}
gl_drawinfo->dldrawlists[list].AddWall(this);
return true;
}
//==========================================================================
//
// Fog boundary without any shader support
//
//==========================================================================
void GLWall::RenderFogBoundaryCompat()
{
// without shaders some approximation is needed. This won't look as good
// as the shader version but it's an acceptable compromise.
float fogdensity = gl_GetFogDensity(lightlevel, Colormap.FadeColor);
float dist1 = Dist2(ViewPos.X, ViewPos.Y, glseg.x1, glseg.y1);
float dist2 = Dist2(ViewPos.X, ViewPos.Y, glseg.x2, glseg.y2);
// these values were determined by trial and error and are scale dependent!
float fogd1 = (0.95f - exp(-fogdensity*dist1 / 62500.f)) * 1.05f;
float fogd2 = (0.95f - exp(-fogdensity*dist2 / 62500.f)) * 1.05f;
float fc[4] = { Colormap.FadeColor.r / 255.0f,Colormap.FadeColor.g / 255.0f,Colormap.FadeColor.b / 255.0f,fogd2 };
gl_RenderState.EnableTexture(false);
gl_RenderState.EnableFog(false);
gl_RenderState.AlphaFunc(GL_GEQUAL, 0);
gl_RenderState.Apply();
glEnable(GL_POLYGON_OFFSET_FILL);
glPolygonOffset(-1.0f, -128.0f);
glDepthFunc(GL_LEQUAL);
glColor4f(fc[0], fc[1], fc[2], fogd1);
glBegin(GL_TRIANGLE_FAN);
glTexCoord2f(lolft.u, lolft.v);
glVertex3f(glseg.x1, zbottom[0], glseg.y1);
glTexCoord2f(uplft.u, uplft.v);
glVertex3f(glseg.x1, ztop[0], glseg.y1);
glColor4f(fc[0], fc[1], fc[2], fogd2);
glTexCoord2f(uprgt.u, uprgt.v);
glVertex3f(glseg.x2, ztop[1], glseg.y2);
glTexCoord2f(lorgt.u, lorgt.v);
glVertex3f(glseg.x2, zbottom[1], glseg.y2);
glEnd();
glDepthFunc(GL_LESS);
glPolygonOffset(0.0f, 0.0f);
glDisable(GL_POLYGON_OFFSET_FILL);
gl_RenderState.EnableFog(true);
gl_RenderState.AlphaFunc(GL_GEQUAL, 0.5f);
gl_RenderState.EnableTexture(true);
}
//==========================================================================
//
//
//
//==========================================================================
void FGLRenderer::RenderMultipassStuff()
{
return;

View File

@ -171,10 +171,13 @@ public:
private:
void CheckGlowing();
bool PutWallCompat(int passflag);
void PutWall(bool translucent);
void PutPortal(int ptype);
void CheckTexturePosition();
void RenderFogBoundaryCompat();
void Put3DWall(lightlist_t * lightlist, bool translucent);
void SplitWallComplex(sector_t * frontsector, bool translucent, float maplightbottomleft, float maplightbottomright);
void SplitWall(sector_t * frontsector, bool translucent);

View File

@ -139,6 +139,11 @@ void GLWall::PutWall(bool translucent)
}
else
{
if (gl.lightmethod == LM_SOFTWARE && !translucent)
{
// This is not yet ready.
//if (PutWallCompat(passflag[type])) return;
}
bool masked;

View File

@ -228,16 +228,23 @@ void GLWall::RenderFogBoundary()
{
if (gl_fogmode && gl_fixedcolormap == 0)
{
int rel = rellight + getExtraLight();
gl_SetFog(lightlevel, rel, &Colormap, false);
gl_RenderState.SetEffect(EFF_FOGBOUNDARY);
gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f);
glEnable(GL_POLYGON_OFFSET_FILL);
glPolygonOffset(-1.0f, -128.0f);
RenderWall(RWF_BLANK);
glPolygonOffset(0.0f, 0.0f);
glDisable(GL_POLYGON_OFFSET_FILL);
gl_RenderState.SetEffect(EFF_NONE);
if (gl.glslversion > 0.f)
{
int rel = rellight + getExtraLight();
gl_SetFog(lightlevel, rel, &Colormap, false);
gl_RenderState.SetEffect(EFF_FOGBOUNDARY);
gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f);
glEnable(GL_POLYGON_OFFSET_FILL);
glPolygonOffset(-1.0f, -128.0f);
RenderWall(RWF_BLANK);
glPolygonOffset(0.0f, 0.0f);
glDisable(GL_POLYGON_OFFSET_FILL);
gl_RenderState.SetEffect(EFF_NONE);
}
else
{
RenderFogBoundaryCompat();
}
}
}
@ -255,12 +262,19 @@ void GLWall::RenderMirrorSurface()
Vector v(glseg.y2-glseg.y1, 0 ,-glseg.x2+glseg.x1);
v.Normalize();
// we use texture coordinates and texture matrix to pass the normal stuff to the shader so that the default vertex buffer format can be used as is.
lolft.u = lorgt.u = uplft.u = uprgt.u = v.X();
lolft.v = lorgt.v = uplft.v = uprgt.v = v.Z();
if (gl.glslversion >= 0.f)
{
// we use texture coordinates and texture matrix to pass the normal stuff to the shader so that the default vertex buffer format can be used as is.
lolft.u = lorgt.u = uplft.u = uprgt.u = v.X();
lolft.v = lorgt.v = uplft.v = uprgt.v = v.Z();
gl_RenderState.EnableTextureMatrix(true);
gl_RenderState.mTextureMatrix.computeNormalMatrix(gl_RenderState.mViewMatrix);
gl_RenderState.EnableTextureMatrix(true);
gl_RenderState.mTextureMatrix.computeNormalMatrix(gl_RenderState.mViewMatrix);
}
else
{
glNormal3fv(&v[0]);
}
// Use sphere mapping for this
gl_RenderState.SetEffect(EFF_SPHEREMAP);

View File

@ -42,6 +42,8 @@ static void* SunGetProcAddress (const GLubyte* name)
#if defined(_WIN32)
#ifdef _MSC_VER
// disable inlining here because it creates an incredible amount of bloat in this file.
#pragma inline_depth(0)
#pragma warning(disable: 4055)
#pragma warning(disable: 4054)
#pragma warning(disable: 4996)