- move view and projection matrices to DrawInfo.

This commit is contained in:
Christoph Oelckers 2018-06-21 20:54:34 +02:00
parent b106f72741
commit 1967165633
27 changed files with 80 additions and 94 deletions

View file

@ -50,7 +50,7 @@ CVAR(Bool, gl_light_models, true, CVAR_ARCHIVE)
VSMatrix FGLModelRenderer::GetViewToWorldMatrix()
{
VSMatrix objectToWorldMatrix;
gl_RenderState.mViewMatrix.inverseMatrix(objectToWorldMatrix);
di->VPUniforms.mViewMatrix.inverseMatrix(objectToWorldMatrix);
return objectToWorldMatrix;
}

View file

@ -29,12 +29,14 @@
#include "r_data/models/models.h"
class GLSprite;
struct FDrawInfo;
class FGLModelRenderer : public FModelRenderer
{
int modellightindex = -1;
FDrawInfo *di;
public:
FGLModelRenderer(int mli) : modellightindex(mli)
FGLModelRenderer(FDrawInfo *d, int mli) : modellightindex(mli), di(d)
{}
ModelRendererType GetType() const override { return GLModelRendererType; }
void BeginDrawModel(AActor *actor, FSpriteModelFrame *smf, const VSMatrix &objectToWorldMatrix, bool mirrored) override;

View file

@ -2,7 +2,7 @@
#define __GL_LIGHTDATA
#include "v_palette.h"
#include "p_3dfloors.h"
#include "r_defs.h"
#include "r_data/renderstyle.h"
#include "hwrenderer/utility/hw_lighting.h"
#include "r_data/colormaps.h"

View file

@ -81,7 +81,7 @@ void FGLRenderer::PostProcessScene(int fixedcm, const std::function<void()> &aft
//
//-----------------------------------------------------------------------------
void FGLRenderer::AmbientOccludeScene()
void FGLRenderer::AmbientOccludeScene(float m5)
{
FGLDebug::PushGroup("AmbientOccludeScene");
@ -94,7 +94,7 @@ void FGLRenderer::AmbientOccludeScene()
float aoStrength = gl_ssao_strength;
//float tanHalfFovy = tan(fovy * (M_PI / 360.0f));
float tanHalfFovy = 1.0f / gl_RenderState.mProjectionMatrix.get()[5];
float tanHalfFovy = 1.0f / m5;
float invFocalLenX = tanHalfFovy * (mBuffers->GetSceneWidth() / (float)mBuffers->GetSceneHeight());
float invFocalLenY = tanHalfFovy;
float nDotVBias = clamp(bias, 0.0f, 1.0f);

View file

@ -467,9 +467,11 @@ void FGLRenderer::Draw2D(F2DDrawer *drawer)
const auto &mScreenViewport = screen->mScreenViewport;
glViewport(mScreenViewport.left, mScreenViewport.top, mScreenViewport.width, mScreenViewport.height);
gl_RenderState.mViewMatrix.loadIdentity();
gl_RenderState.mProjectionMatrix.ortho(0, screen->GetWidth(), screen->GetHeight(), 0, -1.0f, 1.0f);
gl_RenderState.ApplyMatrices();
HWViewpointUniforms matrices;
matrices.mProjectionMatrix.ortho(0, screen->GetWidth(), screen->GetHeight(), 0, -1.0f, 1.0f);
matrices.mViewMatrix.loadIdentity();
matrices.CalcDependencies();
GLRenderer->mShaderManager->ApplyMatrices(&matrices.mProjectionMatrix, &matrices.mViewMatrix, &matrices.mNormalViewMatrix, NORMAL_PASS);
glDisable(GL_DEPTH_TEST);

View file

@ -128,7 +128,7 @@ public:
void RenderScreenQuad();
void PostProcessScene(int fixedcm, const std::function<void()> &afterBloomDrawEndScene2D);
void AmbientOccludeScene();
void AmbientOccludeScene(float m5);
void UpdateCameraExposure();
void BloomScene(int fixedcm);
void TonemapScene();

View file

@ -107,8 +107,6 @@ void FRenderState::Reset()
mDynColor.Set(0.0f, 0.0f, 0.0f, 0.0f);
mEffectState = 0;
activeShader = nullptr;
mProjectionMatrix.loadIdentity();
mViewMatrix.loadIdentity();
mModelMatrix.loadIdentity();
mTextureMatrix.loadIdentity();
mPassType = NORMAL_PASS;
@ -304,17 +302,6 @@ void FRenderState::ApplyColorMask()
}
}
void FRenderState::ApplyMatrices()
{
if (GLRenderer->mShaderManager != NULL)
{
VSMatrix norm;
norm.computeNormalMatrix(mViewMatrix);
GLRenderer->mShaderManager->ApplyMatrices(&mProjectionMatrix, &mViewMatrix, &norm, mPassType);
}
}
void FRenderState::ApplyLightIndex(int index)
{
if (index > -1 && GLRenderer->mLights->GetBufferType() == GL_UNIFORM_BUFFER)

View file

@ -131,11 +131,8 @@ class FRenderState
public:
VSMatrix mProjectionMatrix;
VSMatrix mViewMatrix;
VSMatrix mModelMatrix;
VSMatrix mTextureMatrix;
VSMatrix mNormalViewMatrix;
FRenderState()
{
@ -162,7 +159,6 @@ public:
void Apply();
void ApplyColorMask();
void ApplyMatrices();
void ApplyLightIndex(int index);
void SetVertexBuffer(FVertexBuffer *vb)

View file

@ -190,12 +190,14 @@ FDrawInfo::~FDrawInfo()
// OpenGL has no use for multiple clippers so use the same one for all DrawInfos.
static Clipper staticClipper;
FDrawInfo *FDrawInfo::StartDrawInfo(FRenderViewpoint &parentvp)
FDrawInfo *FDrawInfo::StartDrawInfo(FRenderViewpoint &parentvp, HWViewpointUniforms *uniforms)
{
FDrawInfo *di=di_list.GetNew();
di->mVBO = GLRenderer->mVBO;
di->mClipper = &staticClipper;
di->Viewpoint = parentvp;
if (uniforms) di->VPUniforms = *uniforms;
else di->VPUniforms.SetDefaults();
di->mClipper->SetViewpoint(di->Viewpoint);
staticClipper.Clear();
di->StartScene();

View file

@ -4,6 +4,7 @@
#include "gl/renderer/gl_lightdata.h"
#include "hwrenderer/scene/hw_drawlist.h"
#include "hwrenderer/scene/hw_weapon.h"
#include "hwrenderer/scene/hw_viewpointuniforms.h"
#ifdef _MSC_VER
#pragma warning(disable:4244)
@ -42,6 +43,8 @@ struct FDrawInfo : public HWDrawInfo
FDrawInfo();
~FDrawInfo();
void ApplyVPUniforms() override;
void AddWall(GLWall *wall) override;
void AddMirrorSurface(GLWall *w) override;
GLDecal *AddDecal(bool onmirror) override;
@ -110,12 +113,11 @@ struct FDrawInfo : public HWDrawInfo
void DrawEndScene2D(sector_t * viewsector);
// These should go into hwrenderer later.
void SetProjection(VSMatrix matrix);
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);
static FDrawInfo *StartDrawInfo(FRenderViewpoint &parentvp);
static FDrawInfo *StartDrawInfo(FRenderViewpoint &parentvp, HWViewpointUniforms *uniforms);
FDrawInfo *EndDrawInfo();
gl_subsectorrendernode * GetOtherFloorPlanes(unsigned int sector)

View file

@ -93,15 +93,13 @@ void GLPortal::BeginScene()
//
//
//==========================================================================
void GLPortal::ClearScreen()
void GLPortal::ClearScreen(FDrawInfo *di)
{
bool multi = !!glIsEnabled(GL_MULTISAMPLE);
gl_MatrixStack.Push(gl_RenderState.mViewMatrix);
gl_MatrixStack.Push(gl_RenderState.mProjectionMatrix);
gl_RenderState.mViewMatrix.loadIdentity();
gl_RenderState.mProjectionMatrix.ortho(0, SCREENWIDTH, SCREENHEIGHT, 0, -1.0f, 1.0f);
gl_RenderState.ApplyMatrices();
di->VPUniforms.mViewMatrix.loadIdentity();
di->VPUniforms.mProjectionMatrix.ortho(0, SCREENWIDTH, SCREENHEIGHT, 0, -1.0f, 1.0f);
di->ApplyVPUniforms();
gl_RenderState.SetColor(0, 0, 0);
gl_RenderState.Apply();
@ -111,9 +109,6 @@ void GLPortal::ClearScreen()
glDrawArrays(GL_TRIANGLE_STRIP, FFlatVertexBuffer::FULLSCREEN_INDEX, 4);
glEnable(GL_DEPTH_TEST);
gl_MatrixStack.Pop(gl_RenderState.mProjectionMatrix);
gl_MatrixStack.Pop(gl_RenderState.mViewMatrix);
gl_RenderState.ApplyMatrices();
if (multi) glEnable(GL_MULTISAMPLE);
}
@ -162,6 +157,8 @@ bool GLPortal::Start(bool usestencil, bool doquery, FDrawInfo *outer_di, FDrawIn
*pDi = nullptr;
rendered_portals++;
Clocker c(PortalAll);
*pDi = FDrawInfo::StartDrawInfo(outer_di->Viewpoint, &outer_di->VPUniforms);
if (usestencil)
{
if (!gl_portals)
@ -226,7 +223,6 @@ bool GLPortal::Start(bool usestencil, bool doquery, FDrawInfo *outer_di, FDrawIn
return false;
}
}
*pDi = FDrawInfo::StartDrawInfo(outer_di->Viewpoint);
}
else
{
@ -244,7 +240,6 @@ bool GLPortal::Start(bool usestencil, bool doquery, FDrawInfo *outer_di, FDrawIn
gl_RenderState.SetEffect(EFF_NONE);
glDisable(GL_DEPTH_TEST);
glDepthMask(false); // don't write to Z-buffer!
*pDi = outer_di;
}
}
recursion++;
@ -253,15 +248,10 @@ bool GLPortal::Start(bool usestencil, bool doquery, FDrawInfo *outer_di, FDrawIn
}
else
{
if (NeedDepthBuffer())
{
*pDi = FDrawInfo::StartDrawInfo(outer_di->Viewpoint);
}
else
if (!NeedDepthBuffer())
{
glDepthMask(false);
glDisable(GL_DEPTH_TEST);
*pDi = outer_di;
}
}
@ -318,9 +308,10 @@ void GLPortal::End(FDrawInfo *di, bool usestencil)
if (PrevPortal != nullptr) PrevPortal->PopState();
GLRenderer->mCurrentPortal = PrevPortal;
di = di->EndDrawInfo();
di->ApplyVPUniforms();
if (usestencil)
{
if (needdepth) di = di->EndDrawInfo();
auto &vp = di->Viewpoint;
// Restore the old view
@ -368,7 +359,6 @@ void GLPortal::End(FDrawInfo *di, bool usestencil)
{
if (needdepth)
{
di = di->EndDrawInfo();
glClear(GL_DEPTH_BUFFER_BIT);
}
else
@ -561,7 +551,7 @@ void GLSkyboxPortal::DrawContents(FDrawInfo *di)
if (skyboxrecursion >= 3)
{
ClearScreen();
ClearScreen(di);
return;
}
auto &vp = di->Viewpoint;
@ -732,7 +722,7 @@ void GLPlaneMirrorPortal::DrawContents(FDrawInfo *di)
{
if (renderdepth > r_mirror_recursions)
{
ClearScreen();
ClearScreen(di);
return;
}
// A plane mirror needs to flip the portal exclusion logic because inside the mirror, up is down and down is up.
@ -856,7 +846,7 @@ void GLMirrorPortal::DrawContents(FDrawInfo *di)
{
if (renderdepth>r_mirror_recursions)
{
ClearScreen();
ClearScreen(di);
return;
}
@ -958,7 +948,7 @@ void GLLineToLinePortal::DrawContents(FDrawInfo *di)
// TODO: Handle recursion more intelligently
if (renderdepth>r_mirror_recursions)
{
ClearScreen();
ClearScreen(di);
return;
}
auto &vp = di->Viewpoint;
@ -1111,7 +1101,7 @@ void GLHorizonPortal::DrawContents(FDrawInfo *di)
gltexture=FMaterial::ValidateTexture(sp->texture, false, true);
if (!gltexture)
{
ClearScreen();
ClearScreen(di);
return;
}
gl_RenderState.SetCameraPos(vp.Pos.X, vp.Pos.Y, vp.Pos.Z);

View file

@ -88,7 +88,7 @@ protected:
virtual bool IsSky() { return false; }
virtual bool NeedCap() { return true; }
virtual bool NeedDepthBuffer() { return true; }
void ClearScreen();
void ClearScreen(FDrawInfo *di);
virtual const char *GetName() = 0;
virtual void PushState() {}
virtual void PopState() {}

View file

@ -71,17 +71,11 @@ EXTERN_CVAR (Bool, r_deathcamera)
EXTERN_CVAR (Float, r_visibility)
EXTERN_CVAR (Bool, r_drawvoxels)
//-----------------------------------------------------------------------------
//
// SetProjection
// sets projection matrix
//
//-----------------------------------------------------------------------------
void FDrawInfo::SetProjection(VSMatrix matrix)
void FDrawInfo::ApplyVPUniforms()
{
gl_RenderState.mProjectionMatrix.loadIdentity();
gl_RenderState.mProjectionMatrix.multMatrix(matrix);
VPUniforms.CalcDependencies();
GLRenderer->mShaderManager->ApplyMatrices(&VPUniforms.mProjectionMatrix, &VPUniforms.mViewMatrix, &VPUniforms.mNormalViewMatrix, NORMAL_PASS);
}
//-----------------------------------------------------------------------------
@ -95,12 +89,12 @@ void FDrawInfo::SetViewMatrix(const FRotator &angles, float vx, float vy, float
float mult = mirror? -1:1;
float planemult = planemirror? -level.info->pixelstretch : level.info->pixelstretch;
gl_RenderState.mViewMatrix.loadIdentity();
gl_RenderState.mViewMatrix.rotate(angles.Roll.Degrees, 0.0f, 0.0f, 1.0f);
gl_RenderState.mViewMatrix.rotate(angles.Pitch.Degrees, 1.0f, 0.0f, 0.0f);
gl_RenderState.mViewMatrix.rotate(angles.Yaw.Degrees, 0.0f, mult, 0.0f);
gl_RenderState.mViewMatrix.translate(vx * mult, -vz * planemult , -vy);
gl_RenderState.mViewMatrix.scale(-mult, planemult, 1);
VPUniforms.mViewMatrix.loadIdentity();
VPUniforms.mViewMatrix.rotate(angles.Roll.Degrees, 0.0f, 0.0f, 1.0f);
VPUniforms.mViewMatrix.rotate(angles.Pitch.Degrees, 1.0f, 0.0f, 0.0f);
VPUniforms.mViewMatrix.rotate(angles.Yaw.Degrees, 0.0f, mult, 0.0f);
VPUniforms.mViewMatrix.translate(vx * mult, -vz * planemult , -vy);
VPUniforms.mViewMatrix.scale(-mult, planemult, 1);
}
@ -114,7 +108,7 @@ void FDrawInfo::SetupView(FRenderViewpoint &vp, float vx, float vy, float vz, DA
{
vp.SetViewAngle(r_viewwindow);
SetViewMatrix(vp.HWAngles, vx, vy, vz, mirror, planemirror);
gl_RenderState.ApplyMatrices();
ApplyVPUniforms();
}
//-----------------------------------------------------------------------------
@ -364,11 +358,11 @@ void FDrawInfo::DrawScene(int drawmode)
if (applySSAO && gl_RenderState.GetPassType() == GBUFFER_PASS)
{
gl_RenderState.EnableDrawBuffers(1);
GLRenderer->AmbientOccludeScene();
GLRenderer->AmbientOccludeScene(VPUniforms.mProjectionMatrix.get()[5]);
GLRenderer->mBuffers->BindSceneFB(true);
gl_RenderState.EnableDrawBuffers(gl_RenderState.GetPassDrawBufferCount());
gl_RenderState.Apply();
gl_RenderState.ApplyMatrices();
ApplyVPUniforms();
}
// Handle all portals after rendering the opaque objects but before
@ -414,9 +408,9 @@ void FDrawInfo::DrawEndScene2D(sector_t * viewsector)
const bool renderHUDModel = IsHUDModelForPlayerAvailable(players[consoleplayer].camera->player);
// This should be removed once all 2D stuff is really done through the 2D interface.
gl_RenderState.mViewMatrix.loadIdentity();
gl_RenderState.mProjectionMatrix.ortho(0, screen->GetWidth(), screen->GetHeight(), 0, -1.0f, 1.0f);
gl_RenderState.ApplyMatrices();
VPUniforms.mViewMatrix.loadIdentity();
VPUniforms.mProjectionMatrix.ortho(0, screen->GetWidth(), screen->GetHeight(), 0, -1.0f, 1.0f);
ApplyVPUniforms();
glDisable(GL_DEPTH_TEST);
glDisable(GL_MULTISAMPLE);
@ -510,20 +504,20 @@ sector_t * FGLRenderer::RenderViewpoint (FRenderViewpoint &mainvp, AActor * came
screen->SetViewportRects(bounds);
Set3DViewport(mainview);
FDrawInfo *di = FDrawInfo::StartDrawInfo(mainvp);
FDrawInfo *di = FDrawInfo::StartDrawInfo(mainvp, nullptr);
auto vp = di->Viewpoint;
di->SetViewArea();
auto cm = di->SetFullbrightFlags(mainview ? vp.camera->player : nullptr);
di->Viewpoint.FieldOfView = fov; // Set the real FOV for the current scene (it's not necessarily the same as the global setting in r_viewpoint)
// Stereo mode specific perspective projection
di->SetProjection( eye->GetProjection(fov, ratio, fovratio) );
di->VPUniforms.mProjectionMatrix = eye->GetProjection(fov, ratio, fovratio);
vp.SetViewAngle(r_viewwindow);
// Stereo mode specific viewpoint adjustment - temporarily shifts global ViewPos
eye->GetViewShift(vp.HWAngles.Yaw.Degrees, viewShift);
ScopedViewShifter viewShifter(vp.Pos, viewShift);
di->SetViewMatrix(vp.HWAngles, vp.Pos.X, vp.Pos.Y, vp.Pos.Z, false, false);
gl_RenderState.ApplyMatrices();
di->ApplyVPUniforms();
di->ProcessScene(toscreen);

View file

@ -230,7 +230,6 @@ void GLSkyPortal::DrawContents(FDrawInfo *di)
gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
bool oldClamp = gl_RenderState.SetDepthClamp(true);
gl_MatrixStack.Push(gl_RenderState.mViewMatrix);
di->SetupView(vp, 0, 0, 0, vp.Angles.Yaw, !!(MirrorFlag & 1), !!(PlaneMirrorFlag & 1));
gl_RenderState.SetVertexBuffer(GLRenderer->mSkyVBO);
@ -270,8 +269,7 @@ void GLSkyPortal::DrawContents(FDrawInfo *di)
}
}
gl_RenderState.SetVertexBuffer(GLRenderer->mVBO);
gl_MatrixStack.Pop(gl_RenderState.mViewMatrix);
gl_RenderState.ApplyMatrices();
di->ApplyVPUniforms();
::level.lightmode = oldlightmode;
gl_RenderState.SetDepthClamp(oldClamp);
}

View file

@ -277,7 +277,7 @@ void FDrawInfo::DrawSprite(GLSprite *sprite, int pass)
}
else
{
FGLModelRenderer renderer(sprite->dynlightindex);
FGLModelRenderer renderer(this, sprite->dynlightindex);
renderer.RenderModel(sprite->x, sprite->y, sprite->z, sprite->modelframe, sprite->actor, vp.TicFrac);
}
}

View file

@ -93,7 +93,6 @@ void FDrawInfo::RenderMirrorSurface(GLWall *wall)
// we use texture coordinates and texture matrix to pass the normal stuff to the shader so that the default vertex buffer format can be used as is.
gl_RenderState.EnableTextureMatrix(true);
gl_RenderState.mTextureMatrix.computeNormalMatrix(gl_RenderState.mViewMatrix);
// Use sphere mapping for this
gl_RenderState.SetEffect(EFF_SPHEREMAP);

View file

@ -65,7 +65,7 @@ void FDrawInfo::DrawPSprite (HUDSprite *huds)
if (huds->mframe)
{
gl_RenderState.AlphaFunc(GL_GEQUAL, 0);
FGLModelRenderer renderer(huds->lightindex);
FGLModelRenderer renderer(this, huds->lightindex);
renderer.RenderHUDModel(huds->weapon, huds->mx, huds->my);
}
else
@ -91,7 +91,7 @@ void FDrawInfo::DrawPSprite (HUDSprite *huds)
void FDrawInfo::DrawPlayerSprites(bool hudModelStep)
{
s3d::Stereo3DMode::getCurrentMode().AdjustPlayerSprites();
s3d::Stereo3DMode::getCurrentMode().AdjustPlayerSprites(this);
int oldlightmode = level.lightmode;
if (!hudModelStep && level.lightmode == 8) level.lightmode = 2; // Software lighting cannot handle 2D content so revert to lightmode 2 for that.

View file

@ -33,6 +33,7 @@
**
*/
#include "gl/scene/gl_drawinfo.h"
#include "gl_sidebyside3d.h"
#include "gl/renderer/gl_renderbuffers.h"
@ -98,13 +99,13 @@ SideBySideFull::SideBySideFull(double ipdMeters)
}
/* virtual */
void SideBySideFull::AdjustPlayerSprites() const /* override */
void SideBySideFull::AdjustPlayerSprites(FDrawInfo *di) const /* override */
{
// Show weapon at double width, so it would appear normal width after rescaling
int w = screen->mScreenViewport.width;
int h = screen->mScreenViewport.height;
gl_RenderState.mProjectionMatrix.ortho(w/2, w + w/2, h, 0, -1.0f, 1.0f);
gl_RenderState.ApplyMatrices();
di->VPUniforms.mProjectionMatrix.ortho(w/2, w + w/2, h, 0, -1.0f, 1.0f);
di->ApplyVPUniforms();
}
/* static */

View file

@ -82,7 +82,7 @@ class SideBySideFull : public SideBySideBase
public:
static const SideBySideFull& getInstance(float ipd);
SideBySideFull(double ipdMeters);
virtual void AdjustPlayerSprites() const override;
virtual void AdjustPlayerSprites(FDrawInfo *di) const override;
private:
SBSFLeftEyePose leftEye;
SBSFRightEyePose rightEye;

View file

@ -78,7 +78,7 @@ public:
virtual bool IsMono() const { return false; }
virtual void AdjustViewports() const {};
virtual void AdjustPlayerSprites() const {};
virtual void AdjustPlayerSprites(FDrawInfo *di) const {};
virtual void Present() const = 0;
protected:

View file

@ -342,7 +342,7 @@ IHardwareTexture *OpenGLFrameBuffer::CreateHardwareTexture(FTexture *tex)
FModelRenderer *OpenGLFrameBuffer::CreateModelRenderer(int mli)
{
return new FGLModelRenderer(mli);
return new FGLModelRenderer(nullptr, mli);
}
IUniformBuffer *OpenGLFrameBuffer::CreateUniformBuffer(size_t size, bool staticuse)

View file

@ -3,6 +3,7 @@
#include <atomic>
#include "r_defs.h"
#include "r_utility.h"
#include "hw_viewpointuniforms.h"
struct FSectorPortalGroup;
@ -19,6 +20,7 @@ struct HUDSprite;
class Clipper;
class IPortal;
class FFlatVertexGenerator;
class IRenderQueue;
//==========================================================================
//
@ -99,6 +101,7 @@ struct HWDrawInfo
IShadowMap *mShadowMap;
Clipper *mClipper;
FRenderViewpoint Viewpoint;
HWViewpointUniforms VPUniforms; // per-viewpoint uniform state
TArray<MissingTextureInfo> MissingUpperTextures;
TArray<MissingTextureInfo> MissingLowerTextures;
@ -207,6 +210,7 @@ public:
virtual void AddHUDSprite(HUDSprite *huds) = 0;
virtual int UploadLights(FDynLightData &data) = 0;
virtual void ApplyVPUniforms() = 0;
virtual GLDecal *AddDecal(bool onmirror) = 0;
virtual std::pair<FFlatVertex *, unsigned int> AllocVertices(unsigned int count) = 0;

View file

@ -12,4 +12,12 @@ struct HWViewpointUniforms
{
mNormalViewMatrix.computeNormalMatrix(mViewMatrix);
}
void SetDefaults()
{
mProjectionMatrix.loadIdentity();
mViewMatrix.loadIdentity();
mNormalViewMatrix.loadIdentity();
}
};

View file

@ -8,6 +8,7 @@ class AActor;
enum area_t : int;
struct FSpriteModelFrame;
struct HWDrawInfo;
class FMaterial;
struct WeaponPosition

View file

@ -1032,7 +1032,7 @@ void R_SetupFrame (FRenderViewpoint &viewpoint, FViewWindow &viewwindow, AActor
double alen = sqrt(angx*angx + angy*angy);
viewpoint.HWAngles.Pitch = RAD2DEG((float)asin(angy / alen));
viewpoint.HWAngles.Roll.Degrees = viewpoint.Angles.Roll.Degrees; // copied for convenience.
viewpoint.HWAngles.Roll.Degrees = (float)viewpoint.Angles.Roll.Degrees; // copied for convenience.
// ViewActor only gets set, if the camera actor should not be rendered
if (actor->player && actor->player - players == consoleplayer &&

View file

@ -1,7 +1,7 @@
#pragma once
#include "p_3dfloors.h"
#include "r_defs.h"
#include <unordered_map>
EXTERN_CVAR(Int, r_3dfloors);

View file

@ -68,7 +68,7 @@ void main()
#ifdef SPHEREMAP
vec3 u = normalize(eyeCoordPos.xyz);
vec4 n = normalize(TextureMatrix * vec4(parmTexCoord.x, 0.0, parmTexCoord.y, 0.0)); // use texture matrix and coordinates for our normal. Since this is only used on walls, the normal's y coordinate is always 0.
vec4 n = normalize(NormalViewMatrix * vec4(parmTexCoord.x, 0.0, parmTexCoord.y, 0.0));
vec3 r = reflect(u, n.xyz);
float m = 2.0 * sqrt( r.x*r.x + r.y*r.y + (r.z+1.0)*(r.z+1.0) );
vec2 sst = vec2(r.x/m + 0.5, r.y/m + 0.5);