- start renaming uniforms to match GZDoom.

Needed to allow using the same shader with the backend.
This commit is contained in:
Christoph Oelckers 2020-06-04 21:34:27 +02:00
parent d92f56f36f
commit d812c2997c
10 changed files with 34 additions and 41 deletions

View file

@ -1647,7 +1647,7 @@ static int32_t polymost_md3draw(md3model_t *m, tspriteptr_t tspr)
GLInterface.SetClamp(0);
VSMatrix imat = 0;
imat.scale(1024, 1024, 1024);
auto matrixindex = GLInterface.SetMatrix(Matrix_Model, &imat);
GLInterface.SetMatrix(Matrix_Model, &imat);
for (surfi=0; surfi<m->head.numsurfs; surfi++)
{
@ -1796,9 +1796,7 @@ static int32_t polymost_md3draw(md3model_t *m, tspriteptr_t tspr)
GLInterface.SetCull(Cull_None);
VSMatrix identity(0);
GLInterface.RestoreMatrix(Matrix_Model, matrixindex);
GLInterface.SetIdentityMatrix(Matrix_Model);
GLInterface.SetTinting(-1, 0xffffff, 0xffffff);
GLInterface.SetClamp(prevClamp);

View file

@ -209,7 +209,6 @@ static void resizeglcheck(void)
m[2][3] = 1.f;
m[3][2] = -(2.f * farclip * nearclip) / (farclip - nearclip);
renderSetProjectionMatrix(&m[0][0]);
GLInterface.SetIdentityMatrix(Matrix_Model);
}
//(dpx,dpy) specifies an n-sided polygon. The polygon must be a convex clockwise loop.

View file

@ -1124,7 +1124,7 @@ int32_t polymost_voxdraw(voxmodel_t *m, tspriteptr_t const tspr)
for (int i = 0; i < 15; i++) mat[i] *= 1024.f;
int matrixindex = GLInterface.SetMatrix(Matrix_Model, mat);
GLInterface.SetMatrix(Matrix_Model, mat);
const float ru = 1.f/((float)m->mytexx);
const float rv = 1.f/((float)m->mytexy);
@ -1217,8 +1217,7 @@ int32_t polymost_voxdraw(voxmodel_t *m, tspriteptr_t const tspr)
{
GLInterface.SetDepthFunc(Depth_Less);
}
VSMatrix identity(0);
GLInterface.RestoreMatrix(Matrix_Model, matrixindex);
GLInterface.SetIdentityMatrix(Matrix_Model);
GLInterface.SetFadeDisable(false);
GLInterface.SetTinting(-1, 0xffffff, 0xffffff);
return 1;

View file

@ -151,10 +151,10 @@ bool PolymostShader::Load(const char * name, const char * vert_prog, const char
TintModulate.Init(hShader, "u_tintModulate");
TintOverlay.Init(hShader, "u_tintOverlay");
TintFlags.Init(hShader, "u_tintFlags");
DetailParms.Init(hShader, "u_detailParms");
ModelMatrix.Init(hShader, "u_modelMatrix");
TextureMatrix.Init(hShader, "u_textureMatrix");
DetailParms.Init(hShader, "uDetailParms");
ModelMatrix.Init(hShader, "ModelMatrix");
TextureMatrix.Init(hShader, "TextureMatrix");

View file

@ -48,7 +48,7 @@ public:
FBufferedUniformPalEntry TintModulate;
FBufferedUniformPalEntry TintOverlay;
FBufferedUniform1i TintFlags;
FBufferedUniform2f DetailParms;
FBufferedUniform4f DetailParms;
FUniformMatrix4f ModelMatrix;

View file

@ -101,24 +101,28 @@ void GLInstance::Init(int ydim)
}
FString i_data = R"(
#version 330
// This must match the HWViewpointUniforms struct
layout(std140) uniform ViewpointUBO {
mat4 ProjectionMatrix;
mat4 ViewMatrix;
mat4 NormalViewMatrix;
#version 330
// This must match the HWViewpointUniforms struct
layout(std140) uniform ViewpointUBO {
mat4 ProjectionMatrix;
mat4 ViewMatrix;
mat4 NormalViewMatrix;
vec4 uCameraPos;
vec4 uClipLine;
vec4 uCameraPos;
vec4 uClipLine;
float uGlobVis; // uGlobVis = R_GetGlobVis(r_visibility) / 32.0
int uPalLightLevels;
int uViewHeight; // Software fuzz scaling
float uClipHeight;
float uClipHeightDirection;
int uShadowmapFilter;
};
)";
float uGlobVis; // uGlobVis = R_GetGlobVis(r_visibility) / 32.0
int uPalLightLevels;
int uViewHeight; // Software fuzz scaling
float uClipHeight;
float uClipHeightDirection;
int uShadowmapFilter;
};
uniform mat4 ModelMatrix;
uniform mat4 NormalModelMatrix;
uniform mat4 TextureMatrix;
uniform vec4 uDetailParms;
)";
void GLInstance::LoadPolymostShader()
{
@ -374,7 +378,8 @@ void PolymostRenderState::Apply(PolymostShader* shader, GLState &oldState)
{
mMaterial.mChanged = false;
ApplyMaterial(mMaterial.mMaterial, mMaterial.mClampMode, mMaterial.mTranslation, mMaterial.mOverrideShader);
shader->DetailParms.Set(mMaterial.mMaterial->GetDetailScale().X, mMaterial.mMaterial->GetDetailScale().Y);
float buffer[] = { mMaterial.mMaterial->GetDetailScale().X, mMaterial.mMaterial->GetDetailScale().Y, 1.f, 0.f };
shader->DetailParms.Set(buffer);
}
if (PaletteTexture != nullptr)
@ -524,8 +529,6 @@ void PolymostRenderState::Apply(PolymostShader* shader, GLState &oldState)
shader->FullscreenTint.Set(fullscreenTint);
if (matrixIndex[Matrix_Model] != -1)
shader->ModelMatrix.Set(matrixArray[matrixIndex[Matrix_Model]].get());
if (matrixIndex[Matrix_Texture] != -1)
shader->TextureMatrix.Set(matrixArray[matrixIndex[Matrix_Texture]].get());
memset(matrixIndex, -1, sizeof(matrixIndex));
}
@ -553,7 +556,6 @@ void WriteSavePic(FileWriter* file, int width, int height)
OpenGLRenderer::GLRenderer->mBuffers->BindSceneFB(false);
screen->SetViewportRects(&bounds);
int oldx = xdim;
int oldy = ydim;
auto oldwindowxy1 = windowxy1;

View file

@ -106,7 +106,6 @@ void GLInstance::Draw2D(F2DDrawer *drawer)
{
VSMatrix mat(0);
screen->mViewpoints->Set2D(OpenGLRenderer::gl_RenderState, xdim, ydim);
SetIdentityMatrix(Matrix_Model);
SetViewport(0, 0, xdim, ydim);
EnableDepthTest(false);
EnableMultisampling(false);

View file

@ -10,7 +10,6 @@ class FMaterial;
enum EMatrixType
{
Matrix_Model,
Matrix_Texture,
// These are the only ones being used.
NUMMATRICES
};
@ -67,7 +66,7 @@ struct PolymostRenderState
float AlphaThreshold = 0.5f;
bool AlphaTest = true;
float Color[4] = { 1,1,1,1 };
short matrixIndex[NUMMATRICES] = { 0,0 };
short matrixIndex[NUMMATRICES] = { 0 };
PalEntry fullscreenTint = 0xffffff, hictint = 0xffffff, hictint_overlay = 0xffffff;
int hictint_flags = -1;
FDepthBiasState mBias{ };

View file

@ -38,7 +38,6 @@ uniform float u_alphaThreshold;
uniform vec4 u_tintOverlay, u_tintModulate;
uniform int u_tintFlags;
uniform vec4 u_fullscreenTint;
uniform vec2 u_detailParms;
uniform float u_npotEmulationFactor;
uniform float u_npotEmulationXOffset;
@ -170,7 +169,7 @@ void main()
vec4 detailColor = vec4(1.0);
if ((u_flags & RF_DetailMapping) != 0)
{
detailColor = texture(s_detail, newCoord * u_detailParms);
detailColor = texture(s_detail, newCoord * uDetailParms.xy) * uDetailParms.z;
detailColor = mix(vec4(1.0), 2.0 * detailColor, detailColor.a);
// Application of this differs based on render mode because for paletted rendering with palettized shade tables it can only be done after processing the shade table. We only have a palette index before.
}

View file

@ -5,8 +5,6 @@ out float v_fogCoord;
out vec4 v_eyeCoordPosition;
uniform float u_usePalette;
uniform mat4 u_modelMatrix;
uniform mat4 u_textureMatrix;
in vec4 i_vertPos;
in vec4 i_texCoord;
@ -16,14 +14,14 @@ in vec4 i_color;
void main()
{
vec4 vertex = u_modelMatrix * i_vertPos;
vec4 vertex = ModelMatrix * i_vertPos;
vec4 eyeCoordPosition = ViewMatrix * vertex;
v_eyeCoordPosition = eyeCoordPosition;
gl_Position = ProjectionMatrix * eyeCoordPosition;
eyeCoordPosition.xyz /= eyeCoordPosition.w;
v_texCoord = u_textureMatrix * i_texCoord;
v_texCoord = TextureMatrix * i_texCoord;
v_fogCoord = abs(eyeCoordPosition.z);