mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-28 12:30:46 +00:00
- start renaming uniforms to match GZDoom.
Needed to allow using the same shader with the backend.
This commit is contained in:
parent
d92f56f36f
commit
d812c2997c
10 changed files with 34 additions and 41 deletions
|
@ -1647,7 +1647,7 @@ static int32_t polymost_md3draw(md3model_t *m, tspriteptr_t tspr)
|
||||||
GLInterface.SetClamp(0);
|
GLInterface.SetClamp(0);
|
||||||
VSMatrix imat = 0;
|
VSMatrix imat = 0;
|
||||||
imat.scale(1024, 1024, 1024);
|
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++)
|
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);
|
GLInterface.SetCull(Cull_None);
|
||||||
|
|
||||||
VSMatrix identity(0);
|
GLInterface.SetIdentityMatrix(Matrix_Model);
|
||||||
GLInterface.RestoreMatrix(Matrix_Model, matrixindex);
|
|
||||||
|
|
||||||
GLInterface.SetTinting(-1, 0xffffff, 0xffffff);
|
GLInterface.SetTinting(-1, 0xffffff, 0xffffff);
|
||||||
GLInterface.SetClamp(prevClamp);
|
GLInterface.SetClamp(prevClamp);
|
||||||
|
|
||||||
|
|
|
@ -209,7 +209,6 @@ static void resizeglcheck(void)
|
||||||
m[2][3] = 1.f;
|
m[2][3] = 1.f;
|
||||||
m[3][2] = -(2.f * farclip * nearclip) / (farclip - nearclip);
|
m[3][2] = -(2.f * farclip * nearclip) / (farclip - nearclip);
|
||||||
renderSetProjectionMatrix(&m[0][0]);
|
renderSetProjectionMatrix(&m[0][0]);
|
||||||
GLInterface.SetIdentityMatrix(Matrix_Model);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//(dpx,dpy) specifies an n-sided polygon. The polygon must be a convex clockwise loop.
|
//(dpx,dpy) specifies an n-sided polygon. The polygon must be a convex clockwise loop.
|
||||||
|
|
|
@ -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;
|
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 ru = 1.f/((float)m->mytexx);
|
||||||
const float rv = 1.f/((float)m->mytexy);
|
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);
|
GLInterface.SetDepthFunc(Depth_Less);
|
||||||
}
|
}
|
||||||
VSMatrix identity(0);
|
GLInterface.SetIdentityMatrix(Matrix_Model);
|
||||||
GLInterface.RestoreMatrix(Matrix_Model, matrixindex);
|
|
||||||
GLInterface.SetFadeDisable(false);
|
GLInterface.SetFadeDisable(false);
|
||||||
GLInterface.SetTinting(-1, 0xffffff, 0xffffff);
|
GLInterface.SetTinting(-1, 0xffffff, 0xffffff);
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
@ -151,10 +151,10 @@ bool PolymostShader::Load(const char * name, const char * vert_prog, const char
|
||||||
TintModulate.Init(hShader, "u_tintModulate");
|
TintModulate.Init(hShader, "u_tintModulate");
|
||||||
TintOverlay.Init(hShader, "u_tintOverlay");
|
TintOverlay.Init(hShader, "u_tintOverlay");
|
||||||
TintFlags.Init(hShader, "u_tintFlags");
|
TintFlags.Init(hShader, "u_tintFlags");
|
||||||
DetailParms.Init(hShader, "u_detailParms");
|
|
||||||
|
|
||||||
ModelMatrix.Init(hShader, "u_modelMatrix");
|
DetailParms.Init(hShader, "uDetailParms");
|
||||||
TextureMatrix.Init(hShader, "u_textureMatrix");
|
ModelMatrix.Init(hShader, "ModelMatrix");
|
||||||
|
TextureMatrix.Init(hShader, "TextureMatrix");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@ public:
|
||||||
FBufferedUniformPalEntry TintModulate;
|
FBufferedUniformPalEntry TintModulate;
|
||||||
FBufferedUniformPalEntry TintOverlay;
|
FBufferedUniformPalEntry TintOverlay;
|
||||||
FBufferedUniform1i TintFlags;
|
FBufferedUniform1i TintFlags;
|
||||||
FBufferedUniform2f DetailParms;
|
FBufferedUniform4f DetailParms;
|
||||||
|
|
||||||
|
|
||||||
FUniformMatrix4f ModelMatrix;
|
FUniformMatrix4f ModelMatrix;
|
||||||
|
|
|
@ -101,24 +101,28 @@ void GLInstance::Init(int ydim)
|
||||||
}
|
}
|
||||||
|
|
||||||
FString i_data = R"(
|
FString i_data = R"(
|
||||||
#version 330
|
#version 330
|
||||||
// This must match the HWViewpointUniforms struct
|
// This must match the HWViewpointUniforms struct
|
||||||
layout(std140) uniform ViewpointUBO {
|
layout(std140) uniform ViewpointUBO {
|
||||||
mat4 ProjectionMatrix;
|
mat4 ProjectionMatrix;
|
||||||
mat4 ViewMatrix;
|
mat4 ViewMatrix;
|
||||||
mat4 NormalViewMatrix;
|
mat4 NormalViewMatrix;
|
||||||
|
|
||||||
vec4 uCameraPos;
|
vec4 uCameraPos;
|
||||||
vec4 uClipLine;
|
vec4 uClipLine;
|
||||||
|
|
||||||
float uGlobVis; // uGlobVis = R_GetGlobVis(r_visibility) / 32.0
|
float uGlobVis; // uGlobVis = R_GetGlobVis(r_visibility) / 32.0
|
||||||
int uPalLightLevels;
|
int uPalLightLevels;
|
||||||
int uViewHeight; // Software fuzz scaling
|
int uViewHeight; // Software fuzz scaling
|
||||||
float uClipHeight;
|
float uClipHeight;
|
||||||
float uClipHeightDirection;
|
float uClipHeightDirection;
|
||||||
int uShadowmapFilter;
|
int uShadowmapFilter;
|
||||||
};
|
};
|
||||||
)";
|
uniform mat4 ModelMatrix;
|
||||||
|
uniform mat4 NormalModelMatrix;
|
||||||
|
uniform mat4 TextureMatrix;
|
||||||
|
uniform vec4 uDetailParms;
|
||||||
|
)";
|
||||||
|
|
||||||
void GLInstance::LoadPolymostShader()
|
void GLInstance::LoadPolymostShader()
|
||||||
{
|
{
|
||||||
|
@ -374,7 +378,8 @@ void PolymostRenderState::Apply(PolymostShader* shader, GLState &oldState)
|
||||||
{
|
{
|
||||||
mMaterial.mChanged = false;
|
mMaterial.mChanged = false;
|
||||||
ApplyMaterial(mMaterial.mMaterial, mMaterial.mClampMode, mMaterial.mTranslation, mMaterial.mOverrideShader);
|
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)
|
if (PaletteTexture != nullptr)
|
||||||
|
@ -524,8 +529,6 @@ void PolymostRenderState::Apply(PolymostShader* shader, GLState &oldState)
|
||||||
shader->FullscreenTint.Set(fullscreenTint);
|
shader->FullscreenTint.Set(fullscreenTint);
|
||||||
if (matrixIndex[Matrix_Model] != -1)
|
if (matrixIndex[Matrix_Model] != -1)
|
||||||
shader->ModelMatrix.Set(matrixArray[matrixIndex[Matrix_Model]].get());
|
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));
|
memset(matrixIndex, -1, sizeof(matrixIndex));
|
||||||
}
|
}
|
||||||
|
@ -553,7 +556,6 @@ void WriteSavePic(FileWriter* file, int width, int height)
|
||||||
OpenGLRenderer::GLRenderer->mBuffers->BindSceneFB(false);
|
OpenGLRenderer::GLRenderer->mBuffers->BindSceneFB(false);
|
||||||
screen->SetViewportRects(&bounds);
|
screen->SetViewportRects(&bounds);
|
||||||
|
|
||||||
|
|
||||||
int oldx = xdim;
|
int oldx = xdim;
|
||||||
int oldy = ydim;
|
int oldy = ydim;
|
||||||
auto oldwindowxy1 = windowxy1;
|
auto oldwindowxy1 = windowxy1;
|
||||||
|
|
|
@ -106,7 +106,6 @@ void GLInstance::Draw2D(F2DDrawer *drawer)
|
||||||
{
|
{
|
||||||
VSMatrix mat(0);
|
VSMatrix mat(0);
|
||||||
screen->mViewpoints->Set2D(OpenGLRenderer::gl_RenderState, xdim, ydim);
|
screen->mViewpoints->Set2D(OpenGLRenderer::gl_RenderState, xdim, ydim);
|
||||||
SetIdentityMatrix(Matrix_Model);
|
|
||||||
SetViewport(0, 0, xdim, ydim);
|
SetViewport(0, 0, xdim, ydim);
|
||||||
EnableDepthTest(false);
|
EnableDepthTest(false);
|
||||||
EnableMultisampling(false);
|
EnableMultisampling(false);
|
||||||
|
|
|
@ -10,7 +10,6 @@ class FMaterial;
|
||||||
enum EMatrixType
|
enum EMatrixType
|
||||||
{
|
{
|
||||||
Matrix_Model,
|
Matrix_Model,
|
||||||
Matrix_Texture,
|
|
||||||
// These are the only ones being used.
|
// These are the only ones being used.
|
||||||
NUMMATRICES
|
NUMMATRICES
|
||||||
};
|
};
|
||||||
|
@ -67,7 +66,7 @@ struct PolymostRenderState
|
||||||
float AlphaThreshold = 0.5f;
|
float AlphaThreshold = 0.5f;
|
||||||
bool AlphaTest = true;
|
bool AlphaTest = true;
|
||||||
float Color[4] = { 1,1,1,1 };
|
float Color[4] = { 1,1,1,1 };
|
||||||
short matrixIndex[NUMMATRICES] = { 0,0 };
|
short matrixIndex[NUMMATRICES] = { 0 };
|
||||||
PalEntry fullscreenTint = 0xffffff, hictint = 0xffffff, hictint_overlay = 0xffffff;
|
PalEntry fullscreenTint = 0xffffff, hictint = 0xffffff, hictint_overlay = 0xffffff;
|
||||||
int hictint_flags = -1;
|
int hictint_flags = -1;
|
||||||
FDepthBiasState mBias{ };
|
FDepthBiasState mBias{ };
|
||||||
|
|
|
@ -38,7 +38,6 @@ uniform float u_alphaThreshold;
|
||||||
uniform vec4 u_tintOverlay, u_tintModulate;
|
uniform vec4 u_tintOverlay, u_tintModulate;
|
||||||
uniform int u_tintFlags;
|
uniform int u_tintFlags;
|
||||||
uniform vec4 u_fullscreenTint;
|
uniform vec4 u_fullscreenTint;
|
||||||
uniform vec2 u_detailParms;
|
|
||||||
|
|
||||||
uniform float u_npotEmulationFactor;
|
uniform float u_npotEmulationFactor;
|
||||||
uniform float u_npotEmulationXOffset;
|
uniform float u_npotEmulationXOffset;
|
||||||
|
@ -170,7 +169,7 @@ void main()
|
||||||
vec4 detailColor = vec4(1.0);
|
vec4 detailColor = vec4(1.0);
|
||||||
if ((u_flags & RF_DetailMapping) != 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);
|
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.
|
// 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.
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,8 +5,6 @@ out float v_fogCoord;
|
||||||
out vec4 v_eyeCoordPosition;
|
out vec4 v_eyeCoordPosition;
|
||||||
|
|
||||||
uniform float u_usePalette;
|
uniform float u_usePalette;
|
||||||
uniform mat4 u_modelMatrix;
|
|
||||||
uniform mat4 u_textureMatrix;
|
|
||||||
|
|
||||||
in vec4 i_vertPos;
|
in vec4 i_vertPos;
|
||||||
in vec4 i_texCoord;
|
in vec4 i_texCoord;
|
||||||
|
@ -16,14 +14,14 @@ in vec4 i_color;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
vec4 vertex = u_modelMatrix * i_vertPos;
|
vec4 vertex = ModelMatrix * i_vertPos;
|
||||||
vec4 eyeCoordPosition = ViewMatrix * vertex;
|
vec4 eyeCoordPosition = ViewMatrix * vertex;
|
||||||
v_eyeCoordPosition = eyeCoordPosition;
|
v_eyeCoordPosition = eyeCoordPosition;
|
||||||
gl_Position = ProjectionMatrix * eyeCoordPosition;
|
gl_Position = ProjectionMatrix * eyeCoordPosition;
|
||||||
|
|
||||||
eyeCoordPosition.xyz /= eyeCoordPosition.w;
|
eyeCoordPosition.xyz /= eyeCoordPosition.w;
|
||||||
|
|
||||||
v_texCoord = u_textureMatrix * i_texCoord;
|
v_texCoord = TextureMatrix * i_texCoord;
|
||||||
|
|
||||||
v_fogCoord = abs(eyeCoordPosition.z);
|
v_fogCoord = abs(eyeCoordPosition.z);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue