mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-28 12:30:46 +00:00
- replaced detail matrix with a two element scale vector because that is all that is needed.
This commit is contained in:
parent
d752e33909
commit
bd0c8acd46
8 changed files with 20 additions and 19 deletions
|
@ -83,30 +83,30 @@ FMaterial::FMaterial(FGameTexture * tx, int scaleflags)
|
||||||
auto placeholder = TexMan.GameByIndex(1);
|
auto placeholder = TexMan.GameByIndex(1);
|
||||||
if (tx->Brightmap.get())
|
if (tx->Brightmap.get())
|
||||||
{
|
{
|
||||||
mTextureLayers.Push({ tx->Brightmap.get(), scaleflags });
|
mTextureLayers.Push({ tx->Brightmap.get(), scaleflags, -1 });
|
||||||
mLayerFlags |= TEXF_Brightmap;
|
mLayerFlags |= TEXF_Brightmap;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mTextureLayers.Push({ placeholder->GetTexture(), 0 });
|
mTextureLayers.Push({ placeholder->GetTexture(), 0, -1 });
|
||||||
}
|
}
|
||||||
if (tx->Detailmap.get())
|
if (tx->Detailmap.get())
|
||||||
{
|
{
|
||||||
mTextureLayers.Push({ tx->Detailmap.get(), 0 });
|
mTextureLayers.Push({ tx->Detailmap.get(), 0, CLAMP_NONE });
|
||||||
mLayerFlags |= TEXF_Detailmap;
|
mLayerFlags |= TEXF_Detailmap;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mTextureLayers.Push({ placeholder->GetTexture(), 0 });
|
mTextureLayers.Push({ placeholder->GetTexture(), 0, -1 });
|
||||||
}
|
}
|
||||||
if (tx->Glowmap.get())
|
if (tx->Glowmap.get())
|
||||||
{
|
{
|
||||||
mTextureLayers.Push({ tx->Glowmap.get(), scaleflags });
|
mTextureLayers.Push({ tx->Glowmap.get(), scaleflags, -1 });
|
||||||
mLayerFlags |= TEXF_Glowmap;
|
mLayerFlags |= TEXF_Glowmap;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mTextureLayers.Push({ placeholder->GetTexture(), 0 });
|
mTextureLayers.Push({ placeholder->GetTexture(), 0, -1 });
|
||||||
}
|
}
|
||||||
|
|
||||||
auto index = tx->GetShaderIndex();
|
auto index = tx->GetShaderIndex();
|
||||||
|
|
|
@ -12,6 +12,7 @@ struct MaterialLayerInfo
|
||||||
{
|
{
|
||||||
FTexture* layerTexture;
|
FTexture* layerTexture;
|
||||||
int scaleFlags;
|
int scaleFlags;
|
||||||
|
int clampflags;
|
||||||
};
|
};
|
||||||
|
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
|
@ -37,6 +38,10 @@ public:
|
||||||
int GetShaderIndex() const { return mShaderIndex; }
|
int GetShaderIndex() const { return mShaderIndex; }
|
||||||
int GetScaleFlags() const { return mScaleFlags; }
|
int GetScaleFlags() const { return mScaleFlags; }
|
||||||
virtual void DeleteDescriptors() { }
|
virtual void DeleteDescriptors() { }
|
||||||
|
FVector2 GetDetailScale() const
|
||||||
|
{
|
||||||
|
return sourcetex->GetDetailScale();
|
||||||
|
}
|
||||||
|
|
||||||
FGameTexture* Source() const
|
FGameTexture* Source() const
|
||||||
{
|
{
|
||||||
|
|
|
@ -148,11 +148,11 @@ 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");
|
||||||
|
|
||||||
RotMatrix.Init(hShader, "u_rotMatrix");
|
RotMatrix.Init(hShader, "u_rotMatrix");
|
||||||
ModelMatrix.Init(hShader, "u_modelMatrix");
|
ModelMatrix.Init(hShader, "u_modelMatrix");
|
||||||
ProjectionMatrix.Init(hShader, "u_projectionMatrix");
|
ProjectionMatrix.Init(hShader, "u_projectionMatrix");
|
||||||
DetailMatrix.Init(hShader, "u_detailMatrix");
|
|
||||||
TextureMatrix.Init(hShader, "u_textureMatrix");
|
TextureMatrix.Init(hShader, "u_textureMatrix");
|
||||||
|
|
||||||
|
|
||||||
|
@ -161,7 +161,6 @@ bool PolymostShader::Load(const char * name, const char * vert_prog, const char
|
||||||
|
|
||||||
VSMatrix identity(0);
|
VSMatrix identity(0);
|
||||||
TextureMatrix.Set(identity.get());
|
TextureMatrix.Set(identity.get());
|
||||||
DetailMatrix.Set(identity.get());
|
|
||||||
|
|
||||||
int SamplerLoc;
|
int SamplerLoc;
|
||||||
SamplerLoc = glGetUniformLocation(hShader, "s_texture");
|
SamplerLoc = glGetUniformLocation(hShader, "s_texture");
|
||||||
|
|
|
@ -49,12 +49,12 @@ public:
|
||||||
FBufferedUniformPalEntry TintModulate;
|
FBufferedUniformPalEntry TintModulate;
|
||||||
FBufferedUniformPalEntry TintOverlay;
|
FBufferedUniformPalEntry TintOverlay;
|
||||||
FBufferedUniform1i TintFlags;
|
FBufferedUniform1i TintFlags;
|
||||||
|
FBufferedUniform2f DetailParms;
|
||||||
|
|
||||||
|
|
||||||
FUniformMatrix4f RotMatrix;
|
FUniformMatrix4f RotMatrix;
|
||||||
FUniformMatrix4f ModelMatrix;
|
FUniformMatrix4f ModelMatrix;
|
||||||
FUniformMatrix4f ProjectionMatrix;
|
FUniformMatrix4f ProjectionMatrix;
|
||||||
FUniformMatrix4f DetailMatrix;
|
|
||||||
FUniformMatrix4f TextureMatrix;
|
FUniformMatrix4f TextureMatrix;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -194,7 +194,6 @@ void GLInstance::Draw(EDrawType type, size_t start, size_t count)
|
||||||
rendercommands.Push(renderState);
|
rendercommands.Push(renderState);
|
||||||
clearMapFog();
|
clearMapFog();
|
||||||
SetIdentityMatrix(Matrix_Texture);
|
SetIdentityMatrix(Matrix_Texture);
|
||||||
SetIdentityMatrix(Matrix_Detail);
|
|
||||||
renderState.StateFlags &= ~(STF_CLEARCOLOR | STF_CLEARDEPTH | STF_VIEWPORTSET | STF_SCISSORSET);
|
renderState.StateFlags &= ~(STF_CLEARCOLOR | STF_CLEARDEPTH | STF_VIEWPORTSET | STF_SCISSORSET);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -312,16 +311,17 @@ void PolymostRenderState::ApplyMaterial(FMaterial* mat, int clampmode, int trans
|
||||||
MaterialLayerInfo* layer;
|
MaterialLayerInfo* layer;
|
||||||
auto base = static_cast<OpenGLRenderer::FHardwareTexture*>(mat->GetLayer(0, translation, &layer));
|
auto base = static_cast<OpenGLRenderer::FHardwareTexture*>(mat->GetLayer(0, translation, &layer));
|
||||||
scf |= layer->scaleFlags;
|
scf |= layer->scaleFlags;
|
||||||
if (base->BindOrCreate(layer->layerTexture, 0, clampmode, translation, scf))
|
if (base->BindOrCreate(layer->layerTexture, 0, layer->clampflags == -1? clampmode : layer->clampflags, translation, scf))
|
||||||
{
|
{
|
||||||
for (int i = 1; i < numLayers; i++)
|
for (int i = 1; i < numLayers; i++)
|
||||||
{
|
{
|
||||||
auto systex = static_cast<OpenGLRenderer::FHardwareTexture*>(mat->GetLayer(i, 0, &layer));
|
auto systex = static_cast<OpenGLRenderer::FHardwareTexture*>(mat->GetLayer(i, 0, &layer));
|
||||||
// fixme: Upscale flags must be disabled for certain layers.
|
// fixme: Upscale flags must be disabled for certain layers.
|
||||||
systex->BindOrCreate(layer->layerTexture, i, clampmode, 0, layer->scaleFlags);
|
systex->BindOrCreate(layer->layerTexture, i, layer->clampflags == -1 ? clampmode : layer->clampflags, 0, layer->scaleFlags);
|
||||||
maxbound = i;
|
maxbound = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// The palette lookup must be done manually.
|
// The palette lookup must be done manually.
|
||||||
#if 0
|
#if 0
|
||||||
// unbind everything from the last texture that's still active
|
// unbind everything from the last texture that's still active
|
||||||
|
@ -343,6 +343,7 @@ 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PaletteTexture != nullptr)
|
if (PaletteTexture != nullptr)
|
||||||
|
@ -497,8 +498,6 @@ void PolymostRenderState::Apply(PolymostShader* shader, GLState &oldState)
|
||||||
shader->ProjectionMatrix.Set(matrixArray[matrixIndex[Matrix_Projection]].get());
|
shader->ProjectionMatrix.Set(matrixArray[matrixIndex[Matrix_Projection]].get());
|
||||||
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_Detail] != -1)
|
|
||||||
shader->DetailMatrix.Set(matrixArray[matrixIndex[Matrix_Detail]].get());
|
|
||||||
if (matrixIndex[Matrix_Texture] != -1)
|
if (matrixIndex[Matrix_Texture] != -1)
|
||||||
shader->TextureMatrix.Set(matrixArray[matrixIndex[Matrix_Texture]].get());
|
shader->TextureMatrix.Set(matrixArray[matrixIndex[Matrix_Texture]].get());
|
||||||
memset(matrixIndex, -1, sizeof(matrixIndex));
|
memset(matrixIndex, -1, sizeof(matrixIndex));
|
||||||
|
|
|
@ -104,7 +104,6 @@ void GLInstance::Draw2D(F2DDrawer *drawer)
|
||||||
VSMatrix mat(0);
|
VSMatrix mat(0);
|
||||||
SetIdentityMatrix(Matrix_View);
|
SetIdentityMatrix(Matrix_View);
|
||||||
SetIdentityMatrix(Matrix_Model);
|
SetIdentityMatrix(Matrix_Model);
|
||||||
SetIdentityMatrix(Matrix_Detail);
|
|
||||||
mat.ortho(0, xdim, ydim, 0, -1, 1);
|
mat.ortho(0, xdim, ydim, 0, -1, 1);
|
||||||
SetMatrix(Matrix_Projection, mat.get());
|
SetMatrix(Matrix_Projection, mat.get());
|
||||||
SetViewport(0, 0, xdim, ydim);
|
SetViewport(0, 0, xdim, ydim);
|
||||||
|
|
|
@ -12,7 +12,6 @@ enum EMatrixType
|
||||||
Matrix_View,
|
Matrix_View,
|
||||||
Matrix_Projection,
|
Matrix_Projection,
|
||||||
Matrix_Model,
|
Matrix_Model,
|
||||||
Matrix_Detail,
|
|
||||||
Matrix_Texture,
|
Matrix_Texture,
|
||||||
// These are the only ones being used.
|
// These are the only ones being used.
|
||||||
NUMMATRICES
|
NUMMATRICES
|
||||||
|
@ -71,7 +70,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,0,0,0 };
|
short matrixIndex[NUMMATRICES] = { 0,0,0,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{ };
|
||||||
|
|
|
@ -11,8 +11,8 @@ uniform float u_usePalette;
|
||||||
uniform mat4 u_rotMatrix;
|
uniform mat4 u_rotMatrix;
|
||||||
uniform mat4 u_modelMatrix;
|
uniform mat4 u_modelMatrix;
|
||||||
uniform mat4 u_projectionMatrix;
|
uniform mat4 u_projectionMatrix;
|
||||||
uniform mat4 u_detailMatrix;
|
|
||||||
uniform mat4 u_textureMatrix;
|
uniform mat4 u_textureMatrix;
|
||||||
|
uniform vec2 u_detailParms;
|
||||||
|
|
||||||
in vec4 i_vertPos;
|
in vec4 i_vertPos;
|
||||||
in vec4 i_texCoord;
|
in vec4 i_texCoord;
|
||||||
|
@ -30,7 +30,7 @@ void main()
|
||||||
eyeCoordPosition.xyz /= eyeCoordPosition.w;
|
eyeCoordPosition.xyz /= eyeCoordPosition.w;
|
||||||
|
|
||||||
v_texCoord = u_textureMatrix * i_texCoord;
|
v_texCoord = u_textureMatrix * i_texCoord;
|
||||||
v_detailCoord = u_detailMatrix * i_texCoord;
|
v_detailCoord = vec4(i_texCoord.x * u_detailParms.x, i_texCoord.y * u_detailParms.y, 0.0, 0.0);
|
||||||
|
|
||||||
v_fogCoord = abs(eyeCoordPosition.z);
|
v_fogCoord = abs(eyeCoordPosition.z);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue