- moved FRenderState to 'common' and removed some game-dependent parts from it.
This commit is contained in:
parent
21f32834b2
commit
0c63f5c832
24 changed files with 94 additions and 68 deletions
|
|
@ -27,7 +27,7 @@
|
|||
#include "gl_interface.h"
|
||||
#include "matrix.h"
|
||||
#include "hwrenderer/scene//hw_drawstructs.h"
|
||||
#include "hwrenderer/scene//hw_renderstate.h"
|
||||
#include "hw_renderstate.h"
|
||||
#include "hw_material.h"
|
||||
#include "c_cvars.h"
|
||||
#include "r_defs.h"
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@
|
|||
#include "v_video.h"
|
||||
#include "cmdlib.h"
|
||||
#include "hwrenderer/data/buffers.h"
|
||||
#include "hwrenderer/scene/hw_renderstate.h"
|
||||
#include "hw_renderstate.h"
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@
|
|||
|
||||
#include "hwrenderer/data/shaderuniforms.h"
|
||||
#include "hwrenderer/scene/hw_viewpointuniforms.h"
|
||||
#include "hwrenderer/scene/hw_renderstate.h"
|
||||
#include "hw_renderstate.h"
|
||||
#include "hw_viewpointbuffer.h"
|
||||
|
||||
static const int INITIAL_BUFFER_SIZE = 100; // 100 viewpoints per frame should nearly always be enough
|
||||
|
|
|
|||
|
|
@ -243,6 +243,15 @@ void WriteSavePic(player_t* player, FileWriter* file, int width, int height)
|
|||
//
|
||||
//===========================================================================
|
||||
|
||||
static void CheckTimer(FRenderState &state, uint64_t ShaderStartTime)
|
||||
{
|
||||
// if firstFrame is not yet initialized, initialize it to current time
|
||||
// if we're going to overflow a float (after ~4.6 hours, or 24 bits), re-init to regain precision
|
||||
if ((state.firstFrame == 0) || (screen->FrameTime - state.firstFrame >= 1 << 24) || ShaderStartTime >= state.firstFrame)
|
||||
state.firstFrame = screen->FrameTime;
|
||||
}
|
||||
|
||||
|
||||
sector_t* RenderView(player_t* player)
|
||||
{
|
||||
auto RenderState = screen->RenderState();
|
||||
|
|
@ -281,7 +290,7 @@ sector_t* RenderView(player_t* player)
|
|||
|
||||
// Shader start time does not need to be handled per level. Just use the one from the camera to render from.
|
||||
if (player->camera)
|
||||
RenderState->CheckTimer(player->camera->Level->ShaderStartTime);
|
||||
CheckTimer(*RenderState, player->camera->Level->ShaderStartTime);
|
||||
// prepare all camera textures that have been used in the last frame.
|
||||
// This must be done for all levels, not just the primary one!
|
||||
for (auto Level : AllLevels())
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@
|
|||
#include "hwrenderer/data/buffers.h"
|
||||
#include "hwrenderer/data/flatvertices.h"
|
||||
#include "hwrenderer/scene/hw_drawinfo.h"
|
||||
#include "hwrenderer/scene/hw_renderstate.h"
|
||||
#include "hw_renderstate.h"
|
||||
#include "hwrenderer/scene/hw_portal.h"
|
||||
#include "hw_models.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -108,7 +108,7 @@ void HWDecal::DrawDecal(HWDrawInfo *di, FRenderState &state)
|
|||
di->SetColor(state, thisll, rellight, di->isFullbrightScene(), thiscm, alpha);
|
||||
if (di->Level->flags3 & LEVEL3_NOCOLOREDSPRITELIGHTING) thiscm.Decolorize();
|
||||
di->SetFog(state, thisll, rellight, di->isFullbrightScene(), &thiscm, false);
|
||||
state.SetSplitPlanes(lightlist[k].plane, lowplane);
|
||||
SetSplitPlanes(state, lightlist[k].plane, lowplane);
|
||||
|
||||
state.Draw(DT_TriangleStrip, vertindex, 4);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -435,3 +435,4 @@ struct FDynLightData;
|
|||
struct FDynamicLight;
|
||||
bool GetLight(FDynLightData& dld, int group, Plane& p, FDynamicLight* light, bool checkside);
|
||||
void AddLightToList(FDynLightData &dld, int group, FDynamicLight* light, bool forceAttenuate);
|
||||
void SetSplitPlanes(FRenderState& state, const secplane_t& top, const secplane_t& bottom);
|
||||
|
|
|
|||
|
|
@ -91,6 +91,15 @@ bool hw_SetPlaneTextureRotation(const HWSectorPlane * secplane, FGameTexture * g
|
|||
return false;
|
||||
}
|
||||
|
||||
void SetPlaneTextureRotation(FRenderState &state, HWSectorPlane* plane, FGameTexture* texture)
|
||||
{
|
||||
if (hw_SetPlaneTextureRotation(plane, texture, state.mTextureMatrix))
|
||||
{
|
||||
state.EnableTextureMatrix(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
|
|
@ -326,7 +335,7 @@ void HWFlat::DrawFlat(HWDrawInfo *di, FRenderState &state, bool translucent)
|
|||
if (sector->special != GLSector_Skybox)
|
||||
{
|
||||
state.SetMaterial(texture, UF_Texture, 0, CLAMP_NONE, 0, -1);
|
||||
state.SetPlaneTextureRotation(&plane, texture);
|
||||
SetPlaneTextureRotation(state, &plane, texture);
|
||||
DrawSubsectors(di, state);
|
||||
state.EnableTextureMatrix(false);
|
||||
}
|
||||
|
|
@ -354,7 +363,7 @@ void HWFlat::DrawFlat(HWDrawInfo *di, FRenderState &state, bool translucent)
|
|||
if (!texture->GetTranslucency()) state.AlphaFunc(Alpha_GEqual, gl_mask_threshold);
|
||||
else state.AlphaFunc(Alpha_GEqual, 0.f);
|
||||
state.SetMaterial(texture, UF_Texture, 0, CLAMP_NONE, 0, -1);
|
||||
state.SetPlaneTextureRotation(&plane, texture);
|
||||
SetPlaneTextureRotation(state, &plane, texture);
|
||||
DrawSubsectors(di, state);
|
||||
state.EnableTextureMatrix(false);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,6 +41,8 @@
|
|||
EXTERN_CVAR(Int, r_mirror_recursions)
|
||||
EXTERN_CVAR(Bool, gl_portals)
|
||||
|
||||
void SetPlaneTextureRotation(FRenderState& state, HWSectorPlane* plane, FGameTexture* texture);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// StartFrame
|
||||
|
|
@ -979,7 +981,7 @@ void HWHorizonPortal::DrawContents(HWDrawInfo *di, FRenderState &state)
|
|||
state.SetMaterial(texture, UF_Texture, 0, CLAMP_NONE, 0, -1);
|
||||
state.SetObjectColor(origin->specialcolor);
|
||||
|
||||
state.SetPlaneTextureRotation(sp, texture);
|
||||
SetPlaneTextureRotation(state, sp, texture);
|
||||
state.AlphaFunc(Alpha_GEqual, 0.f);
|
||||
state.SetRenderStyle(STYLE_Source);
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include "tarray.h"
|
||||
#include "r_utility.h"
|
||||
#include "r_sections.h"
|
||||
#include "actor.h"
|
||||
#include "hwrenderer/scene/hw_drawinfo.h"
|
||||
#include "hwrenderer/scene/hw_drawstructs.h"
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@
|
|||
**
|
||||
*/
|
||||
|
||||
#include "g_levellocals.h"
|
||||
#include "hw_renderstate.h"
|
||||
#include "hw_drawstructs.h"
|
||||
#include "hw_portal.h"
|
||||
|
|
@ -157,11 +158,3 @@ void HWDrawInfo::SetFog(FRenderState &state, int lightlevel, int rellight, bool
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void FRenderState::CheckTimer(uint64_t ShaderStartTime)
|
||||
{
|
||||
// if firstFrame is not yet initialized, initialize it to current time
|
||||
// if we're going to overflow a float (after ~4.6 hours, or 24 bits), re-init to regain precision
|
||||
if ((firstFrame == 0) || (screen->FrameTime - firstFrame >= 1 << 24) || ShaderStartTime >= firstFrame)
|
||||
firstFrame = screen->FrameTime;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,683 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include "v_palette.h"
|
||||
#include "vectors.h"
|
||||
#include "g_levellocals.h"
|
||||
#include "hw_drawstructs.h"
|
||||
#include "hw_drawlist.h"
|
||||
#include "matrix.h"
|
||||
#include "hw_material.h"
|
||||
|
||||
struct FColormap;
|
||||
class IVertexBuffer;
|
||||
class IIndexBuffer;
|
||||
|
||||
enum EClearTarget
|
||||
{
|
||||
CT_Depth = 1,
|
||||
CT_Stencil = 2,
|
||||
CT_Color = 4
|
||||
};
|
||||
|
||||
enum ERenderEffect
|
||||
{
|
||||
EFF_NONE = -1,
|
||||
EFF_FOGBOUNDARY,
|
||||
EFF_SPHEREMAP,
|
||||
EFF_BURN,
|
||||
EFF_STENCIL,
|
||||
|
||||
MAX_EFFECTS
|
||||
};
|
||||
|
||||
enum EAlphaFunc
|
||||
{
|
||||
Alpha_GEqual = 0,
|
||||
Alpha_Greater = 1
|
||||
};
|
||||
|
||||
enum EDrawType
|
||||
{
|
||||
DT_Points = 0,
|
||||
DT_Lines = 1,
|
||||
DT_Triangles = 2,
|
||||
DT_TriangleFan = 3,
|
||||
DT_TriangleStrip = 4
|
||||
};
|
||||
|
||||
enum EDepthFunc
|
||||
{
|
||||
DF_Less,
|
||||
DF_LEqual,
|
||||
DF_Always
|
||||
};
|
||||
|
||||
enum EStencilFlags
|
||||
{
|
||||
SF_AllOn = 0,
|
||||
SF_ColorMaskOff = 1,
|
||||
SF_DepthMaskOff = 2,
|
||||
};
|
||||
|
||||
enum EStencilOp
|
||||
{
|
||||
SOP_Keep = 0,
|
||||
SOP_Increment = 1,
|
||||
SOP_Decrement = 2
|
||||
};
|
||||
|
||||
enum ECull
|
||||
{
|
||||
Cull_None,
|
||||
Cull_CCW,
|
||||
Cull_CW
|
||||
};
|
||||
|
||||
|
||||
|
||||
struct FStateVec4
|
||||
{
|
||||
float vec[4];
|
||||
|
||||
void Set(float r, float g, float b, float a)
|
||||
{
|
||||
vec[0] = r;
|
||||
vec[1] = g;
|
||||
vec[2] = b;
|
||||
vec[3] = a;
|
||||
}
|
||||
};
|
||||
|
||||
struct FMaterialState
|
||||
{
|
||||
FMaterial *mMaterial;
|
||||
int mClampMode;
|
||||
int mTranslation;
|
||||
int mOverrideShader;
|
||||
bool mChanged;
|
||||
|
||||
void Reset()
|
||||
{
|
||||
mMaterial = nullptr;
|
||||
mTranslation = 0;
|
||||
mClampMode = CLAMP_NONE;
|
||||
mOverrideShader = -1;
|
||||
mChanged = false;
|
||||
}
|
||||
};
|
||||
|
||||
struct FDepthBiasState
|
||||
{
|
||||
float mFactor;
|
||||
float mUnits;
|
||||
bool mChanged;
|
||||
|
||||
void Reset()
|
||||
{
|
||||
mFactor = 0;
|
||||
mUnits = 0;
|
||||
mChanged = false;
|
||||
}
|
||||
};
|
||||
|
||||
enum EPassType
|
||||
{
|
||||
NORMAL_PASS,
|
||||
GBUFFER_PASS,
|
||||
MAX_PASS_TYPES
|
||||
};
|
||||
|
||||
struct FVector4PalEntry
|
||||
{
|
||||
float r, g, b, a;
|
||||
|
||||
bool operator==(const FVector4PalEntry &other) const
|
||||
{
|
||||
return r == other.r && g == other.g && b == other.b && a == other.a;
|
||||
}
|
||||
|
||||
bool operator!=(const FVector4PalEntry &other) const
|
||||
{
|
||||
return r != other.r || g != other.g || b != other.b || a != other.a;
|
||||
}
|
||||
|
||||
FVector4PalEntry &operator=(PalEntry newvalue)
|
||||
{
|
||||
const float normScale = 1.0f / 255.0f;
|
||||
r = newvalue.r * normScale;
|
||||
g = newvalue.g * normScale;
|
||||
b = newvalue.b * normScale;
|
||||
a = newvalue.a * normScale;
|
||||
return *this;
|
||||
}
|
||||
|
||||
FVector4PalEntry& SetIA(PalEntry newvalue)
|
||||
{
|
||||
const float normScale = 1.0f / 255.0f;
|
||||
r = newvalue.r * normScale;
|
||||
g = newvalue.g * normScale;
|
||||
b = newvalue.b * normScale;
|
||||
a = 1;
|
||||
return *this;
|
||||
}
|
||||
|
||||
FVector4PalEntry& SetFlt(float v1, float v2, float v3, float v4)
|
||||
{
|
||||
r = v1;
|
||||
g = v2;
|
||||
b = v3;
|
||||
a = v4;
|
||||
return *this;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
struct StreamData
|
||||
{
|
||||
FVector4PalEntry uObjectColor;
|
||||
FVector4PalEntry uObjectColor2;
|
||||
FVector4 uDynLightColor;
|
||||
FVector4PalEntry uAddColor;
|
||||
FVector4PalEntry uTextureAddColor;
|
||||
FVector4PalEntry uTextureModulateColor;
|
||||
FVector4PalEntry uTextureBlendColor;
|
||||
FVector4PalEntry uFogColor;
|
||||
float uDesaturationFactor;
|
||||
float uInterpolationFactor;
|
||||
float timer;
|
||||
int useVertexData;
|
||||
FVector4 uVertexColor;
|
||||
FVector4 uVertexNormal;
|
||||
|
||||
FVector4 uGlowTopPlane;
|
||||
FVector4 uGlowTopColor;
|
||||
FVector4 uGlowBottomPlane;
|
||||
FVector4 uGlowBottomColor;
|
||||
|
||||
FVector4 uGradientTopPlane;
|
||||
FVector4 uGradientBottomPlane;
|
||||
|
||||
FVector4 uSplitTopPlane;
|
||||
FVector4 uSplitBottomPlane;
|
||||
|
||||
FVector4 uDetailParms;
|
||||
};
|
||||
|
||||
class FRenderState
|
||||
{
|
||||
protected:
|
||||
uint8_t mFogEnabled;
|
||||
uint8_t mTextureEnabled:1;
|
||||
uint8_t mGlowEnabled : 1;
|
||||
uint8_t mGradientEnabled : 1;
|
||||
uint8_t mModelMatrixEnabled : 1;
|
||||
uint8_t mTextureMatrixEnabled : 1;
|
||||
uint8_t mSplitEnabled : 1;
|
||||
uint8_t mBrightmapEnabled : 1;
|
||||
|
||||
int mLightIndex;
|
||||
int mSpecialEffect;
|
||||
int mTextureMode;
|
||||
int mTextureModeFlags;
|
||||
int mSoftLight;
|
||||
float mLightParms[4];
|
||||
|
||||
float mAlphaThreshold;
|
||||
float mClipSplit[2];
|
||||
|
||||
StreamData mStreamData = {};
|
||||
PalEntry mFogColor;
|
||||
|
||||
FRenderStyle mRenderStyle;
|
||||
|
||||
FMaterialState mMaterial;
|
||||
FDepthBiasState mBias;
|
||||
|
||||
IVertexBuffer *mVertexBuffer;
|
||||
int mVertexOffsets[2]; // one per binding point
|
||||
IIndexBuffer *mIndexBuffer;
|
||||
|
||||
EPassType mPassType = NORMAL_PASS;
|
||||
|
||||
uint64_t firstFrame = 0;
|
||||
|
||||
public:
|
||||
VSMatrix mModelMatrix;
|
||||
VSMatrix mTextureMatrix;
|
||||
|
||||
public:
|
||||
|
||||
void Reset()
|
||||
{
|
||||
mTextureEnabled = true;
|
||||
mBrightmapEnabled = mGradientEnabled = mFogEnabled = mGlowEnabled = false;
|
||||
mFogColor = 0xffffffff;
|
||||
mStreamData.uFogColor = mFogColor;
|
||||
mTextureMode = -1;
|
||||
mTextureModeFlags = 0;
|
||||
mStreamData.uDesaturationFactor = 0.0f;
|
||||
mAlphaThreshold = 0.5f;
|
||||
mModelMatrixEnabled = false;
|
||||
mTextureMatrixEnabled = false;
|
||||
mSplitEnabled = false;
|
||||
mStreamData.uAddColor = 0;
|
||||
mStreamData.uObjectColor = 0xffffffff;
|
||||
mStreamData.uObjectColor2 = 0;
|
||||
mStreamData.uTextureBlendColor = 0;
|
||||
mStreamData.uTextureAddColor = 0;
|
||||
mStreamData.uTextureModulateColor = 0;
|
||||
mSoftLight = 0;
|
||||
mLightParms[0] = mLightParms[1] = mLightParms[2] = 0.0f;
|
||||
mLightParms[3] = -1.f;
|
||||
mSpecialEffect = EFF_NONE;
|
||||
mLightIndex = -1;
|
||||
mStreamData.uInterpolationFactor = 0;
|
||||
mRenderStyle = DefaultRenderStyle();
|
||||
mMaterial.Reset();
|
||||
mBias.Reset();
|
||||
mPassType = NORMAL_PASS;
|
||||
|
||||
mVertexBuffer = nullptr;
|
||||
mVertexOffsets[0] = mVertexOffsets[1] = 0;
|
||||
mIndexBuffer = nullptr;
|
||||
|
||||
mStreamData.uVertexColor = { 1.0f, 1.0f, 1.0f, 1.0f };
|
||||
mStreamData.uGlowTopColor = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||
mStreamData.uGlowBottomColor = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||
mStreamData.uGlowTopPlane = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||
mStreamData.uGlowBottomPlane = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||
mStreamData.uGradientTopPlane = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||
mStreamData.uGradientBottomPlane = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||
mStreamData.uSplitTopPlane = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||
mStreamData.uSplitBottomPlane = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||
mStreamData.uDynLightColor = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||
mStreamData.uDetailParms = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||
|
||||
mModelMatrix.loadIdentity();
|
||||
mTextureMatrix.loadIdentity();
|
||||
ClearClipSplit();
|
||||
}
|
||||
|
||||
void SetNormal(FVector3 norm)
|
||||
{
|
||||
mStreamData.uVertexNormal = { norm.X, norm.Y, norm.Z, 0.f };
|
||||
}
|
||||
|
||||
void SetNormal(float x, float y, float z)
|
||||
{
|
||||
mStreamData.uVertexNormal = { x, y, z, 0.f };
|
||||
}
|
||||
|
||||
void SetColor(float r, float g, float b, float a = 1.f, int desat = 0)
|
||||
{
|
||||
mStreamData.uVertexColor = { r, g, b, a };
|
||||
mStreamData.uDesaturationFactor = desat * (1.0f / 255.0f);
|
||||
}
|
||||
|
||||
void SetColor(PalEntry pe, int desat = 0)
|
||||
{
|
||||
const float scale = 1.0f / 255.0f;
|
||||
mStreamData.uVertexColor = { pe.r * scale, pe.g * scale, pe.b * scale, pe.a * scale };
|
||||
mStreamData.uDesaturationFactor = desat * (1.0f / 255.0f);
|
||||
}
|
||||
|
||||
void SetColorAlpha(PalEntry pe, float alpha = 1.f, int desat = 0)
|
||||
{
|
||||
const float scale = 1.0f / 255.0f;
|
||||
mStreamData.uVertexColor = { pe.r * scale, pe.g * scale, pe.b * scale, alpha };
|
||||
mStreamData.uDesaturationFactor = desat * (1.0f / 255.0f);
|
||||
}
|
||||
|
||||
void ResetColor()
|
||||
{
|
||||
mStreamData.uVertexColor = { 1.0f, 1.0f, 1.0f, 1.0f };
|
||||
mStreamData.uDesaturationFactor = 0.0f;
|
||||
}
|
||||
|
||||
void SetTextureMode(int mode)
|
||||
{
|
||||
mTextureMode = mode;
|
||||
}
|
||||
|
||||
void SetTextureMode(FRenderStyle style)
|
||||
{
|
||||
if (style.Flags & STYLEF_RedIsAlpha)
|
||||
{
|
||||
SetTextureMode(TM_ALPHATEXTURE);
|
||||
}
|
||||
else if (style.Flags & STYLEF_ColorIsFixed)
|
||||
{
|
||||
SetTextureMode(TM_STENCIL);
|
||||
}
|
||||
else if (style.Flags & STYLEF_InvertSource)
|
||||
{
|
||||
SetTextureMode(TM_INVERSE);
|
||||
}
|
||||
}
|
||||
|
||||
int GetTextureMode()
|
||||
{
|
||||
return mTextureMode;
|
||||
}
|
||||
|
||||
void EnableTexture(bool on)
|
||||
{
|
||||
mTextureEnabled = on;
|
||||
}
|
||||
|
||||
void EnableFog(uint8_t on)
|
||||
{
|
||||
mFogEnabled = on;
|
||||
}
|
||||
|
||||
void SetEffect(int eff)
|
||||
{
|
||||
mSpecialEffect = eff;
|
||||
}
|
||||
|
||||
void EnableGlow(bool on)
|
||||
{
|
||||
if (mGlowEnabled && !on)
|
||||
{
|
||||
mStreamData.uGlowTopColor = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||
mStreamData.uGlowBottomColor = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||
}
|
||||
mGlowEnabled = on;
|
||||
}
|
||||
|
||||
void EnableGradient(bool on)
|
||||
{
|
||||
mGradientEnabled = on;
|
||||
}
|
||||
|
||||
void EnableBrightmap(bool on)
|
||||
{
|
||||
mBrightmapEnabled = on;
|
||||
}
|
||||
|
||||
void EnableSplit(bool on)
|
||||
{
|
||||
if (mSplitEnabled && !on)
|
||||
{
|
||||
mStreamData.uSplitTopPlane = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||
mStreamData.uSplitBottomPlane = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||
}
|
||||
mSplitEnabled = on;
|
||||
}
|
||||
|
||||
void EnableModelMatrix(bool on)
|
||||
{
|
||||
mModelMatrixEnabled = on;
|
||||
}
|
||||
|
||||
void EnableTextureMatrix(bool on)
|
||||
{
|
||||
mTextureMatrixEnabled = on;
|
||||
}
|
||||
|
||||
void SetGlowParams(float *t, float *b)
|
||||
{
|
||||
mStreamData.uGlowTopColor = { t[0], t[1], t[2], t[3] };
|
||||
mStreamData.uGlowBottomColor = { b[0], b[1], b[2], b[3] };
|
||||
}
|
||||
|
||||
void SetSoftLightLevel(int llevel, int blendfactor = 0)
|
||||
{
|
||||
if (blendfactor == 0) mLightParms[3] = llevel / 255.f;
|
||||
else mLightParms[3] = -1.f;
|
||||
}
|
||||
|
||||
void SetNoSoftLightLevel()
|
||||
{
|
||||
mLightParms[3] = -1.f;
|
||||
}
|
||||
|
||||
void SetGlowPlanes(const secplane_t &top, const secplane_t &bottom)
|
||||
{
|
||||
auto &tn = top.Normal();
|
||||
auto &bn = bottom.Normal();
|
||||
mStreamData.uGlowTopPlane = { (float)tn.X, (float)tn.Y, (float)top.negiC, (float)top.fD() };
|
||||
mStreamData.uGlowBottomPlane = { (float)bn.X, (float)bn.Y, (float)bottom.negiC, (float)bottom.fD() };
|
||||
}
|
||||
|
||||
void SetGradientPlanes(const secplane_t &top, const secplane_t &bottom)
|
||||
{
|
||||
auto &tn = top.Normal();
|
||||
auto &bn = bottom.Normal();
|
||||
mStreamData.uGradientTopPlane = { (float)tn.X, (float)tn.Y, (float)top.negiC, (float)top.fD() };
|
||||
mStreamData.uGradientBottomPlane = { (float)bn.X, (float)bn.Y, (float)bottom.negiC, (float)bottom.fD() };
|
||||
}
|
||||
|
||||
void SetSplitPlanes(const secplane_t &top, const secplane_t &bottom)
|
||||
{
|
||||
auto &tn = top.Normal();
|
||||
auto &bn = bottom.Normal();
|
||||
mStreamData.uSplitTopPlane = { (float)tn.X, (float)tn.Y, (float)top.negiC, (float)top.fD() };
|
||||
mStreamData.uSplitBottomPlane = { (float)bn.X, (float)bn.Y, (float)bottom.negiC, (float)bottom.fD() };
|
||||
}
|
||||
|
||||
void SetDetailParms(float xscale, float yscale, float bias)
|
||||
{
|
||||
mStreamData.uDetailParms = { xscale, yscale, bias, 0 };
|
||||
}
|
||||
|
||||
void SetDynLight(float r, float g, float b)
|
||||
{
|
||||
mStreamData.uDynLightColor = { r, g, b, 0.0f };
|
||||
}
|
||||
|
||||
void SetObjectColor(PalEntry pe)
|
||||
{
|
||||
mStreamData.uObjectColor = pe;
|
||||
}
|
||||
|
||||
void SetObjectColor2(PalEntry pe)
|
||||
{
|
||||
mStreamData.uObjectColor2 = pe;
|
||||
}
|
||||
|
||||
void SetAddColor(PalEntry pe)
|
||||
{
|
||||
mStreamData.uAddColor = pe;
|
||||
}
|
||||
|
||||
void ApplyTextureManipulation(TextureManipulation* texfx)
|
||||
{
|
||||
if (!texfx || texfx->AddColor.a == 0)
|
||||
{
|
||||
mStreamData.uTextureAddColor.a = 0; // we only need to set the flags to 0
|
||||
}
|
||||
else
|
||||
{
|
||||
// set up the whole thing
|
||||
mStreamData.uTextureAddColor.SetIA(texfx->AddColor);
|
||||
auto pe = texfx->ModulateColor;
|
||||
mStreamData.uTextureModulateColor.SetFlt(pe.r * pe.a / 255.f, pe.g * pe.a / 255.f, pe.b * pe.a / 255.f, texfx->DesaturationFactor);
|
||||
mStreamData.uTextureBlendColor = texfx->BlendColor;
|
||||
}
|
||||
}
|
||||
|
||||
void SetFog(PalEntry c, float d)
|
||||
{
|
||||
const float LOG2E = 1.442692f; // = 1/log(2)
|
||||
mFogColor = c;
|
||||
mStreamData.uFogColor = mFogColor;
|
||||
if (d >= 0.0f) mLightParms[2] = d * (-LOG2E / 64000.f);
|
||||
}
|
||||
|
||||
void SetLightParms(float f, float d)
|
||||
{
|
||||
mLightParms[1] = f;
|
||||
mLightParms[0] = d;
|
||||
}
|
||||
|
||||
PalEntry GetFogColor() const
|
||||
{
|
||||
return mFogColor;
|
||||
}
|
||||
|
||||
void AlphaFunc(int func, float thresh)
|
||||
{
|
||||
if (func == Alpha_Greater) mAlphaThreshold = thresh;
|
||||
else mAlphaThreshold = thresh - 0.001f;
|
||||
}
|
||||
|
||||
void SetPlaneTextureRotation(HWSectorPlane *plane, FGameTexture *texture)
|
||||
{
|
||||
if (hw_SetPlaneTextureRotation(plane, texture, mTextureMatrix))
|
||||
{
|
||||
EnableTextureMatrix(true);
|
||||
}
|
||||
}
|
||||
|
||||
void SetLightIndex(int index)
|
||||
{
|
||||
mLightIndex = index;
|
||||
}
|
||||
|
||||
void SetRenderStyle(FRenderStyle rs)
|
||||
{
|
||||
mRenderStyle = rs;
|
||||
}
|
||||
|
||||
void SetRenderStyle(ERenderStyle rs)
|
||||
{
|
||||
mRenderStyle = rs;
|
||||
}
|
||||
|
||||
void SetDepthBias(float a, float b)
|
||||
{
|
||||
mBias.mFactor = a;
|
||||
mBias.mUnits = b;
|
||||
mBias.mChanged = true;
|
||||
}
|
||||
|
||||
void ClearDepthBias()
|
||||
{
|
||||
mBias.mFactor = 0;
|
||||
mBias.mUnits = 0;
|
||||
mBias.mChanged = true;
|
||||
}
|
||||
|
||||
void SetMaterial(FMaterial *mat, int clampmode, int translation, int overrideshader)
|
||||
{
|
||||
mMaterial.mMaterial = mat;
|
||||
mMaterial.mClampMode = clampmode;
|
||||
mMaterial.mTranslation = translation;
|
||||
mMaterial.mOverrideShader = overrideshader;
|
||||
mMaterial.mChanged = true;
|
||||
mTextureModeFlags = mat->GetLayerFlags();
|
||||
}
|
||||
|
||||
void SetMaterial(FGameTexture* tex, EUpscaleFlags upscalemask, int scaleflags, int clampmode, int translation, int overrideshader)
|
||||
{
|
||||
if (shouldUpscale(tex, upscalemask)) scaleflags |= CTF_Upscale;
|
||||
SetMaterial(FMaterial::ValidateTexture(tex, scaleflags), clampmode, translation, overrideshader);
|
||||
}
|
||||
|
||||
void SetClipSplit(float bottom, float top)
|
||||
{
|
||||
mClipSplit[0] = bottom;
|
||||
mClipSplit[1] = top;
|
||||
}
|
||||
|
||||
void SetClipSplit(float *vals)
|
||||
{
|
||||
memcpy(mClipSplit, vals, 2 * sizeof(float));
|
||||
}
|
||||
|
||||
void GetClipSplit(float *out)
|
||||
{
|
||||
memcpy(out, mClipSplit, 2 * sizeof(float));
|
||||
}
|
||||
|
||||
void ClearClipSplit()
|
||||
{
|
||||
mClipSplit[0] = -1000000.f;
|
||||
mClipSplit[1] = 1000000.f;
|
||||
}
|
||||
|
||||
void SetVertexBuffer(IVertexBuffer *vb, int offset0, int offset1)
|
||||
{
|
||||
assert(vb);
|
||||
mVertexBuffer = vb;
|
||||
mVertexOffsets[0] = offset0;
|
||||
mVertexOffsets[1] = offset1;
|
||||
}
|
||||
|
||||
void SetIndexBuffer(IIndexBuffer *ib)
|
||||
{
|
||||
mIndexBuffer = ib;
|
||||
}
|
||||
|
||||
template <class T> void SetVertexBuffer(T *buffer)
|
||||
{
|
||||
auto ptrs = buffer->GetBufferObjects();
|
||||
SetVertexBuffer(ptrs.first, 0, 0);
|
||||
SetIndexBuffer(ptrs.second);
|
||||
}
|
||||
|
||||
void SetInterpolationFactor(float fac)
|
||||
{
|
||||
mStreamData.uInterpolationFactor = fac;
|
||||
}
|
||||
|
||||
float GetInterpolationFactor()
|
||||
{
|
||||
return mStreamData.uInterpolationFactor;
|
||||
}
|
||||
|
||||
void EnableDrawBufferAttachments(bool on) // Used by fog boundary drawer
|
||||
{
|
||||
EnableDrawBuffers(on ? GetPassDrawBufferCount() : 1);
|
||||
}
|
||||
|
||||
int GetPassDrawBufferCount()
|
||||
{
|
||||
return mPassType == GBUFFER_PASS ? 3 : 1;
|
||||
}
|
||||
|
||||
void SetPassType(EPassType passType)
|
||||
{
|
||||
mPassType = passType;
|
||||
}
|
||||
|
||||
EPassType GetPassType()
|
||||
{
|
||||
return mPassType;
|
||||
}
|
||||
|
||||
void CheckTimer(uint64_t ShaderStartTime);
|
||||
|
||||
// API-dependent render interface
|
||||
|
||||
// Draw commands
|
||||
virtual void ClearScreen() = 0;
|
||||
virtual void Draw(int dt, int index, int count, bool apply = true) = 0;
|
||||
virtual void DrawIndexed(int dt, int index, int count, bool apply = true) = 0;
|
||||
|
||||
// Immediate render state change commands. These only change infrequently and should not clutter the render state.
|
||||
virtual bool SetDepthClamp(bool on) = 0; // Deactivated only by skyboxes.
|
||||
virtual void SetDepthMask(bool on) = 0; // Used by decals and indirectly by portal setup.
|
||||
virtual void SetDepthFunc(int func) = 0; // Used by models, portals and mirror surfaces.
|
||||
virtual void SetDepthRange(float min, float max) = 0; // Used by portal setup.
|
||||
virtual void SetColorMask(bool r, bool g, bool b, bool a) = 0; // Used by portals.
|
||||
virtual void SetStencil(int offs, int op, int flags=-1) = 0; // Used by portal setup and render hacks.
|
||||
virtual void SetCulling(int mode) = 0; // Used by model drawer only.
|
||||
virtual void EnableClipDistance(int num, bool state) = 0; // Use by sprite sorter for vertical splits.
|
||||
virtual void Clear(int targets) = 0; // not used during normal rendering
|
||||
virtual void EnableStencil(bool on) = 0; // always on for 3D, always off for 2D
|
||||
virtual void SetScissor(int x, int y, int w, int h) = 0; // constant for 3D, changes for 2D
|
||||
virtual void SetViewport(int x, int y, int w, int h) = 0; // constant for all 3D and all 2D
|
||||
virtual void EnableDepthTest(bool on) = 0; // used by 2D, portals and render hacks.
|
||||
virtual void EnableMultisampling(bool on) = 0; // only active for 2D
|
||||
virtual void EnableLineSmooth(bool on) = 0; // constant setting for each 2D drawer operation
|
||||
virtual void EnableDrawBuffers(int count, bool apply = false) = 0; // Used by SSAO and EnableDrawBufferAttachments
|
||||
|
||||
void SetColorMask(bool on)
|
||||
{
|
||||
SetColorMask(on, on, on, on);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
|
@ -28,7 +28,7 @@
|
|||
#include "g_levellocals.h"
|
||||
#include "hwrenderer/scene/hw_skydome.h"
|
||||
#include "hwrenderer/scene/hw_portal.h"
|
||||
#include "hwrenderer/scene/hw_renderstate.h"
|
||||
#include "hw_renderstate.h"
|
||||
#include "skyboxtexture.h"
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -237,11 +237,11 @@ void HWSprite::DrawSprite(HWDrawInfo *di, FRenderState &state, bool translucent)
|
|||
{
|
||||
di->SetFog(state, thislight, rel, di->isFullbrightScene(), &thiscm, additivefog);
|
||||
}
|
||||
state.SetSplitPlanes(*topplane, *lowplane);
|
||||
SetSplitPlanes(state, *topplane, *lowplane);
|
||||
}
|
||||
else if (clipping)
|
||||
{
|
||||
state.SetSplitPlanes(topp, bottomp);
|
||||
SetSplitPlanes(state, topp, bottomp);
|
||||
}
|
||||
|
||||
if (!modelframe)
|
||||
|
|
|
|||
|
|
@ -44,6 +44,35 @@
|
|||
#include "hw_renderstate.h"
|
||||
#include "hw_skydome.h"
|
||||
|
||||
|
||||
void SetGlowPlanes(FRenderState &state, const secplane_t& top, const secplane_t& bottom)
|
||||
{
|
||||
auto& tn = top.Normal();
|
||||
auto& bn = bottom.Normal();
|
||||
FVector4 tp = { (float)tn.X, (float)tn.Y, (float)top.negiC, (float)top.fD() };
|
||||
FVector4 bp = { (float)bn.X, (float)bn.Y, (float)bottom.negiC, (float)bottom.fD() };
|
||||
state.SetGlowPlanes(tp, bp);
|
||||
}
|
||||
|
||||
void SetGradientPlanes(FRenderState& state, const secplane_t& top, const secplane_t& bottom)
|
||||
{
|
||||
auto& tn = top.Normal();
|
||||
auto& bn = bottom.Normal();
|
||||
FVector4 tp = { (float)tn.X, (float)tn.Y, (float)top.negiC, (float)top.fD() };
|
||||
FVector4 bp = { (float)bn.X, (float)bn.Y, (float)bottom.negiC, (float)bottom.fD() };
|
||||
state.SetGradientPlanes(tp, bp);
|
||||
}
|
||||
|
||||
void SetSplitPlanes(FRenderState& state, const secplane_t& top, const secplane_t& bottom)
|
||||
{
|
||||
auto& tn = top.Normal();
|
||||
auto& bn = bottom.Normal();
|
||||
FVector4 tp = { (float)tn.X, (float)tn.Y, (float)top.negiC, (float)top.fD() };
|
||||
FVector4 bp = { (float)bn.X, (float)bn.Y, (float)bottom.negiC, (float)bottom.fD() };
|
||||
state.SetSplitPlanes(tp, bp);
|
||||
}
|
||||
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// General purpose wall rendering function
|
||||
|
|
@ -155,7 +184,7 @@ void HWWall::RenderTexturedWall(HWDrawInfo *di, FRenderState &state, int rflags)
|
|||
{
|
||||
state.EnableGlow(true);
|
||||
state.SetGlowParams(topglowcolor, bottomglowcolor);
|
||||
state.SetGlowPlanes(frontsector->ceilingplane, frontsector->floorplane);
|
||||
SetGlowPlanes(state, frontsector->ceilingplane, frontsector->floorplane);
|
||||
}
|
||||
state.SetMaterial(texture, UF_Texture, 0, flags & 3, 0, -1);
|
||||
|
||||
|
|
@ -191,20 +220,20 @@ void HWWall::RenderTexturedWall(HWDrawInfo *di, FRenderState &state, int rflags)
|
|||
{
|
||||
if (tierndx == side_t::top)
|
||||
{
|
||||
state.SetGradientPlanes(frontsector->ceilingplane, backsector->ceilingplane);
|
||||
SetGradientPlanes(state, frontsector->ceilingplane, backsector->ceilingplane);
|
||||
}
|
||||
else if (tierndx == side_t::mid)
|
||||
{
|
||||
state.SetGradientPlanes(backsector->ceilingplane, backsector->floorplane);
|
||||
SetGradientPlanes(state, backsector->ceilingplane, backsector->floorplane);
|
||||
}
|
||||
else // side_t::bottom:
|
||||
{
|
||||
state.SetGradientPlanes(backsector->floorplane, frontsector->floorplane);
|
||||
SetGradientPlanes(state, backsector->floorplane, frontsector->floorplane);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
state.SetGradientPlanes(frontsector->ceilingplane, frontsector->floorplane);
|
||||
SetGradientPlanes(state, frontsector->ceilingplane, frontsector->floorplane);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -237,7 +266,7 @@ void HWWall::RenderTexturedWall(HWDrawInfo *di, FRenderState &state, int rflags)
|
|||
CopyFrom3DLight(thiscm, &(*lightlist)[i]);
|
||||
di->SetColor(state, thisll, rel, false, thiscm, absalpha);
|
||||
if (type != RENDERWALL_M2SNF) di->SetFog(state, thisll, rel, false, &thiscm, RenderStyle == STYLE_Add);
|
||||
state.SetSplitPlanes((*lightlist)[i].plane, lowplane);
|
||||
SetSplitPlanes(state, (*lightlist)[i].plane, lowplane);
|
||||
RenderWall(di, state, rflags);
|
||||
}
|
||||
if (low1 <= zbottom[0] && low2 <= zbottom[1]) break;
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@
|
|||
#include "hwrenderer/data/hw_viewpointbuffer.h"
|
||||
#include "hwrenderer/utility/hw_clock.h"
|
||||
#include "hwrenderer/utility/hw_cvars.h"
|
||||
#include "hwrenderer/scene/hw_renderstate.h"
|
||||
#include "hw_renderstate.h"
|
||||
#include "r_videoscale.h"
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
#include "r_data/colormaps.h"
|
||||
#include "hw_material.h"
|
||||
#include "hwrenderer/utility/hw_cvars.h"
|
||||
#include "hwrenderer/scene/hw_renderstate.h"
|
||||
#include "hw_renderstate.h"
|
||||
#include "poly_framebuffer.h"
|
||||
#include "poly_hwtexture.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
#include "name.h"
|
||||
|
||||
#include "hwrenderer/scene/hw_drawstructs.h"
|
||||
#include "hwrenderer/scene/hw_renderstate.h"
|
||||
#include "hw_renderstate.h"
|
||||
#include "hw_material.h"
|
||||
|
||||
struct HWViewpointUniforms;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "hwrenderer/scene/hw_viewpointuniforms.h"
|
||||
#include "hwrenderer/scene/hw_renderstate.h"
|
||||
#include "hw_renderstate.h"
|
||||
|
||||
#ifndef NO_SSE
|
||||
#include <xmmintrin.h>
|
||||
|
|
|
|||
|
|
@ -421,8 +421,8 @@ static void WriteVaryingWarp1(float posU, float posV, float stepU, float stepV,
|
|||
float u = posU * w[x];
|
||||
float v = posV * w[x];
|
||||
|
||||
v += g_sin(pi2 * (u + timer)) * 0.1f;
|
||||
u += g_sin(pi2 * (v + timer)) * 0.1f;
|
||||
v += (float)g_sin(pi2 * (u + timer)) * 0.1f;
|
||||
u += (float)g_sin(pi2 * (v + timer)) * 0.1f;
|
||||
|
||||
u = u - std::floor(u);
|
||||
v = v - std::floor(v);
|
||||
|
|
@ -448,8 +448,8 @@ static void WriteVaryingWarp2(float posU, float posV, float stepU, float stepV,
|
|||
float u = posU * w[x];
|
||||
float v = posV * w[x];
|
||||
|
||||
v += (0.5f + g_sin(pi2 * (v + timer * 0.61f + 900.f/8192.f)) + g_sin(pi2 * (u * 2.0f + timer * 0.36f + 300.0f/8192.0f))) * 0.025f;
|
||||
u += (0.5f + g_sin(pi2 * (v + timer * 0.49f + 700.f/8192.f)) + g_sin(pi2 * (u * 2.0f + timer * 0.49f + 1200.0f/8192.0f))) * 0.025f;
|
||||
v += (0.5f + (float)g_sin(pi2 * (v + timer * 0.61f + 900.f/8192.f)) + (float)g_sin(pi2 * (u * 2.0f + timer * 0.36f + 300.0f/8192.0f))) * 0.025f;
|
||||
u += (0.5f + (float)g_sin(pi2 * (v + timer * 0.49f + 700.f/8192.f)) + (float)g_sin(pi2 * (u * 2.0f + timer * 0.49f + 1200.0f/8192.0f))) * 0.025f;
|
||||
|
||||
u = u - std::floor(u);
|
||||
v = v - std::floor(v);
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
#include "vulkan/system/vk_objects.h"
|
||||
#include "renderstyle.h"
|
||||
#include "hwrenderer/data/buffers.h"
|
||||
#include "hwrenderer/scene/hw_renderstate.h"
|
||||
#include "hw_renderstate.h"
|
||||
#include <string.h>
|
||||
#include <map>
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
#include "name.h"
|
||||
|
||||
#include "hwrenderer/scene/hw_drawstructs.h"
|
||||
#include "hwrenderer/scene/hw_renderstate.h"
|
||||
#include "hw_renderstate.h"
|
||||
#include "hw_material.h"
|
||||
|
||||
class VkRenderPassSetup;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
#include "vectors.h"
|
||||
#include "matrix.h"
|
||||
#include "name.h"
|
||||
#include "hwrenderer/scene/hw_renderstate.h"
|
||||
#include "hw_renderstate.h"
|
||||
|
||||
#define SHADER_MIN_REQUIRED_TEXTURE_LAYERS 8
|
||||
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
#include "r_data/colormaps.h"
|
||||
#include "hw_material.h"
|
||||
#include "hwrenderer/utility/hw_cvars.h"
|
||||
#include "hwrenderer/scene/hw_renderstate.h"
|
||||
#include "hw_renderstate.h"
|
||||
#include "vulkan/system/vk_objects.h"
|
||||
#include "vulkan/system/vk_builders.h"
|
||||
#include "vulkan/system/vk_framebuffer.h"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue