2013-06-23 07:49:34 +00:00
|
|
|
/*
|
|
|
|
** gl_walls_draw.cpp
|
|
|
|
** Wall rendering
|
|
|
|
**
|
|
|
|
**---------------------------------------------------------------------------
|
|
|
|
** Copyright 2000-2005 Christoph Oelckers
|
|
|
|
** All rights reserved.
|
|
|
|
**
|
|
|
|
** Redistribution and use in source and binary forms, with or without
|
|
|
|
** modification, are permitted provided that the following conditions
|
|
|
|
** are met:
|
|
|
|
**
|
|
|
|
** 1. Redistributions of source code must retain the above copyright
|
|
|
|
** notice, this list of conditions and the following disclaimer.
|
|
|
|
** 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
** notice, this list of conditions and the following disclaimer in the
|
|
|
|
** documentation and/or other materials provided with the distribution.
|
|
|
|
** 3. The name of the author may not be used to endorse or promote products
|
|
|
|
** derived from this software without specific prior written permission.
|
|
|
|
** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be
|
|
|
|
** covered by the terms of the GNU Lesser General Public License as published
|
|
|
|
** by the Free Software Foundation; either version 2.1 of the License, or (at
|
|
|
|
** your option) any later version.
|
|
|
|
** 5. Full disclosure of the entire project's source code, except for third
|
|
|
|
** party libraries is mandatory. (NOTE: This clause is non-negotiable!)
|
|
|
|
**
|
|
|
|
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
**---------------------------------------------------------------------------
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "gl/system/gl_system.h"
|
|
|
|
#include "p_local.h"
|
|
|
|
#include "p_lnspec.h"
|
|
|
|
#include "a_sharedglobal.h"
|
|
|
|
#include "gl/gl_functions.h"
|
|
|
|
|
2013-09-03 16:29:39 +00:00
|
|
|
#include "gl/system/gl_interface.h"
|
2013-06-23 07:49:34 +00:00
|
|
|
#include "gl/system/gl_cvars.h"
|
|
|
|
#include "gl/renderer/gl_lightdata.h"
|
|
|
|
#include "gl/renderer/gl_renderstate.h"
|
2014-05-10 23:23:27 +00:00
|
|
|
#include "gl/renderer/gl_renderer.h"
|
2013-06-23 07:49:34 +00:00
|
|
|
#include "gl/data/gl_data.h"
|
2014-05-10 23:23:27 +00:00
|
|
|
#include "gl/data/gl_vertexbuffer.h"
|
2013-06-23 07:49:34 +00:00
|
|
|
#include "gl/dynlights/gl_dynlight.h"
|
|
|
|
#include "gl/dynlights/gl_glow.h"
|
2014-08-01 18:59:39 +00:00
|
|
|
#include "gl/dynlights/gl_lightbuffer.h"
|
2013-06-23 07:49:34 +00:00
|
|
|
#include "gl/scene/gl_drawinfo.h"
|
|
|
|
#include "gl/scene/gl_portal.h"
|
|
|
|
#include "gl/shaders/gl_shader.h"
|
|
|
|
#include "gl/textures/gl_material.h"
|
|
|
|
#include "gl/utility/gl_clock.h"
|
|
|
|
#include "gl/utility/gl_templates.h"
|
|
|
|
|
|
|
|
EXTERN_CVAR(Bool, gl_seamless)
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
2014-07-15 18:49:21 +00:00
|
|
|
// Collect lights for shader
|
2013-06-23 07:49:34 +00:00
|
|
|
//
|
|
|
|
//==========================================================================
|
2014-07-15 18:49:21 +00:00
|
|
|
FDynLightData lightdata;
|
|
|
|
|
2014-08-19 12:18:21 +00:00
|
|
|
|
2014-07-15 18:49:21 +00:00
|
|
|
void GLWall::SetupLights()
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
2014-08-19 12:18:21 +00:00
|
|
|
// check for wall types which cannot have dynamic lights on them (portal types never get here so they don't need to be checked.)
|
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case RENDERWALL_FOGBOUNDARY:
|
|
|
|
case RENDERWALL_MIRRORSURFACE:
|
|
|
|
case RENDERWALL_COLOR:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-06-23 07:49:34 +00:00
|
|
|
float vtx[]={glseg.x1,zbottom[0],glseg.y1, glseg.x1,ztop[0],glseg.y1, glseg.x2,ztop[1],glseg.y2, glseg.x2,zbottom[1],glseg.y2};
|
|
|
|
Plane p;
|
|
|
|
|
2014-07-15 18:49:21 +00:00
|
|
|
lightdata.Clear();
|
2013-06-23 07:49:34 +00:00
|
|
|
p.Init(vtx,4);
|
|
|
|
|
|
|
|
if (!p.ValidNormal())
|
|
|
|
{
|
2014-07-15 18:49:21 +00:00
|
|
|
return;
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
2014-07-15 18:49:21 +00:00
|
|
|
FLightNode *node;
|
|
|
|
if (seg->sidedef == NULL)
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
2014-07-15 18:49:21 +00:00
|
|
|
node = NULL;
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
2014-07-15 18:49:21 +00:00
|
|
|
else if (!(seg->sidedef->Flags & WALLF_POLYOBJ))
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
2014-07-15 18:49:21 +00:00
|
|
|
node = seg->sidedef->lighthead;
|
|
|
|
}
|
|
|
|
else if (sub)
|
|
|
|
{
|
|
|
|
// Polobject segs cannot be checked per sidedef so use the subsector instead.
|
|
|
|
node = sub->lighthead;
|
|
|
|
}
|
|
|
|
else node = NULL;
|
2013-06-23 07:49:34 +00:00
|
|
|
|
2014-07-15 18:49:21 +00:00
|
|
|
// Iterate through all dynamic lights which touch this wall and render them
|
|
|
|
while (node)
|
|
|
|
{
|
|
|
|
if (!(node->lightsource->flags2&MF2_DORMANT))
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
2014-07-15 18:49:21 +00:00
|
|
|
iter_dlight++;
|
2013-06-23 07:49:34 +00:00
|
|
|
|
2014-07-15 18:49:21 +00:00
|
|
|
Vector fn, pos;
|
2013-06-23 07:49:34 +00:00
|
|
|
|
2016-01-21 11:36:37 +00:00
|
|
|
float x = FIXED2FLOAT(node->lightsource->X());
|
|
|
|
float y = FIXED2FLOAT(node->lightsource->Y());
|
|
|
|
float z = FIXED2FLOAT(node->lightsource->Z());
|
2014-07-15 18:49:21 +00:00
|
|
|
float dist = fabsf(p.DistToPoint(x, z, y));
|
|
|
|
float radius = (node->lightsource->GetRadius() * gl_lights_size);
|
|
|
|
float scale = 1.0f / ((2.f * radius) - dist);
|
2013-06-23 07:49:34 +00:00
|
|
|
|
2014-07-15 18:49:21 +00:00
|
|
|
if (radius > 0.f && dist < radius)
|
|
|
|
{
|
|
|
|
Vector nearPt, up, right;
|
2013-06-23 07:49:34 +00:00
|
|
|
|
2014-07-15 18:49:21 +00:00
|
|
|
pos.Set(x,z,y);
|
|
|
|
fn=p.Normal();
|
|
|
|
fn.GetRightUp(right, up);
|
2013-06-23 07:49:34 +00:00
|
|
|
|
2014-07-15 18:49:21 +00:00
|
|
|
Vector tmpVec = fn * dist;
|
|
|
|
nearPt = pos + tmpVec;
|
2013-06-23 07:49:34 +00:00
|
|
|
|
2014-07-15 18:49:21 +00:00
|
|
|
Vector t1;
|
|
|
|
int outcnt[4]={0,0,0,0};
|
|
|
|
texcoord tcs[4];
|
2013-06-23 07:49:34 +00:00
|
|
|
|
2014-07-15 18:49:21 +00:00
|
|
|
// do a quick check whether the light touches this polygon
|
|
|
|
for(int i=0;i<4;i++)
|
|
|
|
{
|
|
|
|
t1.Set(&vtx[i*3]);
|
|
|
|
Vector nearToVert = t1 - nearPt;
|
|
|
|
tcs[i].u = (nearToVert.Dot(right) * scale) + 0.5f;
|
|
|
|
tcs[i].v = (nearToVert.Dot(up) * scale) + 0.5f;
|
2013-06-23 07:49:34 +00:00
|
|
|
|
2014-07-15 18:49:21 +00:00
|
|
|
if (tcs[i].u<0) outcnt[0]++;
|
|
|
|
if (tcs[i].u>1) outcnt[1]++;
|
|
|
|
if (tcs[i].v<0) outcnt[2]++;
|
|
|
|
if (tcs[i].v>1) outcnt[3]++;
|
2013-06-23 07:49:34 +00:00
|
|
|
|
2014-07-15 18:49:21 +00:00
|
|
|
}
|
|
|
|
if (outcnt[0]!=4 && outcnt[1]!=4 && outcnt[2]!=4 && outcnt[3]!=4)
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
2014-07-15 18:49:21 +00:00
|
|
|
gl_GetLight(p, node->lightsource, true, false, lightdata);
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-07-15 18:49:21 +00:00
|
|
|
node = node->nextLight;
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
|
2014-08-01 18:59:39 +00:00
|
|
|
dynlightindex = GLRenderer->mLights->UploadLights(lightdata);
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
|
2014-06-14 23:14:41 +00:00
|
|
|
|
2013-06-23 07:49:34 +00:00
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// General purpose wall rendering function
|
|
|
|
// everything goes through here
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
2014-07-15 18:49:21 +00:00
|
|
|
void GLWall::RenderWall(int textured, unsigned int *store)
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
2014-07-13 15:15:17 +00:00
|
|
|
static texcoord tcs[4]; // making this variable static saves us a relatively costly stack integrity check.
|
2014-08-04 21:00:40 +00:00
|
|
|
bool split = (gl_seamless && !(textured&RWF_NOSPLIT) && seg->sidedef != NULL && !(seg->sidedef->Flags & WALLF_POLYOBJ) && !(flags & GLWF_NOSPLIT));
|
2013-06-23 07:49:34 +00:00
|
|
|
|
2014-07-15 18:49:21 +00:00
|
|
|
tcs[0]=lolft;
|
|
|
|
tcs[1]=uplft;
|
|
|
|
tcs[2]=uprgt;
|
|
|
|
tcs[3]=lorgt;
|
2013-06-23 07:49:34 +00:00
|
|
|
|
2014-06-15 08:15:44 +00:00
|
|
|
if (!(textured & RWF_NORENDER))
|
|
|
|
{
|
|
|
|
gl_RenderState.Apply();
|
2014-08-01 18:59:39 +00:00
|
|
|
gl_RenderState.ApplyLightIndex(dynlightindex);
|
2014-06-15 08:15:44 +00:00
|
|
|
}
|
2013-06-23 07:49:34 +00:00
|
|
|
|
|
|
|
// the rest of the code is identical for textured rendering and lights
|
2014-06-14 23:14:41 +00:00
|
|
|
FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer();
|
2014-06-15 08:15:44 +00:00
|
|
|
unsigned int count, offset;
|
2013-06-23 07:49:34 +00:00
|
|
|
|
2014-06-14 23:14:41 +00:00
|
|
|
ptr->Set(glseg.x1, zbottom[0], glseg.y1, tcs[0].u, tcs[0].v);
|
|
|
|
ptr++;
|
|
|
|
if (split && glseg.fracleft == 0) SplitLeftEdge(tcs, ptr);
|
|
|
|
ptr->Set(glseg.x1, ztop[0], glseg.y1, tcs[1].u, tcs[1].v);
|
|
|
|
ptr++;
|
|
|
|
if (split && !(flags & GLWF_NOSPLITUPPER)) SplitUpperEdge(tcs, ptr);
|
|
|
|
ptr->Set(glseg.x2, ztop[1], glseg.y2, tcs[2].u, tcs[2].v);
|
|
|
|
ptr++;
|
|
|
|
if (split && glseg.fracright == 1) SplitRightEdge(tcs, ptr);
|
|
|
|
ptr->Set(glseg.x2, zbottom[1], glseg.y2, tcs[3].u, tcs[3].v);
|
|
|
|
ptr++;
|
|
|
|
if (split && !(flags & GLWF_NOSPLITLOWER)) SplitLowerEdge(tcs, ptr);
|
2014-06-15 08:15:44 +00:00
|
|
|
count = GLRenderer->mVBO->GetCount(ptr, &offset);
|
|
|
|
if (!(textured & RWF_NORENDER))
|
|
|
|
{
|
|
|
|
GLRenderer->mVBO->RenderArray(GL_TRIANGLE_FAN, offset, count);
|
|
|
|
vertexcount += count;
|
|
|
|
}
|
|
|
|
if (store != NULL)
|
|
|
|
{
|
|
|
|
store[0] = offset;
|
|
|
|
store[1] = count;
|
|
|
|
}
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
void GLWall::RenderFogBoundary()
|
|
|
|
{
|
|
|
|
if (gl_fogmode && gl_fixedcolormap == 0)
|
|
|
|
{
|
2014-06-21 13:50:32 +00:00
|
|
|
int rel = rellight + getExtraLight();
|
|
|
|
gl_SetFog(lightlevel, rel, &Colormap, false);
|
|
|
|
gl_RenderState.SetEffect(EFF_FOGBOUNDARY);
|
2014-07-14 19:14:43 +00:00
|
|
|
gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f);
|
2014-09-20 07:04:36 +00:00
|
|
|
glEnable(GL_POLYGON_OFFSET_FILL);
|
|
|
|
glPolygonOffset(-1.0f, -128.0f);
|
2014-06-21 13:50:32 +00:00
|
|
|
RenderWall(RWF_BLANK);
|
2014-09-20 07:04:36 +00:00
|
|
|
glPolygonOffset(0.0f, 0.0f);
|
|
|
|
glDisable(GL_POLYGON_OFFSET_FILL);
|
2014-06-21 13:50:32 +00:00
|
|
|
gl_RenderState.SetEffect(EFF_NONE);
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
void GLWall::RenderMirrorSurface()
|
|
|
|
{
|
|
|
|
if (GLRenderer->mirrortexture == NULL) return;
|
|
|
|
|
|
|
|
// For the sphere map effect we need a normal of the mirror surface,
|
|
|
|
Vector v(glseg.y2-glseg.y1, 0 ,-glseg.x2+glseg.x1);
|
|
|
|
v.Normalize();
|
2014-07-14 17:54:07 +00:00
|
|
|
|
|
|
|
// 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);
|
2013-06-23 07:49:34 +00:00
|
|
|
|
|
|
|
// Use sphere mapping for this
|
|
|
|
gl_RenderState.SetEffect(EFF_SPHEREMAP);
|
|
|
|
|
2014-05-11 22:13:19 +00:00
|
|
|
gl_SetColor(lightlevel, 0, Colormap ,0.1f);
|
2014-05-11 20:57:42 +00:00
|
|
|
gl_SetFog(lightlevel, 0, &Colormap, true);
|
2013-06-23 07:49:34 +00:00
|
|
|
gl_RenderState.BlendFunc(GL_SRC_ALPHA,GL_ONE);
|
|
|
|
gl_RenderState.AlphaFunc(GL_GREATER,0);
|
2013-09-03 12:05:41 +00:00
|
|
|
glDepthFunc(GL_LEQUAL);
|
2013-06-23 07:49:34 +00:00
|
|
|
|
2014-08-22 21:50:38 +00:00
|
|
|
FMaterial * pat=FMaterial::ValidateTexture(GLRenderer->mirrortexture, false);
|
2014-09-09 10:00:42 +00:00
|
|
|
gl_RenderState.SetMaterial(pat, CLAMP_NONE, 0, -1, false);
|
2013-06-23 07:49:34 +00:00
|
|
|
|
|
|
|
flags &= ~GLWF_GLOW;
|
2014-06-15 08:15:44 +00:00
|
|
|
RenderWall(RWF_BLANK);
|
2013-06-23 07:49:34 +00:00
|
|
|
|
2014-07-14 17:54:07 +00:00
|
|
|
gl_RenderState.EnableTextureMatrix(false);
|
2013-06-23 07:49:34 +00:00
|
|
|
gl_RenderState.SetEffect(EFF_NONE);
|
|
|
|
|
|
|
|
// Restore the defaults for the translucent pass
|
|
|
|
gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
2014-07-14 19:14:43 +00:00
|
|
|
gl_RenderState.AlphaFunc(GL_GEQUAL, gl_mask_sprite_threshold);
|
2013-09-03 12:05:41 +00:00
|
|
|
glDepthFunc(GL_LESS);
|
2013-06-23 07:49:34 +00:00
|
|
|
|
|
|
|
// This is drawn in the translucent pass which is done after the decal pass
|
|
|
|
// As a result the decals have to be drawn here.
|
|
|
|
if (seg->sidedef->AttachedDecals)
|
|
|
|
{
|
2013-09-03 12:05:41 +00:00
|
|
|
glEnable(GL_POLYGON_OFFSET_FILL);
|
|
|
|
glPolygonOffset(-1.0f, -128.0f);
|
|
|
|
glDepthMask(false);
|
2013-06-23 07:49:34 +00:00
|
|
|
DoDrawDecals();
|
2013-09-03 12:05:41 +00:00
|
|
|
glDepthMask(true);
|
|
|
|
glPolygonOffset(0.0f, 0.0f);
|
|
|
|
glDisable(GL_POLYGON_OFFSET_FILL);
|
2013-06-23 07:49:34 +00:00
|
|
|
gl_RenderState.SetTextureMode(TM_MODULATE);
|
|
|
|
gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
2016-01-31 20:10:59 +00:00
|
|
|
void GLWall::RenderTextured(int rflags)
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
2016-01-31 20:10:59 +00:00
|
|
|
int tmode = gl_RenderState.GetTextureMode();
|
2016-02-19 16:40:08 +00:00
|
|
|
int rel = rellight + getExtraLight();
|
2013-06-23 07:49:34 +00:00
|
|
|
|
2016-01-31 20:10:59 +00:00
|
|
|
if (flags & GLWF_GLOW)
|
2015-12-11 21:26:10 +00:00
|
|
|
{
|
2016-01-31 20:10:59 +00:00
|
|
|
gl_RenderState.EnableGlow(true);
|
|
|
|
gl_RenderState.SetGlowPlanes(topplane, bottomplane);
|
|
|
|
gl_RenderState.SetGlowParams(topglowcolor, bottomglowcolor);
|
2015-12-11 21:26:10 +00:00
|
|
|
}
|
2016-01-31 20:10:59 +00:00
|
|
|
gl_RenderState.SetMaterial(gltexture, flags & 3, 0, -1, false);
|
2015-12-11 21:26:10 +00:00
|
|
|
|
2016-01-31 20:10:59 +00:00
|
|
|
if (type == RENDERWALL_M2SNF)
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
2016-01-31 20:10:59 +00:00
|
|
|
if (flags & GLT_CLAMPY)
|
|
|
|
{
|
|
|
|
if (tmode == TM_MODULATE) gl_RenderState.SetTextureMode(TM_CLAMPY);
|
|
|
|
}
|
|
|
|
gl_SetFog(255, 0, NULL, false);
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
2016-01-31 20:10:59 +00:00
|
|
|
|
|
|
|
float absalpha = fabsf(alpha);
|
2016-02-01 00:03:34 +00:00
|
|
|
if (lightlist == NULL)
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
2016-01-31 20:10:59 +00:00
|
|
|
gl_SetColor(lightlevel, rel, Colormap, absalpha);
|
|
|
|
if (type != RENDERWALL_M2SNF) gl_SetFog(lightlevel, rel, &Colormap, RenderStyle == STYLE_Add);
|
|
|
|
RenderWall(rflags);
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
2014-09-21 09:08:17 +00:00
|
|
|
else
|
|
|
|
{
|
2016-01-31 20:10:59 +00:00
|
|
|
gl_RenderState.EnableSplit(true);
|
2016-01-31 21:04:20 +00:00
|
|
|
glEnable(GL_CLIP_DISTANCE3);
|
|
|
|
glEnable(GL_CLIP_DISTANCE4);
|
2016-02-01 00:03:34 +00:00
|
|
|
|
|
|
|
for (unsigned i = 0; i < lightlist->Size(); i++)
|
2014-09-21 09:08:17 +00:00
|
|
|
{
|
2016-02-01 15:13:07 +00:00
|
|
|
secplane_t &lowplane = i == (*lightlist).Size() - 1 ? bottomplane : (*lightlist)[i + 1].plane;
|
|
|
|
// this must use the exact same calculation method as GLWall::Process etc.
|
|
|
|
float low1 = FIXED2FLOAT(lowplane.ZatPoint(vertexes[0]));
|
|
|
|
float low2 = FIXED2FLOAT(lowplane.ZatPoint(vertexes[1]));
|
|
|
|
|
2016-02-04 00:12:18 +00:00
|
|
|
if (low1 < ztop[0] || low2 < ztop[1])
|
2016-02-01 15:13:07 +00:00
|
|
|
{
|
|
|
|
int thisll = (*lightlist)[i].caster != NULL ? gl_ClampLight(*(*lightlist)[i].p_lightlevel) : lightlevel;
|
|
|
|
FColormap thiscm;
|
|
|
|
thiscm.FadeColor = Colormap.FadeColor;
|
|
|
|
thiscm.CopyFrom3DLight(&(*lightlist)[i]);
|
|
|
|
gl_SetColor(thisll, rel, thiscm, absalpha);
|
|
|
|
if (type != RENDERWALL_M2SNF) gl_SetFog(thisll, rel, &thiscm, RenderStyle == STYLE_Add);
|
|
|
|
gl_RenderState.SetSplitPlanes((*lightlist)[i].plane, lowplane);
|
|
|
|
RenderWall(rflags);
|
|
|
|
}
|
|
|
|
if (low1 <= zbottom[0] && low2 <= zbottom[1]) break;
|
2014-09-21 09:08:17 +00:00
|
|
|
}
|
2016-02-01 00:03:34 +00:00
|
|
|
|
2016-01-31 21:04:20 +00:00
|
|
|
glDisable(GL_CLIP_DISTANCE3);
|
|
|
|
glDisable(GL_CLIP_DISTANCE4);
|
2016-01-31 20:10:59 +00:00
|
|
|
gl_RenderState.EnableSplit(false);
|
2014-09-21 09:08:17 +00:00
|
|
|
}
|
2016-01-31 20:10:59 +00:00
|
|
|
gl_RenderState.SetTextureMode(tmode);
|
|
|
|
gl_RenderState.EnableGlow(false);
|
|
|
|
}
|
2013-06-23 07:49:34 +00:00
|
|
|
|
2016-01-31 20:10:59 +00:00
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//==========================================================================
|
2013-06-23 07:49:34 +00:00
|
|
|
|
2016-01-31 20:10:59 +00:00
|
|
|
void GLWall::RenderTranslucentWall()
|
|
|
|
{
|
|
|
|
if (gltexture)
|
|
|
|
{
|
2016-01-31 21:24:48 +00:00
|
|
|
if (gl_fixedcolormap == CM_DEFAULT && gl_lights && (gl.flags & RFL_BUFFER_STORAGE))
|
|
|
|
{
|
|
|
|
SetupLights();
|
|
|
|
}
|
2016-01-31 20:10:59 +00:00
|
|
|
if (!gltexture->GetTransparent()) gl_RenderState.AlphaFunc(GL_GEQUAL, gl_mask_threshold);
|
|
|
|
else gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f);
|
|
|
|
if (RenderStyle == STYLE_Add) gl_RenderState.BlendFunc(GL_SRC_ALPHA,GL_ONE);
|
|
|
|
RenderTextured(RWF_TEXTURED | RWF_NOSPLIT);
|
|
|
|
if (RenderStyle == STYLE_Add) gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
|
|
|
}
|
|
|
|
else
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
2016-01-31 20:10:59 +00:00
|
|
|
gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f);
|
|
|
|
gl_SetColor(lightlevel, 0, Colormap, fabsf(alpha));
|
|
|
|
gl_SetFog(lightlevel, 0, &Colormap, RenderStyle == STYLE_Add);
|
2016-01-31 21:24:48 +00:00
|
|
|
gl_RenderState.EnableTexture(false);
|
2016-01-31 20:10:59 +00:00
|
|
|
RenderWall(RWF_NOSPLIT);
|
2013-06-23 07:49:34 +00:00
|
|
|
gl_RenderState.EnableTexture(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
void GLWall::Draw(int pass)
|
|
|
|
{
|
|
|
|
switch (pass)
|
|
|
|
{
|
2014-08-19 12:18:21 +00:00
|
|
|
case GLPASS_LIGHTSONLY:
|
|
|
|
SetupLights();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GLPASS_ALL:
|
2013-06-23 07:49:34 +00:00
|
|
|
SetupLights();
|
|
|
|
// fall through
|
2014-08-19 12:18:21 +00:00
|
|
|
case GLPASS_PLAIN:
|
2016-01-31 20:10:59 +00:00
|
|
|
RenderTextured(RWF_TEXTURED);
|
2013-06-23 07:49:34 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GLPASS_TRANSLUCENT:
|
2014-09-20 07:04:36 +00:00
|
|
|
|
2013-06-23 07:49:34 +00:00
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case RENDERWALL_MIRRORSURFACE:
|
|
|
|
RenderMirrorSurface();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RENDERWALL_FOGBOUNDARY:
|
|
|
|
RenderFogBoundary();
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
RenderTranslucentWall();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|