From d5af93911943ef4190a927e10bef52311ac2942d Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 22 Jun 2018 21:32:38 +0200 Subject: [PATCH] - more uniforms moved. (not working yet.) --- src/gl/renderer/gl_renderer.h | 2 -- src/gl/renderer/gl_renderstate.cpp | 3 --- src/gl/scene/gl_scene.cpp | 2 -- src/gl/shaders/gl_shader.cpp | 6 ++++-- src/gl/shaders/gl_shader.h | 4 ++-- src/hwrenderer/scene/hw_drawinfo.cpp | 19 +++++++++++++++++++ src/hwrenderer/scene/hw_viewpointuniforms.h | 19 ++++++++----------- 7 files changed, 33 insertions(+), 22 deletions(-) diff --git a/src/gl/renderer/gl_renderer.h b/src/gl/renderer/gl_renderer.h index 4cd28c730a..46c097ba1b 100644 --- a/src/gl/renderer/gl_renderer.h +++ b/src/gl/renderer/gl_renderer.h @@ -114,8 +114,6 @@ public: float mSceneClearColor[3]; - float mGlobVis = 0.0f; - FGLRenderer(OpenGLFrameBuffer *fb); ~FGLRenderer() ; diff --git a/src/gl/renderer/gl_renderstate.cpp b/src/gl/renderer/gl_renderstate.cpp index c830499fde..a692145d30 100644 --- a/src/gl/renderer/gl_renderstate.cpp +++ b/src/gl/renderer/gl_renderstate.cpp @@ -42,7 +42,6 @@ void gl_SetTextureMode(int type); FRenderState gl_RenderState; CVAR(Bool, gl_direct_state_change, true, 0) -CVAR(Bool, gl_bandedswlight, false, CVAR_ARCHIVE) static VSMatrix identityMatrix(1); @@ -159,8 +158,6 @@ bool FRenderState::ApplyShader() activeShader->muDesaturation.Set(mDesaturation / 255.f); activeShader->muFogEnabled.Set(fogset); - activeShader->muPalLightLevels.Set(static_cast(gl_bandedswlight) | (static_cast(gl_fogmode) << 8)); - activeShader->muGlobVis.Set(GLRenderer->mGlobVis / 32.0f); activeShader->muTextureMode.Set(mTextureMode == TM_MODULATE && mTempTM == TM_OPAQUE ? TM_OPAQUE : mTextureMode); activeShader->muLightParms.Set(mLightParms); activeShader->muFogColor.Set(mFogColor); diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 86cb361fbf..7db0911edd 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -487,8 +487,6 @@ sector_t * FGLRenderer::RenderViewpoint (FRenderViewpoint &mainvp, AActor * came { R_SetupFrame (mainvp, r_viewwindow, camera); - mGlobVis = R_GetGlobVis(r_viewwindow, r_visibility); - // Render (potentially) multiple views for stereo 3d float viewShift[3]; const s3d::Stereo3DMode& stereo3dMode = mainview && toscreen? s3d::Stereo3DMode::getCurrentMode() : s3d::Stereo3DMode::getMonoMode(); diff --git a/src/gl/shaders/gl_shader.cpp b/src/gl/shaders/gl_shader.cpp index d1ba1f8a66..953b31e909 100644 --- a/src/gl/shaders/gl_shader.cpp +++ b/src/gl/shaders/gl_shader.cpp @@ -308,8 +308,6 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * muDesaturation.Init(hShader, "uDesaturationFactor"); muFogEnabled.Init(hShader, "uFogEnabled"); - muPalLightLevels.Init(hShader, "uPalLightLevels"); - muGlobVis.Init(hShader, "uGlobVis"); muTextureMode.Init(hShader, "uTextureMode"); muLightParms.Init(hShader, "uLightAttr"); muClipSplit.Init(hShader, "uClipSplit"); @@ -345,6 +343,8 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * quadmode_index = glGetUniformLocation(hShader, "uQuadMode"); viewheight_index = glGetUniformLocation(hShader, "uViewHeight"); camerapos_index = glGetUniformLocation(hShader, "uCameraPos"); + pallightlevels_index = glGetUniformLocation(hShader, "uPalLightLevels"); + globvis_index = glGetUniformLocation(hShader, "uGlobVis"); if (!(gl.flags & RFL_SHADER_STORAGE_BUFFER)) { @@ -444,6 +444,8 @@ void FShader::ApplyMatrices(HWViewpointUniforms *u) glUniform4fv(camerapos_index, 1, &u->mCameraPos[0]); glUniform1i(viewheight_index, u->mViewHeight); + glUniform1i(pallightlevels_index, u->mPalLightLevels); + glUniform1f(globvis_index, u->mGlobVis); } //========================================================================== diff --git a/src/gl/shaders/gl_shader.h b/src/gl/shaders/gl_shader.h index 26d66fe286..9a0b52eb18 100644 --- a/src/gl/shaders/gl_shader.h +++ b/src/gl/shaders/gl_shader.h @@ -243,8 +243,6 @@ class FShader FBufferedUniform1f muDesaturation; FBufferedUniform1i muFogEnabled; - FBufferedUniform1i muPalLightLevels; - FBufferedUniform1f muGlobVis; FBufferedUniform1i muTextureMode; FBufferedUniform4f muLightParms; FBufferedUniform2f muClipSplit; @@ -277,6 +275,8 @@ class FShader int normalviewmatrix_index; int viewheight_index; int camerapos_index; + int pallightlevels_index; + int globvis_index; public: int vertexmatrix_index; diff --git a/src/hwrenderer/scene/hw_drawinfo.cpp b/src/hwrenderer/scene/hw_drawinfo.cpp index 75943691db..2f3936d87d 100644 --- a/src/hwrenderer/scene/hw_drawinfo.cpp +++ b/src/hwrenderer/scene/hw_drawinfo.cpp @@ -35,6 +35,9 @@ #include "hwrenderer/utility/hw_clock.h" #include "hwrenderer/utility/hw_cvars.h" +EXTERN_CVAR(Float, r_visibility) +CVAR(Bool, gl_bandedswlight, false, CVAR_ARCHIVE) + sector_t * hw_FakeFlat(sector_t * sec, sector_t * dest, area_t in_area, bool back); //========================================================================== @@ -211,3 +214,19 @@ angle_t HWDrawInfo::FrustumAngle() return a1; } +//----------------------------------------------------------------------------- +// +// +// +//----------------------------------------------------------------------------- + +void HWViewpointUniforms::SetDefaults() +{ + mProjectionMatrix.loadIdentity(); + mViewMatrix.loadIdentity(); + mNormalViewMatrix.loadIdentity(); + mViewHeight = viewheight; + mGlobVis = R_GetGlobVis(r_viewwindow, r_visibility) / 32.f; + mPalLightLevels = static_cast(gl_bandedswlight) | (static_cast(gl_fogmode) << 8); + +} diff --git a/src/hwrenderer/scene/hw_viewpointuniforms.h b/src/hwrenderer/scene/hw_viewpointuniforms.h index 7dc76317e6..2727fbd255 100644 --- a/src/hwrenderer/scene/hw_viewpointuniforms.h +++ b/src/hwrenderer/scene/hw_viewpointuniforms.h @@ -11,18 +11,15 @@ struct HWViewpointUniforms FVector4 mCameraPos; FVector4 mClipLine; + float mGlobVis; + int mPalLightLevels; int mViewHeight; - void CalcDependencies() - { - mNormalViewMatrix.computeNormalMatrix(mViewMatrix); - } - void SetDefaults() - { - mProjectionMatrix.loadIdentity(); - mViewMatrix.loadIdentity(); - mNormalViewMatrix.loadIdentity(); - mViewHeight = viewheight; - } + void CalcDependencies() + { + mNormalViewMatrix.computeNormalMatrix(mViewMatrix); + } + + void SetDefaults(); };