2016-09-14 18:01:13 +00:00
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Copyright(C) 2000-2016 Christoph Oelckers
|
|
|
|
// All rights reserved.
|
|
|
|
//
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU Lesser General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public License
|
|
|
|
// along with this program. If not, see http://www.gnu.org/licenses/
|
|
|
|
//
|
|
|
|
//--------------------------------------------------------------------------
|
|
|
|
//
|
2013-06-23 07:49:34 +00:00
|
|
|
|
|
|
|
#include "gl/system/gl_system.h"
|
|
|
|
#include "p_local.h"
|
|
|
|
#include "p_lnspec.h"
|
|
|
|
#include "a_sharedglobal.h"
|
2017-01-28 19:44:46 +00:00
|
|
|
#include "g_levellocals.h"
|
2017-03-10 01:22:42 +00:00
|
|
|
#include "actorinlines.h"
|
2018-04-16 07:02:48 +00:00
|
|
|
#include "hwrenderer/dynlights/hw_dynlightdata.h"
|
2013-06-23 07:49:34 +00:00
|
|
|
|
2013-09-03 16:29:39 +00:00
|
|
|
#include "gl/system/gl_interface.h"
|
2018-04-25 18:33:55 +00:00
|
|
|
#include "hwrenderer/utility/hw_cvars.h"
|
2013-06-23 07:49:34 +00:00
|
|
|
#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"
|
|
|
|
#include "gl/data/gl_vertexbuffer.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"
|
2017-03-12 20:57:39 +00:00
|
|
|
#include "gl/scene/gl_scenedrawer.h"
|
2016-08-25 21:20:23 +00:00
|
|
|
#include "gl/renderer/gl_quaddrawer.h"
|
2013-06-23 07:49:34 +00:00
|
|
|
|
|
|
|
EXTERN_CVAR(Bool, gl_seamless)
|
|
|
|
|
2018-04-26 05:07:46 +00:00
|
|
|
FDynLightData lightdata;
|
|
|
|
|
2013-06-23 07:49:34 +00:00
|
|
|
//==========================================================================
|
|
|
|
//
|
2014-07-15 18:49:21 +00:00
|
|
|
// Collect lights for shader
|
2013-06-23 07:49:34 +00:00
|
|
|
//
|
|
|
|
//==========================================================================
|
2014-08-19 12:18:21 +00:00
|
|
|
|
2018-04-26 05:07:46 +00:00
|
|
|
bool GLWall::SetupLights(FDynLightData &lightdata)
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
2018-04-26 05:07:46 +00:00
|
|
|
if (RenderStyle == STYLE_Add && !level.lightadditivesurfaces) return false; // no lights on additively blended surfaces.
|
2016-05-18 20:20:18 +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:
|
2018-04-26 05:07:46 +00:00
|
|
|
return false;
|
2014-08-19 12:18:21 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2018-04-01 10:43:23 +00:00
|
|
|
auto normal = glseg.Normal();
|
2018-04-15 21:51:41 +00:00
|
|
|
p.Set(normal, -normal.X * glseg.x1 - normal.Z * glseg.y1);
|
2018-04-01 10:43:23 +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
|
|
|
|
2016-12-08 11:49:40 +00:00
|
|
|
DVector3 posrel = node->lightsource->PosRelative(seg->frontsector);
|
|
|
|
float x = posrel.X;
|
|
|
|
float y = posrel.Y;
|
|
|
|
float z = posrel.Z;
|
2014-07-15 18:49:21 +00:00
|
|
|
float dist = fabsf(p.DistToPoint(x, z, y));
|
2016-09-04 10:45:09 +00:00
|
|
|
float radius = node->lightsource->GetRadius();
|
2014-07-15 18:49:21 +00:00
|
|
|
float scale = 1.0f / ((2.f * radius) - dist);
|
2017-03-12 18:44:00 +00:00
|
|
|
FVector3 fn, pos;
|
2013-06-23 07:49:34 +00:00
|
|
|
|
2014-07-15 18:49:21 +00:00
|
|
|
if (radius > 0.f && dist < radius)
|
|
|
|
{
|
2017-03-12 18:44:00 +00:00
|
|
|
FVector3 nearPt, up, right;
|
|
|
|
|
|
|
|
pos = { x, z, y };
|
|
|
|
fn = p.Normal();
|
2013-06-23 07:49:34 +00:00
|
|
|
|
2014-07-15 18:49:21 +00:00
|
|
|
fn.GetRightUp(right, up);
|
2013-06-23 07:49:34 +00:00
|
|
|
|
2017-03-12 18:44:00 +00:00
|
|
|
FVector3 tmpVec = fn * dist;
|
2014-07-15 18:49:21 +00:00
|
|
|
nearPt = pos + tmpVec;
|
2013-06-23 07:49:34 +00:00
|
|
|
|
2017-03-12 18:44:00 +00:00
|
|
|
FVector3 t1;
|
2014-07-15 18:49:21 +00:00
|
|
|
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++)
|
|
|
|
{
|
2017-03-12 18:44:00 +00:00
|
|
|
t1 = FVector3(&vtx[i*3]);
|
|
|
|
FVector3 nearToVert = t1 - nearPt;
|
|
|
|
tcs[i].u = ((nearToVert | right) * scale) + 0.5f;
|
|
|
|
tcs[i].v = ((nearToVert | 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
|
|
|
{
|
2018-04-16 06:55:13 +00:00
|
|
|
lightdata.GetLight(seg->frontsector->PortalGroup, p, node->lightsource, true);
|
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
|
|
|
}
|
2018-04-26 05:07:46 +00:00
|
|
|
return true;
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// General purpose wall rendering function
|
|
|
|
// everything goes through here
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
2018-04-26 22:22:00 +00:00
|
|
|
void FDrawInfo::RenderWall(GLWall *wall, int textured)
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
2018-04-26 17:25:11 +00:00
|
|
|
assert(vertcount > 0);
|
2016-08-25 21:02:43 +00:00
|
|
|
gl_RenderState.Apply();
|
2018-04-26 22:22:00 +00:00
|
|
|
gl_RenderState.ApplyLightIndex(wall->dynlightindex);
|
|
|
|
GLRenderer->mVBO->RenderArray(GL_TRIANGLE_FAN, wall->vertindex, wall->vertcount);
|
|
|
|
vertexcount += wall->vertcount;
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
2018-04-26 22:22:00 +00:00
|
|
|
void FDrawInfo::RenderFogBoundary(GLWall *wall)
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
2017-03-12 20:57:39 +00:00
|
|
|
if (gl_fogmode && mDrawer->FixedColormap == 0)
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
2016-09-01 09:52:52 +00:00
|
|
|
if (!gl.legacyMode)
|
2016-05-03 21:28:42 +00:00
|
|
|
{
|
2018-04-26 22:22:00 +00:00
|
|
|
int rel = wall->rellight + getExtraLight();
|
|
|
|
mDrawer->SetFog(wall->lightlevel, rel, &wall->Colormap, false);
|
2016-10-21 22:09:06 +00:00
|
|
|
gl_RenderState.EnableDrawBuffers(1);
|
2016-05-03 21:28:42 +00:00
|
|
|
gl_RenderState.SetEffect(EFF_FOGBOUNDARY);
|
|
|
|
gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f);
|
|
|
|
glEnable(GL_POLYGON_OFFSET_FILL);
|
|
|
|
glPolygonOffset(-1.0f, -128.0f);
|
2018-04-26 22:22:00 +00:00
|
|
|
RenderWall(wall, GLWall::RWF_BLANK);
|
2016-05-03 21:28:42 +00:00
|
|
|
glPolygonOffset(0.0f, 0.0f);
|
|
|
|
glDisable(GL_POLYGON_OFFSET_FILL);
|
|
|
|
gl_RenderState.SetEffect(EFF_NONE);
|
2016-10-21 22:09:06 +00:00
|
|
|
gl_RenderState.EnableDrawBuffers(gl_RenderState.GetPassDrawBufferCount());
|
2016-05-03 21:28:42 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-04-26 22:22:00 +00:00
|
|
|
RenderFogBoundaryCompat(wall);
|
2016-05-03 21:28:42 +00:00
|
|
|
}
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//==========================================================================
|
2018-04-26 22:22:00 +00:00
|
|
|
void FDrawInfo::RenderMirrorSurface(GLWall *wall)
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
2018-02-15 16:56:04 +00:00
|
|
|
if (!GLRenderer->mirrorTexture.isValid()) return;
|
2013-06-23 07:49:34 +00:00
|
|
|
|
2016-09-01 09:52:52 +00:00
|
|
|
if (!gl.legacyMode)
|
2016-05-03 21:28:42 +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.
|
|
|
|
gl_RenderState.EnableTextureMatrix(true);
|
|
|
|
gl_RenderState.mTextureMatrix.computeNormalMatrix(gl_RenderState.mViewMatrix);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-04-26 22:22:00 +00:00
|
|
|
FVector3 v = wall->glseg.Normal();
|
2016-05-03 21:28:42 +00:00
|
|
|
glNormal3fv(&v[0]);
|
|
|
|
}
|
2013-06-23 07:49:34 +00:00
|
|
|
|
|
|
|
// Use sphere mapping for this
|
|
|
|
gl_RenderState.SetEffect(EFF_SPHEREMAP);
|
|
|
|
|
2018-04-26 22:22:00 +00:00
|
|
|
mDrawer->SetColor(wall->lightlevel, 0, wall->Colormap ,0.1f);
|
|
|
|
mDrawer->SetFog(wall->lightlevel, 0, &wall->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
|
|
|
|
2018-02-15 16:56:04 +00:00
|
|
|
FMaterial * pat=FMaterial::ValidateTexture(GLRenderer->mirrorTexture, false, 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
|
|
|
|
2018-04-26 22:22:00 +00:00
|
|
|
wall->flags &= ~GLWall::GLWF_GLOW;
|
|
|
|
RenderWall(wall, GLWall::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.
|
2018-04-26 22:22:00 +00:00
|
|
|
if (wall->seg->sidedef->AttachedDecals)
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
2013-09-03 12:05:41 +00:00
|
|
|
glEnable(GL_POLYGON_OFFSET_FILL);
|
|
|
|
glPolygonOffset(-1.0f, -128.0f);
|
|
|
|
glDepthMask(false);
|
2018-04-26 22:22:00 +00:00
|
|
|
gl_drawinfo->DoDrawDecals(wall);
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
2018-04-26 22:22:00 +00:00
|
|
|
void FDrawInfo::RenderTexturedWall(GLWall *wall, int rflags)
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
2016-01-31 20:10:59 +00:00
|
|
|
int tmode = gl_RenderState.GetTextureMode();
|
2018-04-26 22:22:00 +00:00
|
|
|
int rel = wall->rellight + getExtraLight();
|
2013-06-23 07:49:34 +00:00
|
|
|
|
2018-04-26 22:22:00 +00:00
|
|
|
if (wall->flags & GLWall::GLWF_GLOW)
|
2015-12-11 21:26:10 +00:00
|
|
|
{
|
2016-01-31 20:10:59 +00:00
|
|
|
gl_RenderState.EnableGlow(true);
|
2018-04-26 22:22:00 +00:00
|
|
|
gl_RenderState.SetGlowParams(wall->topglowcolor, wall->bottomglowcolor);
|
2015-12-11 21:26:10 +00:00
|
|
|
}
|
2018-04-26 22:22:00 +00:00
|
|
|
gl_RenderState.SetGlowPlanes(wall->topplane, wall->bottomplane);
|
|
|
|
gl_RenderState.SetMaterial(wall->gltexture, wall->flags & 3, 0, -1, false);
|
2015-12-11 21:26:10 +00:00
|
|
|
|
2018-04-26 22:22:00 +00:00
|
|
|
if (wall->type == RENDERWALL_M2SNF)
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
2018-04-26 22:22:00 +00:00
|
|
|
if (wall->flags & GLWall::GLWF_CLAMPY)
|
2016-01-31 20:10:59 +00:00
|
|
|
{
|
|
|
|
if (tmode == TM_MODULATE) gl_RenderState.SetTextureMode(TM_CLAMPY);
|
|
|
|
}
|
2018-04-26 22:22:00 +00:00
|
|
|
mDrawer->SetFog(255, 0, nullptr, false);
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
2018-04-26 22:22:00 +00:00
|
|
|
gl_RenderState.SetObjectColor(wall->seg->frontsector->SpecialColors[sector_t::walltop] | 0xff000000);
|
|
|
|
gl_RenderState.SetObjectColor2(wall->seg->frontsector->SpecialColors[sector_t::wallbottom] | 0xff000000);
|
2016-01-31 20:10:59 +00:00
|
|
|
|
2018-04-26 22:22:00 +00:00
|
|
|
float absalpha = fabsf(wall->alpha);
|
|
|
|
if (wall->lightlist == nullptr)
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
2018-04-26 22:22:00 +00:00
|
|
|
if (wall->type != RENDERWALL_M2SNF) mDrawer->SetFog(wall->lightlevel, rel, &wall->Colormap, wall->RenderStyle == STYLE_Add);
|
|
|
|
mDrawer->SetColor(wall->lightlevel, rel, wall->Colormap, absalpha);
|
|
|
|
RenderWall(wall, 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-02-01 00:03:34 +00:00
|
|
|
|
2018-04-26 22:22:00 +00:00
|
|
|
for (unsigned i = 0; i < wall->lightlist->Size(); i++)
|
2014-09-21 09:08:17 +00:00
|
|
|
{
|
2018-04-26 22:22:00 +00:00
|
|
|
secplane_t &lowplane = i == (*wall->lightlist).Size() - 1 ? wall->bottomplane : (*wall->lightlist)[i + 1].plane;
|
2016-02-01 15:13:07 +00:00
|
|
|
// this must use the exact same calculation method as GLWall::Process etc.
|
2018-04-26 22:22:00 +00:00
|
|
|
float low1 = lowplane.ZatPoint(wall->vertexes[0]);
|
|
|
|
float low2 = lowplane.ZatPoint(wall->vertexes[1]);
|
2016-02-01 15:13:07 +00:00
|
|
|
|
2018-04-26 22:22:00 +00:00
|
|
|
if (low1 < wall->ztop[0] || low2 < wall->ztop[1])
|
2016-02-01 15:13:07 +00:00
|
|
|
{
|
2018-04-26 22:22:00 +00:00
|
|
|
int thisll = (*wall->lightlist)[i].caster != NULL ? hw_ClampLight(*(*wall->lightlist)[i].p_lightlevel) : wall->lightlevel;
|
2016-02-01 15:13:07 +00:00
|
|
|
FColormap thiscm;
|
2018-04-26 22:22:00 +00:00
|
|
|
thiscm.FadeColor = wall->Colormap.FadeColor;
|
|
|
|
thiscm.FogDensity = wall->Colormap.FogDensity;
|
|
|
|
thiscm.CopyFrom3DLight(&(*wall->lightlist)[i]);
|
2017-03-12 20:57:39 +00:00
|
|
|
mDrawer->SetColor(thisll, rel, thiscm, absalpha);
|
2018-04-26 22:22:00 +00:00
|
|
|
if (wall->type != RENDERWALL_M2SNF) mDrawer->SetFog(thisll, rel, &thiscm, wall->RenderStyle == STYLE_Add);
|
|
|
|
gl_RenderState.SetSplitPlanes((*wall->lightlist)[i].plane, lowplane);
|
|
|
|
RenderWall(wall, rflags);
|
2016-02-01 15:13:07 +00:00
|
|
|
}
|
2018-04-26 22:22:00 +00:00
|
|
|
if (low1 <= wall->zbottom[0] && low2 <= wall->zbottom[1]) break;
|
2014-09-21 09:08:17 +00:00
|
|
|
}
|
2016-02-01 00:03:34 +00:00
|
|
|
|
2016-01-31 20:10:59 +00:00
|
|
|
gl_RenderState.EnableSplit(false);
|
2014-09-21 09:08:17 +00:00
|
|
|
}
|
2017-01-28 19:44:46 +00:00
|
|
|
gl_RenderState.SetObjectColor(0xffffffff);
|
|
|
|
gl_RenderState.SetObjectColor2(0);
|
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
|
|
|
|
2018-04-26 22:22:00 +00:00
|
|
|
void FDrawInfo::RenderTranslucentWall(GLWall *wall)
|
2016-01-31 20:10:59 +00:00
|
|
|
{
|
2018-04-26 22:22:00 +00:00
|
|
|
if (wall->gltexture)
|
2016-01-31 20:10:59 +00:00
|
|
|
{
|
2017-03-12 20:57:39 +00:00
|
|
|
if (mDrawer->FixedColormap == CM_DEFAULT && gl_lights && gl.lightmethod == LM_DIRECT)
|
2016-01-31 21:24:48 +00:00
|
|
|
{
|
2018-04-26 22:22:00 +00:00
|
|
|
if (wall->SetupLights(lightdata))
|
|
|
|
wall->dynlightindex = GLRenderer->mLights->UploadLights(lightdata);
|
2016-01-31 21:24:48 +00:00
|
|
|
}
|
2018-04-26 22:22:00 +00:00
|
|
|
if (!wall->gltexture->tex->GetTranslucency()) gl_RenderState.AlphaFunc(GL_GEQUAL, gl_mask_threshold);
|
2016-01-31 20:10:59 +00:00
|
|
|
else gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f);
|
2018-04-26 22:22:00 +00:00
|
|
|
if (wall->RenderStyle == STYLE_Add) gl_RenderState.BlendFunc(GL_SRC_ALPHA,GL_ONE);
|
|
|
|
RenderTexturedWall(wall, GLWall::RWF_TEXTURED | GLWall::RWF_NOSPLIT);
|
|
|
|
if (wall->RenderStyle == STYLE_Add) gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
2016-01-31 20:10:59 +00:00
|
|
|
}
|
|
|
|
else
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
2016-01-31 20:10:59 +00:00
|
|
|
gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f);
|
2018-04-26 22:22:00 +00:00
|
|
|
mDrawer->SetColor(wall->lightlevel, 0, wall->Colormap, fabsf(wall->alpha));
|
|
|
|
mDrawer->SetFog(wall->lightlevel, 0, &wall->Colormap, wall->RenderStyle == STYLE_Add);
|
2016-01-31 21:24:48 +00:00
|
|
|
gl_RenderState.EnableTexture(false);
|
2018-04-26 22:22:00 +00:00
|
|
|
RenderWall(wall, GLWall::RWF_NOSPLIT);
|
2013-06-23 07:49:34 +00:00
|
|
|
gl_RenderState.EnableTexture(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//==========================================================================
|
2018-04-26 22:22:00 +00:00
|
|
|
void FDrawInfo::DrawWall(GLWall *wall, int pass)
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
2018-04-26 22:22:00 +00:00
|
|
|
gl_RenderState.SetNormal(wall->glseg.Normal());
|
2013-06-23 07:49:34 +00:00
|
|
|
switch (pass)
|
|
|
|
{
|
2014-08-19 12:18:21 +00:00
|
|
|
case GLPASS_LIGHTSONLY:
|
2018-04-26 22:22:00 +00:00
|
|
|
if (wall->SetupLights(lightdata))
|
|
|
|
wall->dynlightindex = GLRenderer->mLights->UploadLights(lightdata);
|
2014-08-19 12:18:21 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GLPASS_ALL:
|
2018-04-26 22:22:00 +00:00
|
|
|
if (wall->SetupLights(lightdata))
|
|
|
|
wall->dynlightindex = GLRenderer->mLights->UploadLights(lightdata);
|
2013-06-23 07:49:34 +00:00
|
|
|
// fall through
|
2014-08-19 12:18:21 +00:00
|
|
|
case GLPASS_PLAIN:
|
2018-04-26 22:22:00 +00:00
|
|
|
RenderTexturedWall(wall, GLWall::RWF_TEXTURED);
|
2013-06-23 07:49:34 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GLPASS_TRANSLUCENT:
|
2014-09-20 07:04:36 +00:00
|
|
|
|
2018-04-26 22:22:00 +00:00
|
|
|
switch (wall->type)
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
|
|
|
case RENDERWALL_MIRRORSURFACE:
|
2018-04-26 22:22:00 +00:00
|
|
|
RenderMirrorSurface(wall);
|
2013-06-23 07:49:34 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case RENDERWALL_FOGBOUNDARY:
|
2018-04-26 22:22:00 +00:00
|
|
|
RenderFogBoundary(wall);
|
2013-06-23 07:49:34 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2018-04-26 22:22:00 +00:00
|
|
|
RenderTranslucentWall(wall);
|
2013-06-23 07:49:34 +00:00
|
|
|
break;
|
|
|
|
}
|
2016-05-08 22:58:55 +00:00
|
|
|
break;
|
2016-05-05 10:18:09 +00:00
|
|
|
|
|
|
|
case GLPASS_LIGHTTEX:
|
|
|
|
case GLPASS_LIGHTTEX_ADDITIVE:
|
2016-08-24 07:26:11 +00:00
|
|
|
case GLPASS_LIGHTTEX_FOGGY:
|
2018-04-26 22:22:00 +00:00
|
|
|
gl_drawinfo->RenderLightsCompat(wall, pass);
|
2016-05-05 10:18:09 +00:00
|
|
|
break;
|
2016-05-08 20:07:18 +00:00
|
|
|
|
|
|
|
case GLPASS_TEXONLY:
|
2018-04-26 22:22:00 +00:00
|
|
|
gl_RenderState.SetMaterial(wall->gltexture, wall->flags & 3, 0, -1, false);
|
|
|
|
RenderWall(wall, GLWall::RWF_TEXTURED);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
void FDrawInfo::AddWall(GLWall *wall)
|
|
|
|
{
|
|
|
|
bool translucent = !!(wall->flags & GLWall::GLWF_TRANSLUCENT);
|
|
|
|
int list;
|
|
|
|
|
|
|
|
if (translucent) // translucent walls
|
|
|
|
{
|
|
|
|
if (!gl.legacyMode && mDrawer->FixedColormap == CM_DEFAULT && wall->gltexture != nullptr)
|
|
|
|
{
|
|
|
|
if (wall->SetupLights(lightdata))
|
|
|
|
wall->dynlightindex = GLRenderer->mLights->UploadLights(lightdata);
|
|
|
|
}
|
|
|
|
wall->ViewDistance = (r_viewpoint.Pos - (wall->seg->linedef->v1->fPos() + wall->seg->linedef->Delta() / 2)).XY().LengthSquared();
|
|
|
|
wall->MakeVertices(this, true);
|
|
|
|
auto newwall = drawlists[GLDL_TRANSLUCENT].NewWall();
|
|
|
|
*newwall = *wall;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (gl.legacyMode)
|
|
|
|
{
|
|
|
|
if (PutWallCompat(wall, GLWall::passflag[wall->type])) return;
|
|
|
|
}
|
|
|
|
else if (mDrawer->FixedColormap == CM_DEFAULT)
|
|
|
|
{
|
|
|
|
if (wall->SetupLights(lightdata))
|
|
|
|
wall->dynlightindex = GLRenderer->mLights->UploadLights(lightdata);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool masked;
|
|
|
|
|
|
|
|
masked = GLWall::passflag[wall->type] == 1 ? false : (wall->gltexture && wall->gltexture->isMasked());
|
|
|
|
|
|
|
|
if ((wall->flags & GLWall::GLWF_SKYHACK && wall->type == RENDERWALL_M2S))
|
|
|
|
{
|
|
|
|
list = GLDL_MASKEDWALLSOFS;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
list = masked ? GLDL_MASKEDWALLS : GLDL_PLAINWALLS;
|
|
|
|
}
|
|
|
|
wall->MakeVertices(this, false);
|
|
|
|
auto newwall = drawlists[list].NewWall();
|
|
|
|
*newwall = *wall;
|
|
|
|
}
|
|
|
|
wall->dynlightindex = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
void FDrawInfo::AddMirrorSurface(GLWall *w)
|
|
|
|
{
|
|
|
|
w->type = RENDERWALL_MIRRORSURFACE;
|
|
|
|
auto newwall = drawlists[GLDL_TRANSLUCENTBORDER].NewWall();
|
|
|
|
*newwall = *w;
|
|
|
|
|
|
|
|
FVector3 v = newwall->glseg.Normal();
|
|
|
|
auto tcs = newwall->tcs;
|
|
|
|
tcs[GLWall::LOLFT].u = tcs[GLWall::LORGT].u = tcs[GLWall::UPLFT].u = tcs[GLWall::UPRGT].u = v.X;
|
|
|
|
tcs[GLWall::LOLFT].v = tcs[GLWall::LORGT].v = tcs[GLWall::UPLFT].v = tcs[GLWall::UPRGT].v = v.Z;
|
|
|
|
newwall->MakeVertices(this, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
void FDrawInfo::AddPortal(GLWall *wall, int ptype)
|
|
|
|
{
|
|
|
|
GLPortal * portal;
|
|
|
|
|
|
|
|
wall->MakeVertices(this, false);
|
|
|
|
switch (ptype)
|
|
|
|
{
|
|
|
|
// portals don't go into the draw list.
|
|
|
|
// Instead they are added to the portal manager
|
|
|
|
case PORTALTYPE_HORIZON:
|
|
|
|
wall->horizon = UniqueHorizons.Get(wall->horizon);
|
|
|
|
portal = GLPortal::FindPortal(wall->horizon);
|
|
|
|
if (!portal) portal = new GLHorizonPortal(wall->horizon);
|
|
|
|
portal->AddLine(wall);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PORTALTYPE_SKYBOX:
|
|
|
|
portal = GLPortal::FindPortal(wall->secportal);
|
|
|
|
if (!portal)
|
|
|
|
{
|
|
|
|
// either a regular skybox or an Eternity-style horizon
|
|
|
|
if (wall->secportal->mType != PORTS_SKYVIEWPOINT) portal = new GLEEHorizonPortal(wall->secportal);
|
|
|
|
else portal = new GLSkyboxPortal(wall->secportal);
|
|
|
|
}
|
|
|
|
portal->AddLine(wall);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PORTALTYPE_SECTORSTACK:
|
|
|
|
portal = wall->portal->GetRenderState();
|
|
|
|
portal->AddLine(wall);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PORTALTYPE_PLANEMIRROR:
|
|
|
|
if (GLPortal::PlaneMirrorMode * wall->planemirror->fC() <= 0)
|
|
|
|
{
|
|
|
|
//@sync-portal
|
|
|
|
wall->planemirror = UniquePlaneMirrors.Get(wall->planemirror);
|
|
|
|
portal = GLPortal::FindPortal(wall->planemirror);
|
|
|
|
if (!portal) portal = new GLPlaneMirrorPortal(wall->planemirror);
|
|
|
|
portal->AddLine(wall);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PORTALTYPE_MIRROR:
|
|
|
|
portal = GLPortal::FindPortal(wall->seg->linedef);
|
|
|
|
if (!portal) portal = new GLMirrorPortal(wall->seg->linedef);
|
|
|
|
portal->AddLine(wall);
|
|
|
|
if (gl_mirror_envmap)
|
|
|
|
{
|
|
|
|
// draw a reflective layer over the mirror
|
|
|
|
AddMirrorSurface(wall);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PORTALTYPE_LINETOLINE:
|
|
|
|
portal = GLPortal::FindPortal(wall->lineportal);
|
|
|
|
if (!portal)
|
|
|
|
{
|
|
|
|
line_t *otherside = wall->lineportal->lines[0]->mDestination;
|
|
|
|
if (otherside != NULL && otherside->portalindex < level.linePortals.Size())
|
|
|
|
{
|
|
|
|
ProcessActorsInPortal(otherside->getPortal()->mGroup);
|
|
|
|
}
|
|
|
|
portal = new GLLineToLinePortal(wall->lineportal);
|
|
|
|
}
|
|
|
|
portal->AddLine(wall);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PORTALTYPE_SKY:
|
|
|
|
portal = GLPortal::FindPortal(wall->sky);
|
|
|
|
if (!portal) portal = new GLSkyPortal(wall->sky);
|
|
|
|
portal->AddLine(wall);
|
2016-05-08 20:07:18 +00:00
|
|
|
break;
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
2018-04-26 22:22:00 +00:00
|
|
|
wall->vertcount = 0;
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|