mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-11 15:21:51 +00:00
- mirror clip planes moved - not working yet.
This commit is contained in:
parent
e7531bb579
commit
80a9028938
9 changed files with 30 additions and 49 deletions
|
@ -80,8 +80,6 @@ void FRenderState::Reset()
|
||||||
mLightParms[0] = mLightParms[1] = mLightParms[2] = 0.0f;
|
mLightParms[0] = mLightParms[1] = mLightParms[2] = 0.0f;
|
||||||
mLightParms[3] = -1.f;
|
mLightParms[3] = -1.f;
|
||||||
mSpecialEffect = EFF_NONE;
|
mSpecialEffect = EFF_NONE;
|
||||||
mClipHeight = 0.f;
|
|
||||||
mClipHeightDirection = 0.f;
|
|
||||||
mGlossiness = 0.0f;
|
mGlossiness = 0.0f;
|
||||||
mSpecularLevel = 0.0f;
|
mSpecularLevel = 0.0f;
|
||||||
mShaderTimer = 0.0f;
|
mShaderTimer = 0.0f;
|
||||||
|
@ -165,8 +163,6 @@ bool FRenderState::ApplyShader()
|
||||||
activeShader->muObjectColor2.Set(mObjectColor2);
|
activeShader->muObjectColor2.Set(mObjectColor2);
|
||||||
activeShader->muDynLightColor.Set(mDynColor.vec);
|
activeShader->muDynLightColor.Set(mDynColor.vec);
|
||||||
activeShader->muInterpolationFactor.Set(mInterpolationFactor);
|
activeShader->muInterpolationFactor.Set(mInterpolationFactor);
|
||||||
activeShader->muClipHeight.Set(mClipHeight);
|
|
||||||
activeShader->muClipHeightDirection.Set(mClipHeightDirection);
|
|
||||||
activeShader->muTimer.Set((double)(screen->FrameTime - firstFrame) * (double)mShaderTimer / 1000.);
|
activeShader->muTimer.Set((double)(screen->FrameTime - firstFrame) * (double)mShaderTimer / 1000.);
|
||||||
activeShader->muAlphaThreshold.Set(mAlphaThreshold);
|
activeShader->muAlphaThreshold.Set(mAlphaThreshold);
|
||||||
activeShader->muLightIndex.Set(-1);
|
activeShader->muLightIndex.Set(-1);
|
||||||
|
@ -304,20 +300,3 @@ void FRenderState::ApplyLightIndex(int index)
|
||||||
}
|
}
|
||||||
activeShader->muLightIndex.Set(index);
|
activeShader->muLightIndex.Set(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FRenderState::SetClipHeight(float height, float direction)
|
|
||||||
{
|
|
||||||
mClipHeight = height;
|
|
||||||
mClipHeightDirection = direction;
|
|
||||||
|
|
||||||
if (gl.flags & RFL_NO_CLIP_PLANES) return;
|
|
||||||
|
|
||||||
if (direction != 0.f)
|
|
||||||
{
|
|
||||||
glEnable(GL_CLIP_DISTANCE0);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
glDisable(GL_CLIP_DISTANCE0); // GL_CLIP_PLANE0 is the same value so no need to make a distinction
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -196,8 +196,6 @@ public:
|
||||||
return mClipLineShouldBeActive;
|
return mClipLineShouldBeActive;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetClipHeight(float height, float direction);
|
|
||||||
|
|
||||||
void SetNormal(FVector3 norm)
|
void SetNormal(FVector3 norm)
|
||||||
{
|
{
|
||||||
mNormal.Set(norm.X, norm.Y, norm.Z, 0.f);
|
mNormal.Set(norm.X, norm.Y, norm.Z, 0.f);
|
||||||
|
|
|
@ -745,29 +745,13 @@ void GLPlaneMirrorPortal::DrawContents(FDrawInfo *di)
|
||||||
|
|
||||||
di->UpdateCurrentMapSection();
|
di->UpdateCurrentMapSection();
|
||||||
|
|
||||||
gl_RenderState.SetClipHeight(planez, PlaneMirrorMode < 0 ? -1.f : 1.f);
|
di->SetClipHeight(planez, PlaneMirrorMode < 0 ? -1.f : 1.f);
|
||||||
di->DrawScene(DM_PORTAL);
|
di->DrawScene(DM_PORTAL);
|
||||||
gl_RenderState.SetClipHeight(0.f, 0.f);
|
|
||||||
PlaneMirrorFlag--;
|
PlaneMirrorFlag--;
|
||||||
PlaneMirrorMode = old_pm;
|
PlaneMirrorMode = old_pm;
|
||||||
std::swap(screen->instack[sector_t::floor], screen->instack[sector_t::ceiling]);
|
std::swap(screen->instack[sector_t::floor], screen->instack[sector_t::ceiling]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLPlaneMirrorPortal::PushState()
|
|
||||||
{
|
|
||||||
planestack.Push(gl_RenderState.GetClipHeight());
|
|
||||||
planestack.Push(gl_RenderState.GetClipHeightDirection());
|
|
||||||
gl_RenderState.SetClipHeight(0.f, 0.f);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLPlaneMirrorPortal::PopState()
|
|
||||||
{
|
|
||||||
float d, f;
|
|
||||||
planestack.Pop(d);
|
|
||||||
planestack.Pop(f);
|
|
||||||
gl_RenderState.SetClipHeight(f, d);
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// Common code for line to line and mirror portals
|
// Common code for line to line and mirror portals
|
||||||
|
|
|
@ -302,8 +302,6 @@ protected:
|
||||||
virtual void DrawContents(FDrawInfo *di);
|
virtual void DrawContents(FDrawInfo *di);
|
||||||
virtual void * GetSource() const { return origin; }
|
virtual void * GetSource() const { return origin; }
|
||||||
virtual const char *GetName();
|
virtual const char *GetName();
|
||||||
virtual void PushState();
|
|
||||||
virtual void PopState();
|
|
||||||
secplane_t * origin;
|
secplane_t * origin;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -76,6 +76,18 @@ void FDrawInfo::ApplyVPUniforms()
|
||||||
{
|
{
|
||||||
VPUniforms.CalcDependencies();
|
VPUniforms.CalcDependencies();
|
||||||
GLRenderer->mShaderManager->ApplyMatrices(&VPUniforms, NORMAL_PASS);
|
GLRenderer->mShaderManager->ApplyMatrices(&VPUniforms, NORMAL_PASS);
|
||||||
|
|
||||||
|
if (!(gl.flags & RFL_NO_CLIP_PLANES))
|
||||||
|
{
|
||||||
|
if (VPUniforms.mClipHeightDirection != 0.f)
|
||||||
|
{
|
||||||
|
glEnable(GL_CLIP_DISTANCE0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
glDisable(GL_CLIP_DISTANCE0);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
|
@ -324,8 +324,6 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char *
|
||||||
muSplitTopPlane.Init(hShader, "uSplitTopPlane");
|
muSplitTopPlane.Init(hShader, "uSplitTopPlane");
|
||||||
muClipLine.Init(hShader, "uClipLine");
|
muClipLine.Init(hShader, "uClipLine");
|
||||||
muInterpolationFactor.Init(hShader, "uInterpolationFactor");
|
muInterpolationFactor.Init(hShader, "uInterpolationFactor");
|
||||||
muClipHeight.Init(hShader, "uClipHeight");
|
|
||||||
muClipHeightDirection.Init(hShader, "uClipHeightDirection");
|
|
||||||
muAlphaThreshold.Init(hShader, "uAlphaThreshold");
|
muAlphaThreshold.Init(hShader, "uAlphaThreshold");
|
||||||
muSpecularMaterial.Init(hShader, "uSpecularMaterial");
|
muSpecularMaterial.Init(hShader, "uSpecularMaterial");
|
||||||
muTimer.Init(hShader, "timer");
|
muTimer.Init(hShader, "timer");
|
||||||
|
@ -345,6 +343,8 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char *
|
||||||
camerapos_index = glGetUniformLocation(hShader, "uCameraPos");
|
camerapos_index = glGetUniformLocation(hShader, "uCameraPos");
|
||||||
pallightlevels_index = glGetUniformLocation(hShader, "uPalLightLevels");
|
pallightlevels_index = glGetUniformLocation(hShader, "uPalLightLevels");
|
||||||
globvis_index = glGetUniformLocation(hShader, "uGlobVis");
|
globvis_index = glGetUniformLocation(hShader, "uGlobVis");
|
||||||
|
clipheight_index = glGetUniformLocation(hShader, "uClipHeight");
|
||||||
|
clipheightdirection_index = glGetUniformLocation(hShader, "uClipHeightDirection");
|
||||||
|
|
||||||
if (!(gl.flags & RFL_SHADER_STORAGE_BUFFER))
|
if (!(gl.flags & RFL_SHADER_STORAGE_BUFFER))
|
||||||
{
|
{
|
||||||
|
@ -446,6 +446,8 @@ void FShader::ApplyMatrices(HWViewpointUniforms *u)
|
||||||
glUniform1i(viewheight_index, u->mViewHeight);
|
glUniform1i(viewheight_index, u->mViewHeight);
|
||||||
glUniform1i(pallightlevels_index, u->mPalLightLevels);
|
glUniform1i(pallightlevels_index, u->mPalLightLevels);
|
||||||
glUniform1f(globvis_index, u->mGlobVis);
|
glUniform1f(globvis_index, u->mGlobVis);
|
||||||
|
glUniform1f(clipheight_index, u->mClipHeight);
|
||||||
|
glUniform1f(clipheightdirection_index, u->mClipHeightDirection);
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
|
@ -259,8 +259,6 @@ class FShader
|
||||||
FUniform4f muSplitTopPlane;
|
FUniform4f muSplitTopPlane;
|
||||||
FUniform4f muClipLine;
|
FUniform4f muClipLine;
|
||||||
FBufferedUniform1f muInterpolationFactor;
|
FBufferedUniform1f muInterpolationFactor;
|
||||||
FBufferedUniform1f muClipHeight;
|
|
||||||
FBufferedUniform1f muClipHeightDirection;
|
|
||||||
FBufferedUniform1f muAlphaThreshold;
|
FBufferedUniform1f muAlphaThreshold;
|
||||||
FBufferedUniform2f muSpecularMaterial;
|
FBufferedUniform2f muSpecularMaterial;
|
||||||
FBufferedUniform1f muTimer;
|
FBufferedUniform1f muTimer;
|
||||||
|
@ -277,6 +275,8 @@ class FShader
|
||||||
int camerapos_index;
|
int camerapos_index;
|
||||||
int pallightlevels_index;
|
int pallightlevels_index;
|
||||||
int globvis_index;
|
int globvis_index;
|
||||||
|
int clipheight_index;
|
||||||
|
int clipheightdirection_index;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
int vertexmatrix_index;
|
int vertexmatrix_index;
|
||||||
|
|
|
@ -158,6 +158,12 @@ public:
|
||||||
VPUniforms.mCameraPos = { (float)pos.X, (float)pos.Z, (float)pos.Y, 0.f };
|
VPUniforms.mCameraPos = { (float)pos.X, (float)pos.Z, (float)pos.Y, 0.f };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetClipHeight(float h, float d)
|
||||||
|
{
|
||||||
|
VPUniforms.mClipHeight = h;
|
||||||
|
VPUniforms.mClipHeightDirection = d;
|
||||||
|
}
|
||||||
|
|
||||||
void RenderBSPNode(void *node);
|
void RenderBSPNode(void *node);
|
||||||
|
|
||||||
void ClearBuffers();
|
void ClearBuffers();
|
||||||
|
|
|
@ -11,9 +11,11 @@ struct HWViewpointUniforms
|
||||||
FVector4 mCameraPos;
|
FVector4 mCameraPos;
|
||||||
FVector4 mClipLine;
|
FVector4 mClipLine;
|
||||||
|
|
||||||
float mGlobVis;
|
float mGlobVis = 1.f;
|
||||||
int mPalLightLevels;
|
int mPalLightLevels = 0;
|
||||||
int mViewHeight;
|
int mViewHeight = 0;
|
||||||
|
float mClipHeight = 0.f;
|
||||||
|
float mClipHeightDirection = 0.f;
|
||||||
|
|
||||||
void CalcDependencies()
|
void CalcDependencies()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue