Skip to content

Commit

Permalink
- more uniforms moved.
Browse files Browse the repository at this point in the history
(not working yet.)
  • Loading branch information
coelckers committed Jun 22, 2018
1 parent 43e1a2d commit d5af939
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 22 deletions.
2 changes: 0 additions & 2 deletions src/gl/renderer/gl_renderer.h
Expand Up @@ -114,8 +114,6 @@ class FGLRenderer

float mSceneClearColor[3];

float mGlobVis = 0.0f;

FGLRenderer(OpenGLFrameBuffer *fb);
~FGLRenderer() ;

Expand Down
3 changes: 0 additions & 3 deletions src/gl/renderer/gl_renderstate.cpp
Expand Up @@ -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);
Expand Down Expand Up @@ -159,8 +158,6 @@ bool FRenderState::ApplyShader()

activeShader->muDesaturation.Set(mDesaturation / 255.f);
activeShader->muFogEnabled.Set(fogset);
activeShader->muPalLightLevels.Set(static_cast<int>(gl_bandedswlight) | (static_cast<int>(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);
Expand Down
2 changes: 0 additions & 2 deletions src/gl/scene/gl_scene.cpp
Expand Up @@ -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();
Expand Down
6 changes: 4 additions & 2 deletions src/gl/shaders/gl_shader.cpp
Expand Up @@ -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");
Expand Down Expand Up @@ -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))
{
Expand Down Expand Up @@ -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);
}

//==========================================================================
Expand Down
4 changes: 2 additions & 2 deletions src/gl/shaders/gl_shader.h
Expand Up @@ -243,8 +243,6 @@ class FShader

FBufferedUniform1f muDesaturation;
FBufferedUniform1i muFogEnabled;
FBufferedUniform1i muPalLightLevels;
FBufferedUniform1f muGlobVis;
FBufferedUniform1i muTextureMode;
FBufferedUniform4f muLightParms;
FBufferedUniform2f muClipSplit;
Expand Down Expand Up @@ -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;
Expand Down
19 changes: 19 additions & 0 deletions src/hwrenderer/scene/hw_drawinfo.cpp
Expand Up @@ -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);

//==========================================================================
Expand Down Expand Up @@ -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<int>(gl_bandedswlight) | (static_cast<int>(gl_fogmode) << 8);

}
19 changes: 8 additions & 11 deletions src/hwrenderer/scene/hw_viewpointuniforms.h
Expand Up @@ -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();

};

0 comments on commit d5af939

Please sign in to comment.