mirror of
https://github.com/ZDoom/qzdoom-gpl.git
synced 2025-02-13 07:02:03 +00:00
Merge branch 'master' of https://github.com/coelckers/gzdoom
This commit is contained in:
commit
f6cb797504
34 changed files with 400 additions and 106 deletions
|
@ -770,6 +770,7 @@ set( FASTMATH_SOURCES
|
|||
gl/utility/gl_cycler.cpp
|
||||
gl/utility/gl_geometric.cpp
|
||||
gl/renderer/gl_2ddrawer.cpp
|
||||
gl/renderer/gl_quaddrawer.cpp
|
||||
gl/renderer/gl_renderer.cpp
|
||||
gl/renderer/gl_renderstate.cpp
|
||||
gl/renderer/gl_renderbuffers.cpp
|
||||
|
|
|
@ -137,9 +137,9 @@ void FSimpleVertexBuffer::set(FSimpleVertex *verts, int count)
|
|||
//==========================================================================
|
||||
|
||||
FFlatVertexBuffer::FFlatVertexBuffer(int width, int height)
|
||||
: FVertexBuffer(gl.buffermethod == BM_PERSISTENT)
|
||||
: FVertexBuffer(gl.buffermethod != BM_CLIENTARRAY)
|
||||
{
|
||||
if (gl.buffermethod == BM_PERSISTENT)
|
||||
if (gl.buffermethod != BM_CLIENTARRAY)
|
||||
{
|
||||
unsigned int bytesize = BUFFER_SIZE * sizeof(FFlatVertex);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, vbo_id);
|
||||
|
@ -157,10 +157,10 @@ FFlatVertexBuffer::FFlatVertexBuffer(int width, int height)
|
|||
vbo_shadowdata.Resize(mNumReserved);
|
||||
|
||||
// the first quad is reserved for handling coordinates through uniforms.
|
||||
vbo_shadowdata[0].Set(1, 0, 0, 0, 0);
|
||||
vbo_shadowdata[1].Set(2, 0, 0, 0, 0);
|
||||
vbo_shadowdata[2].Set(3, 0, 0, 0, 0);
|
||||
vbo_shadowdata[3].Set(4, 0, 0, 0, 0);
|
||||
vbo_shadowdata[0].Set(0, 0, 0, 0, 0);
|
||||
vbo_shadowdata[1].Set(1, 0, 0, 0, 0);
|
||||
vbo_shadowdata[2].Set(2, 0, 0, 0, 0);
|
||||
vbo_shadowdata[3].Set(3, 0, 0, 0, 0);
|
||||
|
||||
// and the second one for the fullscreen quad used for blend overlays.
|
||||
vbo_shadowdata[4].Set(0, 0, 0, 0, 0);
|
||||
|
|
|
@ -97,9 +97,17 @@ public:
|
|||
{
|
||||
return &map[mCurIndex];
|
||||
}
|
||||
FFlatVertex *Alloc(int num, int *poffset)
|
||||
{
|
||||
FFlatVertex *p = GetBuffer();
|
||||
*poffset = mCurIndex;
|
||||
mCurIndex += num;
|
||||
if (mCurIndex >= BUFFER_SIZE_TO_USE) mCurIndex = mIndex;
|
||||
return p;
|
||||
}
|
||||
|
||||
unsigned int GetCount(FFlatVertex *newptr, unsigned int *poffset)
|
||||
{
|
||||
|
||||
unsigned int newofs = (unsigned int)(newptr - map);
|
||||
unsigned int diff = newofs - mCurIndex;
|
||||
*poffset = mCurIndex;
|
||||
|
|
|
@ -55,6 +55,7 @@
|
|||
#include "r_utility.h"
|
||||
#include "a_hexenglobal.h"
|
||||
#include "p_local.h"
|
||||
#include "colormatcher.h"
|
||||
#include "gl/gl_functions.h"
|
||||
#include "gl/system/gl_interface.h"
|
||||
#include "gl/system/gl_framebuffer.h"
|
||||
|
@ -89,7 +90,7 @@ CVAR(Float, gl_exposure, 0.0f, 0)
|
|||
|
||||
CUSTOM_CVAR(Int, gl_tonemap, 0, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
||||
{
|
||||
if (self < 0 || self > 4)
|
||||
if (self < 0 || self > 5)
|
||||
self = 0;
|
||||
}
|
||||
|
||||
|
@ -222,13 +223,61 @@ void FGLRenderer::TonemapScene()
|
|||
mBuffers->BindCurrentTexture(0);
|
||||
mTonemapShader->Bind();
|
||||
mTonemapShader->SceneTexture.Set(0);
|
||||
|
||||
if (mTonemapShader->IsPaletteMode())
|
||||
{
|
||||
mTonemapShader->PaletteLUT.Set(1);
|
||||
BindTonemapPalette(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
mTonemapShader->Exposure.Set(mCameraExposure);
|
||||
}
|
||||
|
||||
RenderScreenQuad();
|
||||
mBuffers->NextTexture();
|
||||
|
||||
FGLDebug::PopGroup();
|
||||
}
|
||||
|
||||
void FGLRenderer::BindTonemapPalette(int texunit)
|
||||
{
|
||||
if (mTonemapPalette)
|
||||
{
|
||||
mTonemapPalette->Bind(texunit, 0, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
TArray<unsigned char> lut;
|
||||
lut.Resize(512 * 512 * 4);
|
||||
for (int r = 0; r < 64; r++)
|
||||
{
|
||||
for (int g = 0; g < 64; g++)
|
||||
{
|
||||
for (int b = 0; b < 64; b++)
|
||||
{
|
||||
PalEntry color = GPalette.BaseColors[ColorMatcher.Pick((r << 2) | (r >> 1), (g << 2) | (g >> 1), (b << 2) | (b >> 1))];
|
||||
int index = ((r * 64 + g) * 64 + b) * 4;
|
||||
lut[index] = color.r;
|
||||
lut[index + 1] = color.g;
|
||||
lut[index + 2] = color.b;
|
||||
lut[index + 3] = 255;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mTonemapPalette = new FHardwareTexture(512, 512, true);
|
||||
mTonemapPalette->CreateTexture(&lut[0], 512, 512, texunit, false, 0, "mTonemapPalette");
|
||||
|
||||
glActiveTexture(GL_TEXTURE0 + texunit);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Apply lens distortion and place the result in the HUD/2D texture
|
||||
|
|
|
@ -62,8 +62,12 @@ FGLPostProcessState::FGLPostProcessState()
|
|||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
if (gl.flags & RFL_SAMPLER_OBJECTS)
|
||||
{
|
||||
glGetIntegerv(GL_SAMPLER_BINDING, &samplerBinding);
|
||||
glGetIntegerv(GL_SAMPLER_BINDING, &samplerBinding[0]);
|
||||
glBindSampler(0, 0);
|
||||
glActiveTexture(GL_TEXTURE0 + 1);
|
||||
glGetIntegerv(GL_SAMPLER_BINDING, &samplerBinding[1]);
|
||||
glBindSampler(1, 0);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
}
|
||||
|
||||
glGetBooleanv(GL_BLEND, &blendEnabled);
|
||||
|
@ -120,7 +124,10 @@ FGLPostProcessState::~FGLPostProcessState()
|
|||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
if (gl.flags & RFL_SAMPLER_OBJECTS)
|
||||
glBindSampler(0, samplerBinding);
|
||||
{
|
||||
glBindSampler(0, samplerBinding[0]);
|
||||
glBindSampler(1, samplerBinding[1]);
|
||||
}
|
||||
glBindTexture(GL_TEXTURE_2D, textureBinding);
|
||||
glActiveTexture(activeTex);
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ private:
|
|||
|
||||
GLint activeTex;
|
||||
GLint textureBinding;
|
||||
GLint samplerBinding;
|
||||
GLint samplerBinding[2];
|
||||
GLboolean blendEnabled;
|
||||
GLboolean scissorEnabled;
|
||||
GLboolean depthEnabled;
|
||||
|
|
86
src/gl/renderer/gl_quaddrawer.cpp
Normal file
86
src/gl/renderer/gl_quaddrawer.cpp
Normal file
|
@ -0,0 +1,86 @@
|
|||
/*
|
||||
** gl_quaddrawer.h
|
||||
**
|
||||
**---------------------------------------------------------------------------
|
||||
** Copyright 2016 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 "gl/shaders/gl_shader.h"
|
||||
#include "gl/renderer/gl_renderer.h"
|
||||
#include "gl/renderer/gl_renderstate.h"
|
||||
#include "gl/renderer/gl_quaddrawer.h"
|
||||
#include "gl/data/gl_matrix.h"
|
||||
|
||||
/*
|
||||
** For handling of dynamically created quads when no persistently mapped
|
||||
** buffer or client array is available (i.e. GL 3.x core profiles)
|
||||
**
|
||||
** In this situation the 4 vertices of a quad primitive are being passed
|
||||
** as a matrix uniform because that is a lot faster than any kind of
|
||||
** temporary buffer change.
|
||||
*/
|
||||
|
||||
FFlatVertex FQuadDrawer::buffer[4];
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void FQuadDrawer::DoRender(int type)
|
||||
{
|
||||
// When this gets called, the render state must already be applied so we can just
|
||||
// send our vertices to the current shader.
|
||||
float matV[16], matT[16];
|
||||
|
||||
for(int i=0;i<4;i++)
|
||||
{
|
||||
matV[i*4+0] = buffer[i].x;
|
||||
matV[i*4+1] = buffer[i].z;
|
||||
matV[i*4+2] = buffer[i].y;
|
||||
matV[i*4+3] = 1;
|
||||
matT[i*4+0] = buffer[i].u;
|
||||
matT[i*4+1] = buffer[i].v;
|
||||
matT[i*4+2] = matT[i*4+3] = 0;
|
||||
}
|
||||
FShader *shader = GLRenderer->mShaderManager->GetActiveShader();
|
||||
glUniformMatrix4fv(shader->vertexmatrix_index, 1, false, matV);
|
||||
glUniformMatrix4fv(shader->texcoordmatrix_index, 1, false, matT);
|
||||
glUniform1i(shader->quadmode_index, 1);
|
||||
GLRenderer->mVBO->RenderArray(type, 0, 4);
|
||||
glUniform1i(shader->quadmode_index, 0);
|
||||
}
|
44
src/gl/renderer/gl_quaddrawer.h
Normal file
44
src/gl/renderer/gl_quaddrawer.h
Normal file
|
@ -0,0 +1,44 @@
|
|||
#ifndef __QDRAWER_H
|
||||
#define __QDRAWER_H
|
||||
|
||||
#include "gl/data/gl_vertexbuffer.h"
|
||||
|
||||
class FQuadDrawer
|
||||
{
|
||||
FFlatVertex *p;
|
||||
int ndx;
|
||||
static FFlatVertex buffer[4];
|
||||
|
||||
void DoRender(int type);
|
||||
public:
|
||||
|
||||
FQuadDrawer()
|
||||
{
|
||||
if (gl.buffermethod == BM_DEFERRED)
|
||||
{
|
||||
p = buffer;
|
||||
}
|
||||
else
|
||||
{
|
||||
p = GLRenderer->mVBO->Alloc(4, &ndx);
|
||||
}
|
||||
}
|
||||
void Set(int ndx, float x, float y, float z, float s, float t)
|
||||
{
|
||||
p[ndx].Set(x, y, z, s, t);
|
||||
}
|
||||
void Render(int type)
|
||||
{
|
||||
if (gl.buffermethod == BM_DEFERRED)
|
||||
{
|
||||
DoRender(type);
|
||||
}
|
||||
else
|
||||
{
|
||||
GLRenderer->mVBO->RenderArray(type, ndx, 4);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#endif
|
|
@ -123,6 +123,7 @@ void FGLRenderer::Initialize(int width, int height)
|
|||
mBloomCombineShader = new FBloomCombineShader();
|
||||
mBlurShader = new FBlurShader();
|
||||
mTonemapShader = new FTonemapShader();
|
||||
mTonemapPalette = nullptr;
|
||||
mLensShader = new FLensShader();
|
||||
mPresentShader = new FPresentShader();
|
||||
m2DDrawer = new F2DDrawer;
|
||||
|
@ -181,6 +182,7 @@ FGLRenderer::~FGLRenderer()
|
|||
if (mBloomCombineShader) delete mBloomCombineShader;
|
||||
if (mBlurShader) delete mBlurShader;
|
||||
if (mTonemapShader) delete mTonemapShader;
|
||||
if (mTonemapPalette) delete mTonemapPalette;
|
||||
if (mLensShader) delete mLensShader;
|
||||
}
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ class FTonemapShader;
|
|||
class FLensShader;
|
||||
class FPresentShader;
|
||||
class F2DDrawer;
|
||||
class FHardwareTexture;
|
||||
|
||||
inline float DEG2RAD(float deg)
|
||||
{
|
||||
|
@ -92,6 +93,7 @@ public:
|
|||
FBloomCombineShader *mBloomCombineShader;
|
||||
FBlurShader *mBlurShader;
|
||||
FTonemapShader *mTonemapShader;
|
||||
FHardwareTexture *mTonemapPalette;
|
||||
FLensShader *mLensShader;
|
||||
FPresentShader *mPresentShader;
|
||||
|
||||
|
@ -164,6 +166,7 @@ public:
|
|||
void EndDrawScene(sector_t * viewsector);
|
||||
void BloomScene();
|
||||
void TonemapScene();
|
||||
void BindTonemapPalette(int texunit);
|
||||
void LensDistortScene();
|
||||
void CopyToBackbuffer(const GL_IRECT *bounds, bool applyGamma);
|
||||
void Flush() { CopyToBackbuffer(nullptr, true); }
|
||||
|
|
|
@ -54,6 +54,7 @@
|
|||
#include "gl/textures/gl_texture.h"
|
||||
#include "gl/textures/gl_material.h"
|
||||
#include "gl/utility/gl_clock.h"
|
||||
#include "gl/renderer/gl_quaddrawer.h"
|
||||
|
||||
struct DecalVertex
|
||||
{
|
||||
|
@ -328,22 +329,19 @@ void GLWall::DrawDecal(DBaseDecal *decal)
|
|||
gl_RenderState.SetFog(0,-1);
|
||||
}
|
||||
|
||||
FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer();
|
||||
FQuadDrawer qd;
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
ptr->Set(dv[i].x, dv[i].z, dv[i].y, dv[i].u, dv[i].v);
|
||||
ptr++;
|
||||
qd.Set(i, dv[i].x, dv[i].z, dv[i].y, dv[i].u, dv[i].v);
|
||||
}
|
||||
|
||||
if (lightlist == NULL)
|
||||
{
|
||||
gl_RenderState.Apply();
|
||||
GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_FAN);
|
||||
qd.Render(GL_TRIANGLE_FAN);
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned int offset;
|
||||
unsigned int count = GLRenderer->mVBO->GetCount(ptr, &offset);
|
||||
for (unsigned k = 0; k < lightlist->Size(); k++)
|
||||
{
|
||||
secplane_t &lowplane = k == (*lightlist).Size() - 1 ? bottomplane : (*lightlist)[k + 1].plane;
|
||||
|
@ -363,7 +361,7 @@ void GLWall::DrawDecal(DBaseDecal *decal)
|
|||
gl_RenderState.SetSplitPlanes((*lightlist)[k].plane, lowplane);
|
||||
|
||||
gl_RenderState.Apply();
|
||||
GLRenderer->mVBO->RenderArray(GL_TRIANGLE_FAN, offset, count);
|
||||
qd.Render(GL_TRIANGLE_FAN);
|
||||
}
|
||||
if (low1 <= dv[0].z && low2 <= dv[3].z) break;
|
||||
}
|
||||
|
|
|
@ -57,6 +57,7 @@
|
|||
#include "gl/utility/gl_templates.h"
|
||||
#include "gl/shaders/gl_shader.h"
|
||||
#include "gl/stereo3d/scoped_color_mask.h"
|
||||
#include "gl/renderer/gl_quaddrawer.h"
|
||||
|
||||
FDrawInfo * gl_drawinfo;
|
||||
|
||||
|
@ -1079,17 +1080,12 @@ void FDrawInfo::SetupFloodStencil(wallseg * ws)
|
|||
glDepthMask(true);
|
||||
|
||||
gl_RenderState.Apply();
|
||||
FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer();
|
||||
ptr->Set(ws->x1, ws->z1, ws->y1, 0, 0);
|
||||
ptr++;
|
||||
ptr->Set(ws->x1, ws->z2, ws->y1, 0, 0);
|
||||
ptr++;
|
||||
ptr->Set(ws->x2, ws->z2, ws->y2, 0, 0);
|
||||
ptr++;
|
||||
ptr->Set(ws->x2, ws->z1, ws->y2, 0, 0);
|
||||
ptr++;
|
||||
GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_FAN);
|
||||
|
||||
FQuadDrawer qd;
|
||||
qd.Set(0, ws->x1, ws->z1, ws->y1, 0, 0);
|
||||
qd.Set(1, ws->x1, ws->z2, ws->y1, 0, 0);
|
||||
qd.Set(2, ws->x2, ws->z2, ws->y2, 0, 0);
|
||||
qd.Set(3, ws->x2, ws->z1, ws->y2, 0, 0);
|
||||
qd.Render(GL_TRIANGLE_FAN);
|
||||
|
||||
glStencilFunc(GL_EQUAL, recursion + 1, ~0); // draw sky into stencil
|
||||
glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); // this stage doesn't modify the stencil
|
||||
|
@ -1112,16 +1108,12 @@ void FDrawInfo::ClearFloodStencil(wallseg * ws)
|
|||
gl_RenderState.ResetColor();
|
||||
|
||||
gl_RenderState.Apply();
|
||||
FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer();
|
||||
ptr->Set(ws->x1, ws->z1, ws->y1, 0, 0);
|
||||
ptr++;
|
||||
ptr->Set(ws->x1, ws->z2, ws->y1, 0, 0);
|
||||
ptr++;
|
||||
ptr->Set(ws->x2, ws->z2, ws->y2, 0, 0);
|
||||
ptr++;
|
||||
ptr->Set(ws->x2, ws->z1, ws->y2, 0, 0);
|
||||
ptr++;
|
||||
GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_FAN);
|
||||
FQuadDrawer qd;
|
||||
qd.Set(0, ws->x1, ws->z1, ws->y1, 0, 0);
|
||||
qd.Set(1, ws->x1, ws->z2, ws->y1, 0, 0);
|
||||
qd.Set(2, ws->x2, ws->z2, ws->y2, 0, 0);
|
||||
qd.Set(3, ws->x2, ws->z1, ws->y2, 0, 0);
|
||||
qd.Render(GL_TRIANGLE_FAN);
|
||||
|
||||
// restore old stencil op.
|
||||
glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
|
||||
|
@ -1192,16 +1184,12 @@ void FDrawInfo::DrawFloodedPlane(wallseg * ws, float planez, sector_t * sec, boo
|
|||
float px4 = fviewx + prj_fac1 * (ws->x2-fviewx);
|
||||
float py4 = fviewy + prj_fac1 * (ws->y2-fviewy);
|
||||
|
||||
FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer();
|
||||
ptr->Set(px1, planez, py1, px1 / 64, -py1 / 64);
|
||||
ptr++;
|
||||
ptr->Set(px2, planez, py2, px2 / 64, -py2 / 64);
|
||||
ptr++;
|
||||
ptr->Set(px3, planez, py3, px3 / 64, -py3 / 64);
|
||||
ptr++;
|
||||
ptr->Set(px4, planez, py4, px4 / 64, -py4 / 64);
|
||||
ptr++;
|
||||
GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_FAN);
|
||||
FQuadDrawer qd;
|
||||
qd.Set(0, px1, planez, py1, px1 / 64, -py1 / 64);
|
||||
qd.Set(1, px2, planez, py2, px2 / 64, -py2 / 64);
|
||||
qd.Set(2, px3, planez, py3, px3 / 64, -py3 / 64);
|
||||
qd.Set(3, px4, planez, py4, px4 / 64, -py4 / 64);
|
||||
qd.Render(GL_TRIANGLE_FAN);
|
||||
|
||||
gl_RenderState.EnableTextureMatrix(false);
|
||||
}
|
||||
|
|
|
@ -448,6 +448,7 @@ void GLFlat::Draw(int pass, bool trans) // trans only has meaning for GLPASS_LIG
|
|||
|
||||
case GLPASS_LIGHTTEX:
|
||||
case GLPASS_LIGHTTEX_ADDITIVE:
|
||||
case GLPASS_LIGHTTEX_FOGGY:
|
||||
DrawLightsCompat(pass);
|
||||
break;
|
||||
|
||||
|
|
|
@ -411,6 +411,8 @@ void FGLRenderer::RenderScene(int recursion)
|
|||
if (gl.lightmethod == LM_SOFTWARE)
|
||||
{
|
||||
// also process the render lists with walls and dynamic lights
|
||||
gl_drawinfo->dldrawlists[GLLDL_WALLS_PLAIN].DrawDecals();
|
||||
gl_drawinfo->dldrawlists[GLLDL_WALLS_FOG].DrawDecals();
|
||||
}
|
||||
|
||||
gl_RenderState.SetTextureMode(TM_MODULATE);
|
||||
|
|
|
@ -64,6 +64,7 @@
|
|||
#include "gl/textures/gl_material.h"
|
||||
#include "gl/utility/gl_clock.h"
|
||||
#include "gl/data/gl_vertexbuffer.h"
|
||||
#include "gl/renderer/gl_quaddrawer.h"
|
||||
|
||||
CVAR(Bool, gl_usecolorblending, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
||||
CVAR(Bool, gl_spritebrightfog, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG);
|
||||
|
@ -399,18 +400,12 @@ void GLSprite::Draw(int pass)
|
|||
v4 = FVector3(x2, z2, y2);
|
||||
}
|
||||
|
||||
FFlatVertex *ptr;
|
||||
unsigned int offset, count;
|
||||
ptr = GLRenderer->mVBO->GetBuffer();
|
||||
ptr->Set(v1[0], v1[1], v1[2], ul, vt);
|
||||
ptr++;
|
||||
ptr->Set(v2[0], v2[1], v2[2], ur, vt);
|
||||
ptr++;
|
||||
ptr->Set(v3[0], v3[1], v3[2], ul, vb);
|
||||
ptr++;
|
||||
ptr->Set(v4[0], v4[1], v4[2], ur, vb);
|
||||
ptr++;
|
||||
GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP, &offset, &count);
|
||||
FQuadDrawer qd;
|
||||
qd.Set(0, v1[0], v1[1], v1[2], ul, vt);
|
||||
qd.Set(1, v2[0], v2[1], v2[2], ur, vt);
|
||||
qd.Set(2, v3[0], v3[1], v3[2], ul, vb);
|
||||
qd.Set(3, v4[0], v4[1], v4[2], ur, vb);
|
||||
qd.Render(GL_TRIANGLE_STRIP);
|
||||
|
||||
if (foglayer)
|
||||
{
|
||||
|
@ -420,7 +415,7 @@ void GLSprite::Draw(int pass)
|
|||
gl_RenderState.BlendEquation(GL_FUNC_ADD);
|
||||
gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
gl_RenderState.Apply();
|
||||
GLRenderer->mVBO->RenderArray(GL_TRIANGLE_STRIP, offset, count);
|
||||
qd.Render(GL_TRIANGLE_STRIP);
|
||||
gl_RenderState.SetFixedColormap(CM_DEFAULT);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -448,6 +448,7 @@ void GLWall::Draw(int pass)
|
|||
|
||||
case GLPASS_LIGHTTEX:
|
||||
case GLPASS_LIGHTTEX_ADDITIVE:
|
||||
case GLPASS_LIGHTTEX_FOGGY:
|
||||
RenderLightsCompat(pass);
|
||||
break;
|
||||
|
||||
|
|
|
@ -57,6 +57,7 @@
|
|||
#include "gl/models/gl_models.h"
|
||||
#include "gl/shaders/gl_shader.h"
|
||||
#include "gl/textures/gl_material.h"
|
||||
#include "gl/renderer/gl_quaddrawer.h"
|
||||
|
||||
EXTERN_CVAR (Bool, r_drawplayersprites)
|
||||
EXTERN_CVAR(Float, transsouls)
|
||||
|
@ -161,16 +162,12 @@ void FGLRenderer::DrawPSprite (player_t * player,DPSprite *psp, float sx, float
|
|||
gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f);
|
||||
}
|
||||
gl_RenderState.Apply();
|
||||
FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer();
|
||||
ptr->Set(x1, y1, 0, fU1, fV1);
|
||||
ptr++;
|
||||
ptr->Set(x1, y2, 0, fU1, fV2);
|
||||
ptr++;
|
||||
ptr->Set(x2, y1, 0, fU2, fV1);
|
||||
ptr++;
|
||||
ptr->Set(x2, y2, 0, fU2, fV2);
|
||||
ptr++;
|
||||
GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP);
|
||||
FQuadDrawer qd;
|
||||
qd.Set(0, x1, y1, 0, fU1, fV1);
|
||||
qd.Set(1, x1, y2, 0, fU1, fV2);
|
||||
qd.Set(2, x2, y1, 0, fU2, fV1);
|
||||
qd.Set(3, x2, y2, 0, fU2, fV2);
|
||||
qd.Render(GL_TRIANGLE_STRIP);
|
||||
gl_RenderState.AlphaFunc(GL_GEQUAL, 0.5f);
|
||||
}
|
||||
|
||||
|
|
|
@ -125,6 +125,10 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char *
|
|||
vp_comb = "#version 400 core\n#extension GL_ARB_shader_storage_buffer_object : require\n#define SHADER_STORAGE_LIGHTS\n";
|
||||
}
|
||||
}
|
||||
//if (gl.buffermethod == BM_DEFERRED)
|
||||
{
|
||||
vp_comb << "#define USE_QUAD_DRAWER\n";
|
||||
}
|
||||
|
||||
vp_comb << defines << i_data.GetString().GetChars();
|
||||
FString fp_comb = vp_comb;
|
||||
|
@ -265,6 +269,9 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char *
|
|||
viewmatrix_index = glGetUniformLocation(hShader, "ViewMatrix");
|
||||
modelmatrix_index = glGetUniformLocation(hShader, "ModelMatrix");
|
||||
texturematrix_index = glGetUniformLocation(hShader, "TextureMatrix");
|
||||
vertexmatrix_index = glGetUniformLocation(hShader, "uQuadVertices");
|
||||
texcoordmatrix_index = glGetUniformLocation(hShader, "uQuadTexCoords");
|
||||
quadmode_index = glGetUniformLocation(hShader, "uQuadMode");
|
||||
|
||||
if (LM_SOFTWARE != gl.lightmethod && !(gl.flags & RFL_SHADER_STORAGE_BUFFER))
|
||||
{
|
||||
|
@ -273,6 +280,7 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char *
|
|||
}
|
||||
|
||||
glUseProgram(hShader);
|
||||
if (quadmode_index > 0) glUniform1i(quadmode_index, 0);
|
||||
|
||||
// set up other texture units (if needed by the shader)
|
||||
for (int i = 2; i<16; i++)
|
||||
|
|
|
@ -244,6 +244,9 @@ class FShader
|
|||
int modelmatrix_index;
|
||||
int texturematrix_index;
|
||||
public:
|
||||
int vertexmatrix_index;
|
||||
int texcoordmatrix_index;
|
||||
int quadmode_index;
|
||||
int fakevb_index;
|
||||
private:
|
||||
int currentglowstate = 0;
|
||||
|
|
|
@ -61,10 +61,16 @@ void FTonemapShader::Bind()
|
|||
shader.SetAttribLocation(0, "PositionInProjection");
|
||||
SceneTexture.Init(shader, "InputTexture");
|
||||
Exposure.Init(shader, "ExposureAdjustment");
|
||||
PaletteLUT.Init(shader, "PaletteLUT");
|
||||
}
|
||||
shader.Bind();
|
||||
}
|
||||
|
||||
bool FTonemapShader::IsPaletteMode()
|
||||
{
|
||||
return gl_tonemap == Palette;
|
||||
}
|
||||
|
||||
const char *FTonemapShader::GetDefines(int mode)
|
||||
{
|
||||
switch (mode)
|
||||
|
@ -74,5 +80,6 @@ const char *FTonemapShader::GetDefines(int mode)
|
|||
case Reinhard: return "#define REINHARD\n";
|
||||
case HejlDawson: return "#define HEJLDAWSON\n";
|
||||
case Uncharted2: return "#define UNCHARTED2\n";
|
||||
case Palette: return "#define PALETTE\n";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,9 @@ public:
|
|||
|
||||
FBufferedUniform1i SceneTexture;
|
||||
FBufferedUniform1f Exposure;
|
||||
FBufferedUniform1i PaletteLUT;
|
||||
|
||||
static bool IsPaletteMode();
|
||||
|
||||
private:
|
||||
enum TonemapMode
|
||||
|
@ -19,6 +22,7 @@ private:
|
|||
HejlDawson,
|
||||
Reinhard,
|
||||
Linear,
|
||||
Palette,
|
||||
NumTonemapModes
|
||||
};
|
||||
|
||||
|
|
|
@ -49,7 +49,14 @@
|
|||
#include <signal.h>
|
||||
#endif
|
||||
|
||||
CVAR(Int, gl_debug_level, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG);
|
||||
CUSTOM_CVAR(Int, gl_debug_level, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL)
|
||||
{
|
||||
if (!FGLDebug::HasDebugApi())
|
||||
{
|
||||
Printf("No OpenGL debug support detected.\n");
|
||||
}
|
||||
}
|
||||
|
||||
CVAR(Bool, gl_debug_breakpoint, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -60,6 +67,9 @@ CVAR(Bool, gl_debug_breakpoint, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG);
|
|||
|
||||
void FGLDebug::Update()
|
||||
{
|
||||
if (!HasDebugApi())
|
||||
return;
|
||||
|
||||
SetupBreakpointMode();
|
||||
UpdateLoggingLevel();
|
||||
OutputMessageLog();
|
||||
|
@ -74,7 +84,7 @@ void FGLDebug::Update()
|
|||
|
||||
void FGLDebug::LabelObject(GLenum type, GLuint handle, const FString &name)
|
||||
{
|
||||
if (gl_debug_level != 0)
|
||||
if (HasDebugApi() && gl_debug_level != 0)
|
||||
{
|
||||
glObjectLabel(type, handle, (GLsizei)name.Len(), name.GetChars());
|
||||
}
|
||||
|
@ -82,7 +92,7 @@ void FGLDebug::LabelObject(GLenum type, GLuint handle, const FString &name)
|
|||
|
||||
void FGLDebug::LabelObjectPtr(void *ptr, const FString &name)
|
||||
{
|
||||
if (gl_debug_level != 0)
|
||||
if (HasDebugApi() && gl_debug_level != 0)
|
||||
{
|
||||
glObjectPtrLabel(ptr, (GLsizei)name.Len(), name.GetChars());
|
||||
}
|
||||
|
@ -97,7 +107,7 @@ void FGLDebug::LabelObjectPtr(void *ptr, const FString &name)
|
|||
|
||||
void FGLDebug::PushGroup(const FString &name)
|
||||
{
|
||||
if (gl_debug_level != 0)
|
||||
if (HasDebugApi() && gl_debug_level != 0)
|
||||
{
|
||||
glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0, (GLsizei)name.Len(), name.GetChars());
|
||||
}
|
||||
|
@ -105,7 +115,7 @@ void FGLDebug::PushGroup(const FString &name)
|
|||
|
||||
void FGLDebug::PopGroup()
|
||||
{
|
||||
if (gl_debug_level != 0)
|
||||
if (HasDebugApi() && gl_debug_level != 0)
|
||||
{
|
||||
glPopDebugGroup();
|
||||
}
|
||||
|
|
|
@ -17,6 +17,8 @@ public:
|
|||
static void PushGroup(const FString &name);
|
||||
static void PopGroup();
|
||||
|
||||
static bool HasDebugApi() { return (gl.flags & RFL_DEBUG) != 0; }
|
||||
|
||||
private:
|
||||
void SetupBreakpointMode();
|
||||
void UpdateLoggingLevel();
|
||||
|
|
|
@ -156,7 +156,15 @@ void gl_LoadExtensions()
|
|||
|
||||
gl.version = strtod(version, NULL) + 0.01f;
|
||||
|
||||
// Don't even start if it's lower than 3.0
|
||||
bool iscore = false;
|
||||
if (gl.version >= 3.2)
|
||||
{
|
||||
int v;
|
||||
glGetIntegerv(GL_CONTEXT_PROFILE_MASK, &v);
|
||||
iscore = !!(v & GL_CONTEXT_CORE_PROFILE_BIT);
|
||||
}
|
||||
|
||||
// Don't even start if it's lower than 2.0 or no framebuffers are available
|
||||
if ((gl.version < 2.0 || !CheckExtension("GL_EXT_framebuffer_object")) && gl.version < 3.0)
|
||||
{
|
||||
I_FatalError("Unsupported OpenGL version.\nAt least OpenGL 2.0 with framebuffer support is required to run " GAMENAME ".\n");
|
||||
|
@ -178,10 +186,10 @@ void gl_LoadExtensions()
|
|||
if (gl.version > 3.0f && (gl.version >= 3.3f || CheckExtension("GL_ARB_uniform_buffer_object")))
|
||||
{
|
||||
gl.lightmethod = LM_DEFERRED;
|
||||
// Only Apple requires the core profile for GL 3.x+.
|
||||
// #ifdef __APPLE__
|
||||
// gl.buffermethod = BM_DEFERRED;
|
||||
// #endif
|
||||
if (iscore)
|
||||
{
|
||||
gl.buffermethod = BM_DEFERRED;
|
||||
}
|
||||
}
|
||||
|
||||
if (CheckExtension("GL_ARB_texture_compression")) gl.flags |= RFL_TEXTURE_COMPRESSION;
|
||||
|
@ -245,6 +253,7 @@ void gl_LoadExtensions()
|
|||
}
|
||||
|
||||
if (gl.version >= 4.3f || CheckExtension("GL_ARB_invalidate_subdata")) gl.flags |= RFL_INVALIDATE_BUFFER;
|
||||
if (gl.version >= 4.3f || CheckExtension("GL_KHR_debug")) gl.flags |= RFL_DEBUG;
|
||||
|
||||
const char *lm = Args->CheckValue("-lightmethod");
|
||||
if (lm != NULL)
|
||||
|
@ -256,7 +265,7 @@ void gl_LoadExtensions()
|
|||
lm = Args->CheckValue("-buffermethod");
|
||||
if (lm != NULL)
|
||||
{
|
||||
//if (!stricmp(lm, "deferred") && gl.buffermethod == BM_PERSISTENT) gl.buffermethod = BM_DEFERRED;
|
||||
if (!stricmp(lm, "deferred") && gl.buffermethod == BM_PERSISTENT) gl.buffermethod = BM_DEFERRED;
|
||||
if (!stricmp(lm, "clientarray")) gl.buffermethod = BM_CLIENTARRAY;
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,8 @@ enum RenderFlags
|
|||
RFL_NO_DEPTHSTENCIL = 64,
|
||||
RFL_NO_CLIP_PLANES = 128,
|
||||
|
||||
RFL_INVALIDATE_BUFFER = 256
|
||||
RFL_INVALIDATE_BUFFER = 256,
|
||||
RFL_DEBUG = 512
|
||||
};
|
||||
|
||||
enum TexMode
|
||||
|
|
|
@ -4438,8 +4438,7 @@ enum EACSFunctions
|
|||
ACSF_SpawnParticle,
|
||||
ACSF_SetMusicVolume,
|
||||
ACSF_CheckProximity,
|
||||
// 1 more left...
|
||||
|
||||
ACSF_CheckActorState, // 99
|
||||
/* Zandronum's - these must be skipped when we reach 99!
|
||||
-100:ResetMap(0),
|
||||
-101 : PlayerIsSpectator(1),
|
||||
|
@ -6017,6 +6016,18 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound)
|
|||
return P_Thing_CheckProximity(actor, classname, distance, count, flags, ptr);
|
||||
}
|
||||
|
||||
case ACSF_CheckActorState:
|
||||
{
|
||||
actor = SingleActorFromTID(args[0], activator);
|
||||
const char *statename = FBehavior::StaticLookupString(args[1]);
|
||||
bool exact = (argCount > 2) ? !!args[2] : false;
|
||||
if (actor && statename)
|
||||
{
|
||||
return (actor->GetClass()->FindStateByString(statename, exact) != nullptr);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -49,7 +49,8 @@ EXTERN_CVAR (Float, Gamma)
|
|||
EXTERN_CVAR (Int, vid_adapter)
|
||||
EXTERN_CVAR (Int, vid_displaybits)
|
||||
EXTERN_CVAR (Int, vid_renderer)
|
||||
|
||||
EXTERN_CVAR (Int, vid_maxfps)
|
||||
EXTERN_CVAR (Bool, cl_capfps)
|
||||
|
||||
// PUBLIC DATA DEFINITIONS -------------------------------------------------
|
||||
|
||||
|
@ -459,6 +460,13 @@ void SDLGLFB::NewRefreshRate ()
|
|||
|
||||
void SDLGLFB::SwapBuffers()
|
||||
{
|
||||
#ifndef __APPLE__
|
||||
if (vid_maxfps && !cl_capfps)
|
||||
{
|
||||
SEMAPHORE_WAIT(FPSLimitSemaphore)
|
||||
}
|
||||
#endif
|
||||
|
||||
SDL_GL_SwapWindow (Screen);
|
||||
}
|
||||
|
||||
|
|
|
@ -7267,12 +7267,10 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FaceMovementDirection)
|
|||
{
|
||||
current -= anglelimit + offset;
|
||||
}
|
||||
else // huh???
|
||||
{
|
||||
current = angle + 180. + offset;
|
||||
}
|
||||
mobj->SetAngle(current, !!(flags & FMDF_INTERPOLATE));
|
||||
}
|
||||
else
|
||||
mobj->SetAngle(angle + offset, !!(flags & FMDF_INTERPOLATE));
|
||||
}
|
||||
else
|
||||
mobj->SetAngle(angle + offset, !!(flags & FMDF_INTERPOLATE));
|
||||
|
|
|
@ -1149,6 +1149,11 @@ void Win32GLFrameBuffer::SetVSync (bool vsync)
|
|||
|
||||
void Win32GLFrameBuffer::SwapBuffers()
|
||||
{
|
||||
// Limiting the frame rate is as simple as waiting for the timer to signal this event.
|
||||
if (FPSLimitEvent != NULL)
|
||||
{
|
||||
WaitForSingleObject(FPSLimitEvent, 1000);
|
||||
}
|
||||
::SwapBuffers(static_cast<Win32GLVideo *>(Video)->m_hDC);
|
||||
}
|
||||
|
||||
|
|
|
@ -2700,3 +2700,4 @@ OPTVAL_QUADBUFFERED = "Quad-buffered";
|
|||
OPTVAL_UNCHARTED2 = "Uncharted 2";
|
||||
OPTVAL_HEJLDAWSON = "Hejl Dawson";
|
||||
OPTVAL_REINHARD = "Reinhard";
|
||||
OPTVAL_PALETTE = "Palette";
|
|
@ -39,6 +39,7 @@ OptionValue "TonemapModes"
|
|||
2, "$OPTVAL_HEJLDAWSON"
|
||||
3, "$OPTVAL_REINHARD"
|
||||
4, "$OPTVAL_LINEAR"
|
||||
5, "$OPTVAL_PALETTE"
|
||||
}
|
||||
|
||||
OptionValue "TextureFormats"
|
||||
|
|
|
@ -13,10 +13,29 @@ out vec4 vColor;
|
|||
|
||||
void main()
|
||||
{
|
||||
#ifndef SIMPLE
|
||||
vec4 worldcoord = ModelMatrix * mix(aPosition, aVertex2, uInterpolationFactor);
|
||||
vec2 parmTexCoord;
|
||||
vec4 parmPosition;
|
||||
|
||||
#ifndef USE_QUAD_DRAWER
|
||||
parmTexCoord = aTexCoord;
|
||||
parmPosition = aPosition;
|
||||
#else
|
||||
vec4 worldcoord = ModelMatrix * aPosition;
|
||||
if (uQuadMode == 0)
|
||||
{
|
||||
parmTexCoord = aTexCoord;
|
||||
parmPosition = aPosition;
|
||||
}
|
||||
else
|
||||
{
|
||||
parmPosition = uQuadVertices[int(aPosition.x)];
|
||||
parmTexCoord = uQuadTexCoords[int(aPosition.x)].st;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef SIMPLE
|
||||
vec4 worldcoord = ModelMatrix * mix(parmPosition, aVertex2, uInterpolationFactor);
|
||||
#else
|
||||
vec4 worldcoord = ModelMatrix * parmPosition;
|
||||
#endif
|
||||
|
||||
vec4 eyeCoordPos = ViewMatrix * worldcoord;
|
||||
|
@ -39,23 +58,17 @@ void main()
|
|||
|
||||
#ifdef SPHEREMAP
|
||||
vec3 u = normalize(eyeCoordPos.xyz);
|
||||
vec4 n = normalize(TextureMatrix * vec4(aTexCoord.x, 0.0, aTexCoord.y, 0.0)); // use texture matrix and coordinates for our normal. Since this is only used on walls, the normal's y coordinate is always 0.
|
||||
vec4 n = normalize(TextureMatrix * vec4(parmTexCoord.x, 0.0, parmTexCoord.y, 0.0)); // use texture matrix and coordinates for our normal. Since this is only used on walls, the normal's y coordinate is always 0.
|
||||
vec3 r = reflect(u, n.xyz);
|
||||
float m = 2.0 * sqrt( r.x*r.x + r.y*r.y + (r.z+1.0)*(r.z+1.0) );
|
||||
vec2 sst = vec2(r.x/m + 0.5, r.y/m + 0.5);
|
||||
vTexCoord.xy = sst;
|
||||
#else
|
||||
vTexCoord = TextureMatrix * vec4(aTexCoord, 0.0, 1.0);
|
||||
vTexCoord = TextureMatrix * vec4(parmTexCoord, 0.0, 1.0);
|
||||
#endif
|
||||
|
||||
gl_Position = ProjectionMatrix * eyeCoordPos;
|
||||
|
||||
#if defined __GLSL_CG_DATA_TYPES && defined GLSL12_COMPATIBILE
|
||||
gl_ClipVertex = eyeCoordPos;
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
if (uClipHeightDirection != 0.0) // clip planes used for reflective flats
|
||||
{
|
||||
gl_ClipDistance[0] = (worldcoord.y - uClipHeight) * uClipHeightDirection;
|
||||
|
|
|
@ -45,6 +45,13 @@ uniform int uFogEnabled;
|
|||
// dynamic lights
|
||||
uniform int uLightIndex;
|
||||
|
||||
// quad drawer stuff
|
||||
#ifdef USE_QUAD_DRAWER
|
||||
uniform mat4 uQuadVertices;
|
||||
uniform mat4 uQuadTexCoords;
|
||||
uniform int uQuadMode;
|
||||
#endif
|
||||
|
||||
// matrices
|
||||
uniform mat4 ProjectionMatrix;
|
||||
uniform mat4 ViewMatrix;
|
||||
|
|
|
@ -42,7 +42,7 @@ vec3 Tonemap(vec3 color)
|
|||
return (x * (6.2 * x + 0.5)) / (x * (6.2 * x + 1.7) + 0.06); // no sRGB needed
|
||||
}
|
||||
|
||||
#else
|
||||
#elif defined(UNCHARTED2)
|
||||
|
||||
vec3 Uncharted2Tonemap(vec3 x)
|
||||
{
|
||||
|
@ -63,12 +63,36 @@ vec3 Tonemap(vec3 color)
|
|||
return sRGB(curr * whiteScale);
|
||||
}
|
||||
|
||||
#elif defined(PALETTE)
|
||||
|
||||
uniform sampler2D PaletteLUT;
|
||||
|
||||
vec3 Tonemap(vec3 color)
|
||||
{
|
||||
ivec3 c = ivec3(clamp(color.rgb, vec3(0.0), vec3(1.0)) * 255.0 + 0.5);
|
||||
#if __VERSION__ < 130
|
||||
int index = (c.r / 4 * 64 + c.g / 4) * 64 + c.b / 4;
|
||||
float tx = mod(index, 512) / 512.0;
|
||||
float ty = float(index / 512) / 512.0;
|
||||
return texture2D(PaletteLUT, vec2(tx, ty)).rgb;
|
||||
#else
|
||||
int index = ((c.r >> 2) * 64 + (c.g >> 2)) * 64 + (c.b >> 2);
|
||||
int tx = index % 512;
|
||||
int ty = index / 512;
|
||||
return texelFetch(PaletteLUT, ivec2(tx, ty), 0).rgb;
|
||||
#endif
|
||||
}
|
||||
|
||||
#else
|
||||
#error "Tonemap mode define is missing"
|
||||
#endif
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 color = texture(InputTexture, TexCoord).rgb;
|
||||
#ifndef PALETTE
|
||||
color = color * ExposureAdjustment;
|
||||
color = Linear(color); // needed because gzdoom's scene texture is not linear at the moment
|
||||
#endif
|
||||
FragColor = vec4(Tonemap(color), 1.0);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue