Merge branch 'shadowmaps' of https://github.com/raa-eruanna/qzdoom into 3.0_work
# Conflicts: # src/CMakeLists.txt # wadsrc/static/language.enu
This commit is contained in:
commit
9eae422dab
20 changed files with 994 additions and 5 deletions
|
|
@ -740,6 +740,49 @@ void FGLRenderBuffers::BindEyeFB(int eye, bool readBuffer)
|
|||
glBindFramebuffer(readBuffer ? GL_READ_FRAMEBUFFER : GL_FRAMEBUFFER, mEyeFBs[eye]);
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// Shadow map texture and frame buffers
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void FGLRenderBuffers::BindShadowMapFB()
|
||||
{
|
||||
CreateShadowMap();
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, mShadowMapFB);
|
||||
}
|
||||
|
||||
void FGLRenderBuffers::BindShadowMapTexture(int texunit)
|
||||
{
|
||||
CreateShadowMap();
|
||||
glActiveTexture(GL_TEXTURE0 + texunit);
|
||||
glBindTexture(GL_TEXTURE_2D, mShadowMapTexture);
|
||||
}
|
||||
|
||||
void FGLRenderBuffers::CreateShadowMap()
|
||||
{
|
||||
if (mShadowMapTexture != 0)
|
||||
return;
|
||||
|
||||
GLint activeTex, textureBinding, frameBufferBinding;
|
||||
glGetIntegerv(GL_ACTIVE_TEXTURE, &activeTex);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glGetIntegerv(GL_TEXTURE_BINDING_2D, &textureBinding);
|
||||
glGetIntegerv(GL_FRAMEBUFFER_BINDING, &frameBufferBinding);
|
||||
|
||||
mShadowMapTexture = Create2DTexture("ShadowMap", GL_R32F, 1024, 1024);
|
||||
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);
|
||||
|
||||
mShadowMapFB = CreateFrameBuffer("ShadowMapFB", mShadowMapTexture);
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, textureBinding);
|
||||
glActiveTexture(activeTex);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, frameBufferBinding);
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// Makes the scene frame buffer active (multisample, depth, stecil, etc.)
|
||||
|
|
|
|||
|
|
@ -49,6 +49,9 @@ public:
|
|||
void BindEyeTexture(int eye, int texunit);
|
||||
void BindEyeFB(int eye, bool readBuffer = false);
|
||||
|
||||
void BindShadowMapFB();
|
||||
void BindShadowMapTexture(int index);
|
||||
|
||||
enum { NumBloomLevels = 4 };
|
||||
FGLBloomTextureLevel BloomLevels[NumBloomLevels];
|
||||
|
||||
|
|
@ -89,6 +92,7 @@ private:
|
|||
void CreateBloom(int width, int height);
|
||||
void CreateExposureLevels(int width, int height);
|
||||
void CreateEyeBuffers(int eye);
|
||||
void CreateShadowMap();
|
||||
void CreateAmbientOcclusion(int width, int height);
|
||||
GLuint Create2DTexture(const FString &name, GLuint format, int width, int height, const void *data = nullptr);
|
||||
GLuint Create2DMultisampleTexture(const FString &name, GLuint format, int width, int height, int samples, bool fixedSampleLocations);
|
||||
|
|
@ -133,6 +137,10 @@ private:
|
|||
TArray<GLuint> mEyeTextures;
|
||||
TArray<GLuint> mEyeFBs;
|
||||
|
||||
// Shadow map texture
|
||||
GLuint mShadowMapTexture = 0;
|
||||
GLuint mShadowMapFB = 0;
|
||||
|
||||
static bool FailedCreate;
|
||||
static bool BuffersActive;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -60,6 +60,7 @@
|
|||
#include "gl/shaders/gl_fxaashader.h"
|
||||
#include "gl/shaders/gl_presentshader.h"
|
||||
#include "gl/shaders/gl_present3dRowshader.h"
|
||||
#include "gl/shaders/gl_shadowmapshader.h"
|
||||
#include "gl/stereo3d/gl_stereo3d.h"
|
||||
#include "gl/textures/gl_texture.h"
|
||||
#include "gl/textures/gl_translate.h"
|
||||
|
|
@ -125,6 +126,7 @@ FGLRenderer::FGLRenderer(OpenGLFrameBuffer *fb)
|
|||
mSSAOCombineShader = nullptr;
|
||||
mFXAAShader = nullptr;
|
||||
mFXAALumaShader = nullptr;
|
||||
mShadowMapShader = nullptr;
|
||||
}
|
||||
|
||||
void gl_LoadModels();
|
||||
|
|
@ -153,6 +155,7 @@ void FGLRenderer::Initialize(int width, int height)
|
|||
mPresent3dCheckerShader = new FPresent3DCheckerShader();
|
||||
mPresent3dColumnShader = new FPresent3DColumnShader();
|
||||
mPresent3dRowShader = new FPresent3DRowShader();
|
||||
mShadowMapShader = new FShadowMapShader();
|
||||
m2DDrawer = new F2DDrawer;
|
||||
|
||||
// needed for the core profile, because someone decided it was a good idea to remove the default VAO.
|
||||
|
|
@ -223,6 +226,7 @@ FGLRenderer::~FGLRenderer()
|
|||
if (mTonemapPalette) delete mTonemapPalette;
|
||||
if (mColormapShader) delete mColormapShader;
|
||||
if (mLensShader) delete mLensShader;
|
||||
if (mShadowMapShader) delete mShadowMapShader;
|
||||
delete mFXAAShader;
|
||||
delete mFXAALumaShader;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
#include "vectors.h"
|
||||
#include "r_renderer.h"
|
||||
#include "gl/data/gl_matrix.h"
|
||||
#include "gl/dynlights/gl_shadowmap.h"
|
||||
|
||||
struct particle_t;
|
||||
class FCanvasTexture;
|
||||
|
|
@ -40,6 +41,7 @@ class FPresent3DColumnShader;
|
|||
class FPresent3DRowShader;
|
||||
class F2DDrawer;
|
||||
class FHardwareTexture;
|
||||
class FShadowMapShader;
|
||||
|
||||
inline float DEG2RAD(float deg)
|
||||
{
|
||||
|
|
@ -122,6 +124,9 @@ public:
|
|||
FPresent3DCheckerShader *mPresent3dCheckerShader;
|
||||
FPresent3DColumnShader *mPresent3dColumnShader;
|
||||
FPresent3DRowShader *mPresent3dRowShader;
|
||||
FShadowMapShader *mShadowMapShader;
|
||||
|
||||
FShadowMap mShadowMap;
|
||||
|
||||
FTexture *gllight;
|
||||
FTexture *glpart2;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue