mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-13 07:57:52 +00:00
- moved uViewHeight and uCameraPos to the viewpoint uniform struct.
This commit is contained in:
parent
9486180843
commit
43e1a2d249
12 changed files with 57 additions and 53 deletions
|
@ -468,8 +468,8 @@ void FGLRenderer::Draw2D(F2DDrawer *drawer)
|
||||||
glViewport(mScreenViewport.left, mScreenViewport.top, mScreenViewport.width, mScreenViewport.height);
|
glViewport(mScreenViewport.left, mScreenViewport.top, mScreenViewport.width, mScreenViewport.height);
|
||||||
|
|
||||||
HWViewpointUniforms matrices;
|
HWViewpointUniforms matrices;
|
||||||
|
matrices.SetDefaults();
|
||||||
matrices.mProjectionMatrix.ortho(0, screen->GetWidth(), screen->GetHeight(), 0, -1.0f, 1.0f);
|
matrices.mProjectionMatrix.ortho(0, screen->GetWidth(), screen->GetHeight(), 0, -1.0f, 1.0f);
|
||||||
matrices.mViewMatrix.loadIdentity();
|
|
||||||
matrices.CalcDependencies();
|
matrices.CalcDependencies();
|
||||||
GLRenderer->mShaderManager->ApplyMatrices(&matrices, NORMAL_PASS);
|
GLRenderer->mShaderManager->ApplyMatrices(&matrices, NORMAL_PASS);
|
||||||
|
|
||||||
|
|
|
@ -96,7 +96,6 @@ void FRenderState::Reset()
|
||||||
mInterpolationFactor = 0.0f;
|
mInterpolationFactor = 0.0f;
|
||||||
|
|
||||||
mColor.Set(1.0f, 1.0f, 1.0f, 1.0f);
|
mColor.Set(1.0f, 1.0f, 1.0f, 1.0f);
|
||||||
mCameraPos.Set(0.0f, 0.0f, 0.0f, 0.0f);
|
|
||||||
mGlowTop.Set(0.0f, 0.0f, 0.0f, 0.0f);
|
mGlowTop.Set(0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
mGlowBottom.Set(0.0f, 0.0f, 0.0f, 0.0f);
|
mGlowBottom.Set(0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
mGlowTopPlane.Set(0.0f, 0.0f, 0.0f, 0.0f);
|
mGlowTopPlane.Set(0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
|
@ -163,7 +162,6 @@ bool FRenderState::ApplyShader()
|
||||||
activeShader->muPalLightLevels.Set(static_cast<int>(gl_bandedswlight) | (static_cast<int>(gl_fogmode) << 8));
|
activeShader->muPalLightLevels.Set(static_cast<int>(gl_bandedswlight) | (static_cast<int>(gl_fogmode) << 8));
|
||||||
activeShader->muGlobVis.Set(GLRenderer->mGlobVis / 32.0f);
|
activeShader->muGlobVis.Set(GLRenderer->mGlobVis / 32.0f);
|
||||||
activeShader->muTextureMode.Set(mTextureMode == TM_MODULATE && mTempTM == TM_OPAQUE ? TM_OPAQUE : mTextureMode);
|
activeShader->muTextureMode.Set(mTextureMode == TM_MODULATE && mTempTM == TM_OPAQUE ? TM_OPAQUE : mTextureMode);
|
||||||
activeShader->muCameraPos.Set(mCameraPos.vec);
|
|
||||||
activeShader->muLightParms.Set(mLightParms);
|
activeShader->muLightParms.Set(mLightParms);
|
||||||
activeShader->muFogColor.Set(mFogColor);
|
activeShader->muFogColor.Set(mFogColor);
|
||||||
activeShader->muObjectColor.Set(mObjectColor);
|
activeShader->muObjectColor.Set(mObjectColor);
|
||||||
|
@ -176,7 +174,6 @@ bool FRenderState::ApplyShader()
|
||||||
activeShader->muAlphaThreshold.Set(mAlphaThreshold);
|
activeShader->muAlphaThreshold.Set(mAlphaThreshold);
|
||||||
activeShader->muLightIndex.Set(-1);
|
activeShader->muLightIndex.Set(-1);
|
||||||
activeShader->muClipSplit.Set(mClipSplit);
|
activeShader->muClipSplit.Set(mClipSplit);
|
||||||
activeShader->muViewHeight.Set(viewheight);
|
|
||||||
activeShader->muSpecularMaterial.Set(mGlossiness, mSpecularLevel);
|
activeShader->muSpecularMaterial.Set(mGlossiness, mSpecularLevel);
|
||||||
|
|
||||||
if (mGlowEnabled)
|
if (mGlowEnabled)
|
||||||
|
|
|
@ -103,7 +103,6 @@ class FRenderState
|
||||||
FVertexBuffer *mVertexBuffer, *mCurrentVertexBuffer;
|
FVertexBuffer *mVertexBuffer, *mCurrentVertexBuffer;
|
||||||
FStateVec4 mNormal;
|
FStateVec4 mNormal;
|
||||||
FStateVec4 mColor;
|
FStateVec4 mColor;
|
||||||
FStateVec4 mCameraPos;
|
|
||||||
FStateVec4 mGlowTop, mGlowBottom;
|
FStateVec4 mGlowTop, mGlowBottom;
|
||||||
FStateVec4 mGlowTopPlane, mGlowBottomPlane;
|
FStateVec4 mGlowTopPlane, mGlowBottomPlane;
|
||||||
FStateVec4 mSplitTopPlane, mSplitBottomPlane;
|
FStateVec4 mSplitTopPlane, mSplitBottomPlane;
|
||||||
|
@ -344,11 +343,6 @@ public:
|
||||||
mTextureMatrixEnabled = on;
|
mTextureMatrixEnabled = on;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetCameraPos(float x, float y, float z)
|
|
||||||
{
|
|
||||||
mCameraPos.Set(x, z, y, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetGlowParams(float *t, float *b)
|
void SetGlowParams(float *t, float *b)
|
||||||
{
|
{
|
||||||
mGlowTop.Set(t[0], t[1], t[2], t[3]);
|
mGlowTop.Set(t[0], t[1], t[2], t[3]);
|
||||||
|
|
|
@ -44,6 +44,17 @@
|
||||||
#include "gl/renderer/gl_quaddrawer.h"
|
#include "gl/renderer/gl_quaddrawer.h"
|
||||||
#include "gl/dynlights/gl_lightbuffer.h"
|
#include "gl/dynlights/gl_lightbuffer.h"
|
||||||
|
|
||||||
|
class FDrawInfoList
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
TDeletingArray<FDrawInfo *> mList;
|
||||||
|
|
||||||
|
|
||||||
|
FDrawInfo * GetNew();
|
||||||
|
void Release(FDrawInfo *);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
static FDrawInfo * gl_drawinfo;
|
static FDrawInfo * gl_drawinfo;
|
||||||
FDrawInfoList di_list;
|
FDrawInfoList di_list;
|
||||||
|
|
||||||
|
@ -228,11 +239,10 @@ void FDrawInfo::StartScene()
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
FDrawInfo *FDrawInfo::EndDrawInfo()
|
FDrawInfo *FDrawInfo::EndDrawInfo()
|
||||||
{
|
{
|
||||||
FDrawInfo * di = gl_drawinfo;
|
assert(this == gl_drawinfo);
|
||||||
|
for(int i=0;i<GLDL_TYPES;i++) drawlists[i].Reset();
|
||||||
for(int i=0;i<GLDL_TYPES;i++) di->drawlists[i].Reset();
|
gl_drawinfo=next;
|
||||||
gl_drawinfo=di->next;
|
di_list.Release(this);
|
||||||
di_list.Release(di);
|
|
||||||
if (gl_drawinfo == nullptr)
|
if (gl_drawinfo == nullptr)
|
||||||
ResetRenderDataAllocator();
|
ResetRenderDataAllocator();
|
||||||
return gl_drawinfo;
|
return gl_drawinfo;
|
||||||
|
|
|
@ -114,7 +114,7 @@ struct FDrawInfo : public HWDrawInfo
|
||||||
|
|
||||||
// These should go into hwrenderer later.
|
// These should go into hwrenderer later.
|
||||||
void SetViewMatrix(const FRotator &angles, float vx, float vy, float vz, bool mirror, bool planemirror);
|
void SetViewMatrix(const FRotator &angles, float vx, float vy, float vz, bool mirror, bool planemirror);
|
||||||
void SetupView(FRenderViewpoint &vp, float vx, float vy, float vz, DAngle va, bool mirror, bool planemirror);
|
void SetupView(float vx, float vy, float vz, DAngle va, bool mirror, bool planemirror);
|
||||||
|
|
||||||
|
|
||||||
static FDrawInfo *StartDrawInfo(FRenderViewpoint &parentvp, HWViewpointUniforms *uniforms);
|
static FDrawInfo *StartDrawInfo(FRenderViewpoint &parentvp, HWViewpointUniforms *uniforms);
|
||||||
|
@ -144,16 +144,6 @@ struct FDrawInfo : public HWDrawInfo
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class FDrawInfoList
|
|
||||||
{
|
|
||||||
TDeletingArray<FDrawInfo *> mList;
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
FDrawInfo *GetNew();
|
|
||||||
void Release(FDrawInfo *);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
void gl_SetRenderStyle(FRenderStyle style, bool drawopaque, bool allowcolorblending);
|
void gl_SetRenderStyle(FRenderStyle style, bool drawopaque, bool allowcolorblending);
|
||||||
|
|
||||||
|
|
|
@ -158,7 +158,6 @@ bool GLPortal::Start(bool usestencil, bool doquery, FDrawInfo *outer_di, FDrawIn
|
||||||
rendered_portals++;
|
rendered_portals++;
|
||||||
Clocker c(PortalAll);
|
Clocker c(PortalAll);
|
||||||
|
|
||||||
*pDi = FDrawInfo::StartDrawInfo(outer_di->Viewpoint, &outer_di->VPUniforms);
|
|
||||||
if (usestencil)
|
if (usestencil)
|
||||||
{
|
{
|
||||||
if (!gl_portals)
|
if (!gl_portals)
|
||||||
|
@ -254,6 +253,7 @@ bool GLPortal::Start(bool usestencil, bool doquery, FDrawInfo *outer_di, FDrawIn
|
||||||
glDisable(GL_DEPTH_TEST);
|
glDisable(GL_DEPTH_TEST);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*pDi = FDrawInfo::StartDrawInfo(outer_di->Viewpoint, &outer_di->VPUniforms);
|
||||||
|
|
||||||
// save viewpoint
|
// save viewpoint
|
||||||
savedvisibility = outer_di->Viewpoint.camera ? outer_di->Viewpoint.camera->renderflags & RF_MAYBEINVISIBLE : ActorRenderFlags::FromInt(0);
|
savedvisibility = outer_di->Viewpoint.camera ? outer_di->Viewpoint.camera->renderflags & RF_MAYBEINVISIBLE : ActorRenderFlags::FromInt(0);
|
||||||
|
@ -316,7 +316,7 @@ void GLPortal::End(FDrawInfo *di, bool usestencil)
|
||||||
|
|
||||||
// Restore the old view
|
// Restore the old view
|
||||||
if (vp.camera != nullptr) vp.camera->renderflags = (vp.camera->renderflags & ~RF_MAYBEINVISIBLE) | savedvisibility;
|
if (vp.camera != nullptr) vp.camera->renderflags = (vp.camera->renderflags & ~RF_MAYBEINVISIBLE) | savedvisibility;
|
||||||
di->SetupView(vp, vp.Pos.X, vp.Pos.Y, vp.Pos.Z, vp.Angles.Yaw, !!(MirrorFlag & 1), !!(PlaneMirrorFlag & 1));
|
di->SetupView(vp.Pos.X, vp.Pos.Y, vp.Pos.Z, vp.Angles.Yaw, !!(MirrorFlag & 1), !!(PlaneMirrorFlag & 1));
|
||||||
|
|
||||||
{
|
{
|
||||||
ScopedColorMask colorMask(0, 0, 0, 0); // glColorMask(0, 0, 0, 0); // no graphics
|
ScopedColorMask colorMask(0, 0, 0, 0); // glColorMask(0, 0, 0, 0); // no graphics
|
||||||
|
@ -370,7 +370,7 @@ void GLPortal::End(FDrawInfo *di, bool usestencil)
|
||||||
|
|
||||||
// Restore the old view
|
// Restore the old view
|
||||||
if (vp.camera != nullptr) vp.camera->renderflags = (vp.camera->renderflags & ~RF_MAYBEINVISIBLE) | savedvisibility;
|
if (vp.camera != nullptr) vp.camera->renderflags = (vp.camera->renderflags & ~RF_MAYBEINVISIBLE) | savedvisibility;
|
||||||
di->SetupView(vp, vp.Pos.X, vp.Pos.Y, vp.Pos.Z, vp.Angles.Yaw, !!(MirrorFlag & 1), !!(PlaneMirrorFlag & 1));
|
di->SetupView(vp.Pos.X, vp.Pos.Y, vp.Pos.Z, vp.Angles.Yaw, !!(MirrorFlag & 1), !!(PlaneMirrorFlag & 1));
|
||||||
|
|
||||||
// This draws a valid z-buffer into the stencil's contents to ensure it
|
// This draws a valid z-buffer into the stencil's contents to ensure it
|
||||||
// doesn't get overwritten by the level's geometry.
|
// doesn't get overwritten by the level's geometry.
|
||||||
|
@ -577,7 +577,7 @@ void GLSkyboxPortal::DrawContents(FDrawInfo *di)
|
||||||
vp.ViewActor = origin;
|
vp.ViewActor = origin;
|
||||||
|
|
||||||
inskybox = true;
|
inskybox = true;
|
||||||
di->SetupView(vp, vp.Pos.X, vp.Pos.Y, vp.Pos.Z, vp.Angles.Yaw, !!(MirrorFlag & 1), !!(PlaneMirrorFlag & 1));
|
di->SetupView(vp.Pos.X, vp.Pos.Y, vp.Pos.Z, vp.Angles.Yaw, !!(MirrorFlag & 1), !!(PlaneMirrorFlag & 1));
|
||||||
di->SetViewArea();
|
di->SetViewArea();
|
||||||
ClearClipper(di);
|
ClearClipper(di);
|
||||||
|
|
||||||
|
@ -684,7 +684,7 @@ void GLSectorStackPortal::DrawContents(FDrawInfo *di)
|
||||||
// avoid recursions!
|
// avoid recursions!
|
||||||
if (origin->plane != -1) screen->instack[origin->plane]++;
|
if (origin->plane != -1) screen->instack[origin->plane]++;
|
||||||
|
|
||||||
di->SetupView(vp, vp.Pos.X, vp.Pos.Y, vp.Pos.Z, vp.Angles.Yaw, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1));
|
di->SetupView(vp.Pos.X, vp.Pos.Y, vp.Pos.Z, vp.Angles.Yaw, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1));
|
||||||
SetupCoverage(di);
|
SetupCoverage(di);
|
||||||
ClearClipper(di);
|
ClearClipper(di);
|
||||||
|
|
||||||
|
@ -740,7 +740,7 @@ void GLPlaneMirrorPortal::DrawContents(FDrawInfo *di)
|
||||||
PlaneMirrorMode = origin->fC() < 0 ? -1 : 1;
|
PlaneMirrorMode = origin->fC() < 0 ? -1 : 1;
|
||||||
|
|
||||||
PlaneMirrorFlag++;
|
PlaneMirrorFlag++;
|
||||||
di->SetupView(vp, vp.Pos.X, vp.Pos.Y, vp.Pos.Z, vp.Angles.Yaw, !!(MirrorFlag & 1), !!(PlaneMirrorFlag & 1));
|
di->SetupView(vp.Pos.X, vp.Pos.Y, vp.Pos.Z, vp.Angles.Yaw, !!(MirrorFlag & 1), !!(PlaneMirrorFlag & 1));
|
||||||
ClearClipper(di);
|
ClearClipper(di);
|
||||||
|
|
||||||
di->UpdateCurrentMapSection();
|
di->UpdateCurrentMapSection();
|
||||||
|
@ -911,7 +911,7 @@ void GLMirrorPortal::DrawContents(FDrawInfo *di)
|
||||||
vp.ViewActor = nullptr;
|
vp.ViewActor = nullptr;
|
||||||
|
|
||||||
MirrorFlag++;
|
MirrorFlag++;
|
||||||
di->SetupView(vp, vp.Pos.X, vp.Pos.Y, vp.Pos.Z, vp.Angles.Yaw, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1));
|
di->SetupView(vp.Pos.X, vp.Pos.Y, vp.Pos.Z, vp.Angles.Yaw, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1));
|
||||||
|
|
||||||
di->mClipper->Clear();
|
di->mClipper->Clear();
|
||||||
|
|
||||||
|
@ -988,7 +988,7 @@ void GLLineToLinePortal::DrawContents(FDrawInfo *di)
|
||||||
}
|
}
|
||||||
|
|
||||||
vp.ViewActor = nullptr;
|
vp.ViewActor = nullptr;
|
||||||
di->SetupView(vp, vp.Pos.X, vp.Pos.Y, vp.Pos.Z, vp.Angles.Yaw, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1));
|
di->SetupView(vp.Pos.X, vp.Pos.Y, vp.Pos.Z, vp.Angles.Yaw, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1));
|
||||||
|
|
||||||
ClearClipper(di);
|
ClearClipper(di);
|
||||||
gl_RenderState.SetClipLine(glport->lines[0]->mDestination);
|
gl_RenderState.SetClipLine(glport->lines[0]->mDestination);
|
||||||
|
@ -1104,7 +1104,7 @@ void GLHorizonPortal::DrawContents(FDrawInfo *di)
|
||||||
ClearScreen(di);
|
ClearScreen(di);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
gl_RenderState.SetCameraPos(vp.Pos.X, vp.Pos.Y, vp.Pos.Z);
|
di->SetCameraPos(vp.Pos);
|
||||||
|
|
||||||
|
|
||||||
if (gltexture && gltexture->tex->isFullbright())
|
if (gltexture && gltexture->tex->isFullbright())
|
||||||
|
|
|
@ -104,10 +104,12 @@ void FDrawInfo::SetViewMatrix(const FRotator &angles, float vx, float vy, float
|
||||||
// Setup the view rotation matrix for the given viewpoint
|
// Setup the view rotation matrix for the given viewpoint
|
||||||
//
|
//
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void FDrawInfo::SetupView(FRenderViewpoint &vp, float vx, float vy, float vz, DAngle va, bool mirror, bool planemirror)
|
void FDrawInfo::SetupView(float vx, float vy, float vz, DAngle va, bool mirror, bool planemirror)
|
||||||
{
|
{
|
||||||
|
auto &vp = Viewpoint;
|
||||||
vp.SetViewAngle(r_viewwindow);
|
vp.SetViewAngle(r_viewwindow);
|
||||||
SetViewMatrix(vp.HWAngles, vx, vy, vz, mirror, planemirror);
|
SetViewMatrix(vp.HWAngles, vx, vy, vz, mirror, planemirror);
|
||||||
|
SetCameraPos(vp.Pos);
|
||||||
ApplyVPUniforms();
|
ApplyVPUniforms();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -182,8 +184,6 @@ void FDrawInfo::RenderScene(int recursion)
|
||||||
glDepthMask(true);
|
glDepthMask(true);
|
||||||
if (!gl_no_skyclear) GLPortal::RenderFirstSkyPortal(recursion, this);
|
if (!gl_no_skyclear) GLPortal::RenderFirstSkyPortal(recursion, this);
|
||||||
|
|
||||||
gl_RenderState.SetCameraPos(vp.Pos.X, vp.Pos.Y, vp.Pos.Z);
|
|
||||||
|
|
||||||
gl_RenderState.EnableFog(true);
|
gl_RenderState.EnableFog(true);
|
||||||
gl_RenderState.BlendFunc(GL_ONE,GL_ZERO);
|
gl_RenderState.BlendFunc(GL_ONE,GL_ZERO);
|
||||||
|
|
||||||
|
@ -287,12 +287,8 @@ void FDrawInfo::RenderScene(int recursion)
|
||||||
|
|
||||||
void FDrawInfo::RenderTranslucent()
|
void FDrawInfo::RenderTranslucent()
|
||||||
{
|
{
|
||||||
const auto &vp = Viewpoint;
|
|
||||||
|
|
||||||
RenderAll.Clock();
|
RenderAll.Clock();
|
||||||
|
|
||||||
gl_RenderState.SetCameraPos(vp.Pos.X, vp.Pos.Y, vp.Pos.Z);
|
|
||||||
|
|
||||||
// final pass: translucent stuff
|
// final pass: translucent stuff
|
||||||
gl_RenderState.AlphaFunc(GL_GEQUAL, gl_mask_sprite_threshold);
|
gl_RenderState.AlphaFunc(GL_GEQUAL, gl_mask_sprite_threshold);
|
||||||
gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
|
|
@ -230,7 +230,7 @@ void GLSkyPortal::DrawContents(FDrawInfo *di)
|
||||||
gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
bool oldClamp = gl_RenderState.SetDepthClamp(true);
|
bool oldClamp = gl_RenderState.SetDepthClamp(true);
|
||||||
|
|
||||||
di->SetupView(vp, 0, 0, 0, vp.Angles.Yaw, !!(MirrorFlag & 1), !!(PlaneMirrorFlag & 1));
|
di->SetupView(0, 0, 0, vp.Angles.Yaw, !!(MirrorFlag & 1), !!(PlaneMirrorFlag & 1));
|
||||||
|
|
||||||
gl_RenderState.SetVertexBuffer(GLRenderer->mSkyVBO);
|
gl_RenderState.SetVertexBuffer(GLRenderer->mSkyVBO);
|
||||||
if (origin->texture[0] && origin->texture[0]->tex->bSkybox)
|
if (origin->texture[0] && origin->texture[0]->tex->bSkybox)
|
||||||
|
|
|
@ -311,7 +311,6 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char *
|
||||||
muPalLightLevels.Init(hShader, "uPalLightLevels");
|
muPalLightLevels.Init(hShader, "uPalLightLevels");
|
||||||
muGlobVis.Init(hShader, "uGlobVis");
|
muGlobVis.Init(hShader, "uGlobVis");
|
||||||
muTextureMode.Init(hShader, "uTextureMode");
|
muTextureMode.Init(hShader, "uTextureMode");
|
||||||
muCameraPos.Init(hShader, "uCameraPos");
|
|
||||||
muLightParms.Init(hShader, "uLightAttr");
|
muLightParms.Init(hShader, "uLightAttr");
|
||||||
muClipSplit.Init(hShader, "uClipSplit");
|
muClipSplit.Init(hShader, "uClipSplit");
|
||||||
muLightIndex.Init(hShader, "uLightIndex");
|
muLightIndex.Init(hShader, "uLightIndex");
|
||||||
|
@ -331,7 +330,6 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char *
|
||||||
muClipHeightDirection.Init(hShader, "uClipHeightDirection");
|
muClipHeightDirection.Init(hShader, "uClipHeightDirection");
|
||||||
muAlphaThreshold.Init(hShader, "uAlphaThreshold");
|
muAlphaThreshold.Init(hShader, "uAlphaThreshold");
|
||||||
muSpecularMaterial.Init(hShader, "uSpecularMaterial");
|
muSpecularMaterial.Init(hShader, "uSpecularMaterial");
|
||||||
muViewHeight.Init(hShader, "uViewHeight");
|
|
||||||
muTimer.Init(hShader, "timer");
|
muTimer.Init(hShader, "timer");
|
||||||
|
|
||||||
lights_index = glGetUniformLocation(hShader, "lights");
|
lights_index = glGetUniformLocation(hShader, "lights");
|
||||||
|
@ -345,6 +343,8 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char *
|
||||||
normalviewmatrix_index = glGetUniformLocation(hShader, "NormalViewMatrix");
|
normalviewmatrix_index = glGetUniformLocation(hShader, "NormalViewMatrix");
|
||||||
normalmodelmatrix_index = glGetUniformLocation(hShader, "NormalModelMatrix");
|
normalmodelmatrix_index = glGetUniformLocation(hShader, "NormalModelMatrix");
|
||||||
quadmode_index = glGetUniformLocation(hShader, "uQuadMode");
|
quadmode_index = glGetUniformLocation(hShader, "uQuadMode");
|
||||||
|
viewheight_index = glGetUniformLocation(hShader, "uViewHeight");
|
||||||
|
camerapos_index = glGetUniformLocation(hShader, "uCameraPos");
|
||||||
|
|
||||||
if (!(gl.flags & RFL_SHADER_STORAGE_BUFFER))
|
if (!(gl.flags & RFL_SHADER_STORAGE_BUFFER))
|
||||||
{
|
{
|
||||||
|
@ -441,6 +441,9 @@ void FShader::ApplyMatrices(HWViewpointUniforms *u)
|
||||||
glUniformMatrix4fv(projectionmatrix_index, 1, false, u->mProjectionMatrix.get());
|
glUniformMatrix4fv(projectionmatrix_index, 1, false, u->mProjectionMatrix.get());
|
||||||
glUniformMatrix4fv(viewmatrix_index, 1, false, u->mViewMatrix.get());
|
glUniformMatrix4fv(viewmatrix_index, 1, false, u->mViewMatrix.get());
|
||||||
glUniformMatrix4fv(normalviewmatrix_index, 1, false, u->mNormalViewMatrix.get());
|
glUniformMatrix4fv(normalviewmatrix_index, 1, false, u->mNormalViewMatrix.get());
|
||||||
|
|
||||||
|
glUniform4fv(camerapos_index, 1, &u->mCameraPos[0]);
|
||||||
|
glUniform1i(viewheight_index, u->mViewHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
|
@ -246,7 +246,6 @@ class FShader
|
||||||
FBufferedUniform1i muPalLightLevels;
|
FBufferedUniform1i muPalLightLevels;
|
||||||
FBufferedUniform1f muGlobVis;
|
FBufferedUniform1f muGlobVis;
|
||||||
FBufferedUniform1i muTextureMode;
|
FBufferedUniform1i muTextureMode;
|
||||||
FBufferedUniform4f muCameraPos;
|
|
||||||
FBufferedUniform4f muLightParms;
|
FBufferedUniform4f muLightParms;
|
||||||
FBufferedUniform2f muClipSplit;
|
FBufferedUniform2f muClipSplit;
|
||||||
FBufferedUniform1i muLightIndex;
|
FBufferedUniform1i muLightIndex;
|
||||||
|
@ -265,17 +264,20 @@ class FShader
|
||||||
FBufferedUniform1f muClipHeight;
|
FBufferedUniform1f muClipHeight;
|
||||||
FBufferedUniform1f muClipHeightDirection;
|
FBufferedUniform1f muClipHeightDirection;
|
||||||
FBufferedUniform1f muAlphaThreshold;
|
FBufferedUniform1f muAlphaThreshold;
|
||||||
FBufferedUniform1i muViewHeight;
|
|
||||||
FBufferedUniform2f muSpecularMaterial;
|
FBufferedUniform2f muSpecularMaterial;
|
||||||
FBufferedUniform1f muTimer;
|
FBufferedUniform1f muTimer;
|
||||||
|
|
||||||
int lights_index;
|
int lights_index;
|
||||||
int projectionmatrix_index;
|
|
||||||
int viewmatrix_index;
|
|
||||||
int normalviewmatrix_index;
|
|
||||||
int modelmatrix_index;
|
int modelmatrix_index;
|
||||||
int normalmodelmatrix_index;
|
int normalmodelmatrix_index;
|
||||||
int texturematrix_index;
|
int texturematrix_index;
|
||||||
|
|
||||||
|
int projectionmatrix_index;
|
||||||
|
int viewmatrix_index;
|
||||||
|
int normalviewmatrix_index;
|
||||||
|
int viewheight_index;
|
||||||
|
int camerapos_index;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
int vertexmatrix_index;
|
int vertexmatrix_index;
|
||||||
int texcoordmatrix_index;
|
int texcoordmatrix_index;
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
|
#include "vectors.h"
|
||||||
#include "r_defs.h"
|
#include "r_defs.h"
|
||||||
#include "r_utility.h"
|
#include "r_utility.h"
|
||||||
#include "hw_viewpointuniforms.h"
|
#include "hw_viewpointuniforms.h"
|
||||||
|
@ -151,6 +152,12 @@ private:
|
||||||
void RenderThings(subsector_t * sub, sector_t * sector);
|
void RenderThings(subsector_t * sub, sector_t * sector);
|
||||||
void DoSubsector(subsector_t * sub);
|
void DoSubsector(subsector_t * sub);
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
void SetCameraPos(const DVector3 &pos)
|
||||||
|
{
|
||||||
|
VPUniforms.mCameraPos = { (float)pos.X, (float)pos.Z, (float)pos.Y, 0.f };
|
||||||
|
}
|
||||||
|
|
||||||
void RenderBSPNode(void *node);
|
void RenderBSPNode(void *node);
|
||||||
|
|
||||||
void ClearBuffers();
|
void ClearBuffers();
|
||||||
|
|
|
@ -1,13 +1,17 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "r_data/matrix.h"
|
#include "r_data/matrix.h"
|
||||||
|
#include "r_utility.h"
|
||||||
|
|
||||||
struct HWViewpointUniforms
|
struct HWViewpointUniforms
|
||||||
{
|
{
|
||||||
VSMatrix mProjectionMatrix;
|
VSMatrix mProjectionMatrix;
|
||||||
VSMatrix mViewMatrix;
|
VSMatrix mViewMatrix;
|
||||||
VSMatrix mNormalViewMatrix;
|
VSMatrix mNormalViewMatrix;
|
||||||
|
FVector4 mCameraPos;
|
||||||
|
FVector4 mClipLine;
|
||||||
|
|
||||||
|
int mViewHeight;
|
||||||
void CalcDependencies()
|
void CalcDependencies()
|
||||||
{
|
{
|
||||||
mNormalViewMatrix.computeNormalMatrix(mViewMatrix);
|
mNormalViewMatrix.computeNormalMatrix(mViewMatrix);
|
||||||
|
@ -18,6 +22,7 @@ struct HWViewpointUniforms
|
||||||
mProjectionMatrix.loadIdentity();
|
mProjectionMatrix.loadIdentity();
|
||||||
mViewMatrix.loadIdentity();
|
mViewMatrix.loadIdentity();
|
||||||
mNormalViewMatrix.loadIdentity();
|
mNormalViewMatrix.loadIdentity();
|
||||||
|
mViewHeight = viewheight;
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue