mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-28 12:30:46 +00:00
- split texture selection from binding.
This commit is contained in:
parent
1bc744b77b
commit
2c94b2bb6d
2 changed files with 48 additions and 71 deletions
|
@ -3063,7 +3063,7 @@ void twod_rotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16_t pic
|
||||||
F2DDrawer::RenderCommand dg = {};
|
F2DDrawer::RenderCommand dg = {};
|
||||||
int method = 0;
|
int method = 0;
|
||||||
|
|
||||||
dg.mTranslationId = TRANSLATION(Translation_Remap + basepal, dapalnum);
|
dg.mTranslationId = pic? 0 : TRANSLATION(Translation_Remap + basepal, dapalnum);
|
||||||
dg.mType = F2DDrawer::DrawTypeTriangles;
|
dg.mType = F2DDrawer::DrawTypeTriangles;
|
||||||
if (clipx1 > 0 || clipy1 > 0 || clipx2 < screen->GetWidth() - 1 || clipy2 < screen->GetHeight() - 1)
|
if (clipx1 > 0 || clipy1 > 0 || clipx2 < screen->GetWidth() - 1 || clipy2 < screen->GetHeight() - 1)
|
||||||
{
|
{
|
||||||
|
|
|
@ -80,73 +80,21 @@ struct TexturePick
|
||||||
PalEntry basepalTint; // can the base palette be done with a global tint effect?
|
PalEntry basepalTint; // can the base palette be done with a global tint effect?
|
||||||
};
|
};
|
||||||
|
|
||||||
#if 0
|
bool PickTexture(int picnum, FGameTexture *tex, int paletteid, TexturePick &pick)
|
||||||
TexturePick PickTexture(int tilenum, int basepal, int palette)
|
|
||||||
{
|
{
|
||||||
TexturePick pick = { nullptr, 0, -1, 0xffffff, 0xffffff };
|
if (!tex) tex = tileGetTexture(picnum);
|
||||||
int usepalette = fixpalette >= 0 ? fixpalette : basepal;
|
if (picnum == -1) picnum = TileFiles.GetTileIndex(tex); // Allow getting replacements also when the texture is not passed by its tile number.
|
||||||
int usepalswap = fixpalswap >= 0 ? fixpalswap : palette;
|
|
||||||
auto& h = hictinting[palette];
|
|
||||||
auto tex = TileFiles.tiles[tilenum];
|
|
||||||
auto rep = (hw_hightile && !(h.tintFlags & TINTF_ALWAYSUSEART)) ? TileFiles.FindReplacement(tilenum, usepalswap) : nullptr;
|
|
||||||
// Canvas textures must be treated like hightile replacements in the following code.
|
|
||||||
bool truecolor = rep || tex->GetUseType() == FGameTexture::Canvas;
|
|
||||||
bool applytint = false;
|
|
||||||
if (truecolor)
|
|
||||||
{
|
|
||||||
if (usepalette != 0)
|
|
||||||
{
|
|
||||||
// This is a global setting for the entire scene, so let's do it here, right at the start. (Fixme: Store this in a static table instead of reusing the same entry for all palettes.)
|
|
||||||
auto& hh = hictinting[MAXPALOOKUPS - 1];
|
|
||||||
// This sets a tinting color for global palettes, e.g. water or slime - only used for hires replacements (also an option for low-resource hardware where duplicating the textures may be problematic.)
|
|
||||||
pick.basepalTint = hh.tint;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rep)
|
|
||||||
{
|
|
||||||
tex = rep->faces[0];
|
|
||||||
}
|
|
||||||
if (!rep || rep->palnum != palette || (h.tintFlags & TINTF_APPLYOVERALTPAL)) applytint = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Tinting is not used on indexed textures, unless explicitly requested
|
|
||||||
if (h.tintFlags & (TINTF_ALWAYSUSEART | TINTF_USEONART))
|
|
||||||
{
|
|
||||||
applytint = true;
|
|
||||||
if (!(h.tintFlags & TINTF_APPLYOVERPALSWAP)) usepalswap = 0;
|
|
||||||
}
|
|
||||||
pick.translation = TRANSLATION(usepalette + 1, usepalswap);
|
|
||||||
}
|
|
||||||
pick.texture = tex;
|
|
||||||
if (applytint && h.tintFlags)
|
|
||||||
{
|
|
||||||
pick.tintFlags = h.tintFlags;
|
|
||||||
pick.tintColor = h.tint;
|
|
||||||
}
|
|
||||||
return pick;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
bool GLInstance::SetTextureInternal(int picnum, FGameTexture* tex, int paletteid, int method, int sampleroverride, FGameTexture *det, float detscale, FGameTexture *glow)
|
|
||||||
{
|
|
||||||
if (!tex->isValid() || tex->GetTexelWidth() <= 0 || tex->GetTexelHeight() <= 0) return false;
|
if (!tex->isValid() || tex->GetTexelWidth() <= 0 || tex->GetTexelHeight() <= 0) return false;
|
||||||
|
pick.texture = tex;
|
||||||
int curbasepal = GetTranslationType(paletteid) - Translation_Remap;
|
int curbasepal = GetTranslationType(paletteid) - Translation_Remap;
|
||||||
int palette = GetTranslationIndex(paletteid);
|
int palette = GetTranslationIndex(paletteid);
|
||||||
int usepalette = fixpalette >= 0 ? fixpalette : curbasepal;
|
int usepalette = fixpalette >= 0 ? fixpalette : curbasepal;
|
||||||
int usepalswap = fixpalswap >= 0 ? fixpalswap : palette;
|
int usepalswap = fixpalswap >= 0 ? fixpalswap : palette;
|
||||||
GLInterface.SetPalette(usepalette);
|
int TextureType = hw_int_useindexedcolortextures ? TT_INDEXED : TT_TRUECOLOR;
|
||||||
GLInterface.SetPalswap(usepalswap);
|
|
||||||
bool texbound[3] = {};
|
|
||||||
int MatrixChange = 0;
|
|
||||||
|
|
||||||
TextureType = hw_int_useindexedcolortextures? TT_INDEXED : TT_TRUECOLOR;
|
pick.translation = TRANSLATION(usepalette + Translation_Remap, usepalswap);
|
||||||
|
pick.basepalTint = 0xffffff;
|
||||||
int lookuppal = 0;
|
|
||||||
int bindflags = 0;
|
|
||||||
VSMatrix texmat;
|
|
||||||
|
|
||||||
GLInterface.SetBasepalTint(0xffffff);
|
|
||||||
|
|
||||||
auto& h = lookups.tables[palette];
|
auto& h = lookups.tables[palette];
|
||||||
bool applytint = false;
|
bool applytint = false;
|
||||||
|
@ -160,7 +108,7 @@ bool GLInstance::SetTextureInternal(int picnum, FGameTexture* tex, int paletteid
|
||||||
// This is a global setting for the entire scene, so let's do it here, right at the start. (Fixme: Store this in a static table instead of reusing the same entry for all palettes.)
|
// This is a global setting for the entire scene, so let's do it here, right at the start. (Fixme: Store this in a static table instead of reusing the same entry for all palettes.)
|
||||||
auto& hh = lookups.tables[MAXPALOOKUPS - 1];
|
auto& hh = lookups.tables[MAXPALOOKUPS - 1];
|
||||||
// This sets a tinting color for global palettes, e.g. water or slime - only used for hires replacements (also an option for low-resource hardware where duplicating the textures may be problematic.)
|
// This sets a tinting color for global palettes, e.g. water or slime - only used for hires replacements (also an option for low-resource hardware where duplicating the textures may be problematic.)
|
||||||
GLInterface.SetBasepalTint(hh.tintColor);
|
pick.basepalTint = hh.tintColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rep)
|
if (rep)
|
||||||
|
@ -168,34 +116,60 @@ bool GLInstance::SetTextureInternal(int picnum, FGameTexture* tex, int paletteid
|
||||||
tex = rep->faces[0];
|
tex = rep->faces[0];
|
||||||
}
|
}
|
||||||
if (!rep || rep->palnum != palette || (h.tintFlags & TINTF_APPLYOVERALTPAL)) applytint = true;
|
if (!rep || rep->palnum != palette || (h.tintFlags & TINTF_APPLYOVERALTPAL)) applytint = true;
|
||||||
TextureType = TT_HICREPLACE;
|
pick.translation = 0;
|
||||||
bindflags = CTF_Upscale;
|
//TextureType = TT_HICREPLACE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Only look up the palette if we really want to use it (i.e. when creating a true color texture of an ART tile.)
|
// Only look up the palette if we really want to use it (i.e. when creating a true color texture of an ART tile.)
|
||||||
if (TextureType == TT_TRUECOLOR)
|
if (TextureType == TT_TRUECOLOR)
|
||||||
{
|
{
|
||||||
// Tinting is not used on indexed textures
|
|
||||||
if (h.tintFlags & (TINTF_ALWAYSUSEART | TINTF_USEONART))
|
if (h.tintFlags & (TINTF_ALWAYSUSEART | TINTF_USEONART))
|
||||||
{
|
{
|
||||||
applytint = true;
|
applytint = true;
|
||||||
if (!(h.tintFlags & TINTF_APPLYOVERPALSWAP)) usepalswap = 0;
|
if (!(h.tintFlags & TINTF_APPLYOVERPALSWAP)) usepalswap = 0;
|
||||||
}
|
}
|
||||||
lookuppal = TRANSLATION(usepalette + Translation_Remap, usepalswap);
|
pick.translation = TRANSLATION(usepalette + Translation_Remap, usepalswap);
|
||||||
bindflags = CTF_Upscale;
|
|
||||||
}
|
}
|
||||||
else bindflags = CTF_Indexed;
|
else pick.translation |= 0x80000000;
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is intentionally the same value for both parameters. The shader does not use the same uniform for modulation and overlay colors.
|
if (applytint && h.tintFlags)
|
||||||
if (applytint && h.tintFlags)
|
{
|
||||||
GLInterface.SetTinting(h.tintFlags, h.tintColor, h.tintColor);
|
pick.tintFlags = h.tintFlags;
|
||||||
else GLInterface.SetTinting(-1, 0xffffff, 0xffffff);
|
pick.tintColor = h.tintColor;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pick.tintFlags = -1;
|
||||||
|
pick.tintColor = 0xffffff;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GLInstance::SetTextureInternal(int picnum, FGameTexture* tex, int paletteid, int method, int sampleroverride, FGameTexture *det, float detscale, FGameTexture *glow)
|
||||||
|
{
|
||||||
|
TexturePick pick;
|
||||||
|
if (!PickTexture(picnum, tex, paletteid, pick)) return false;
|
||||||
|
|
||||||
|
GLInterface.SetPalette(GetTranslationType(pick.translation & 0x7fffffff) - Translation_Remap);
|
||||||
|
GLInterface.SetPalswap(GetTranslationIndex(pick.translation));
|
||||||
|
GLInterface.SetBasepalTint(pick.basepalTint);
|
||||||
|
|
||||||
|
bool texbound[3] = {};
|
||||||
|
//int MatrixChange = 0;
|
||||||
|
//VSMatrix texmat;
|
||||||
|
|
||||||
|
// This is intentionally the same value for both parameters. The shader does not use the same uniform for modulation and overlay colors.
|
||||||
|
GLInterface.SetTinting(pick.tintFlags, pick.tintColor, pick.tintColor);
|
||||||
|
|
||||||
// Load the main texture
|
// Load the main texture
|
||||||
|
|
||||||
|
int TextureType = (pick.translation & 0x80000000) ? TT_INDEXED : TT_TRUECOLOR;
|
||||||
|
int lookuppal = pick.translation & 0x7fffffff;
|
||||||
|
int bindflags = 0;
|
||||||
|
|
||||||
auto mtex = LoadTexture(tex->GetTexture(), TextureType, lookuppal);
|
auto mtex = LoadTexture(tex->GetTexture(), TextureType, lookuppal);
|
||||||
if (mtex)
|
if (mtex)
|
||||||
{
|
{
|
||||||
|
@ -203,6 +177,7 @@ bool GLInstance::SetTextureInternal(int picnum, FGameTexture* tex, int paletteid
|
||||||
if (TextureType == TT_INDEXED)
|
if (TextureType == TT_INDEXED)
|
||||||
{
|
{
|
||||||
sampler = sampler + SamplerNoFilterRepeat - SamplerRepeat;
|
sampler = sampler + SamplerNoFilterRepeat - SamplerRepeat;
|
||||||
|
bindflags = CTF_Indexed;
|
||||||
}
|
}
|
||||||
else if (tex->isHardwareCanvas())
|
else if (tex->isHardwareCanvas())
|
||||||
{
|
{
|
||||||
|
@ -215,12 +190,14 @@ bool GLInstance::SetTextureInternal(int picnum, FGameTexture* tex, int paletteid
|
||||||
mtex->BindOrCreate(tex->GetTexture(), 0, sampler, lookuppal, bindflags);
|
mtex->BindOrCreate(tex->GetTexture(), 0, sampler, lookuppal, bindflags);
|
||||||
BindTexture(0, mtex, sampler);
|
BindTexture(0, mtex, sampler);
|
||||||
// Needs a) testing and b) verification for correctness. This doesn't look like it makes sense.
|
// Needs a) testing and b) verification for correctness. This doesn't look like it makes sense.
|
||||||
|
#if 0
|
||||||
if (rep && (rep->scale.x != 1.0f || rep->scale.y != 1.0f))
|
if (rep && (rep->scale.x != 1.0f || rep->scale.y != 1.0f))
|
||||||
{
|
{
|
||||||
//texmat.loadIdentity();
|
//texmat.loadIdentity();
|
||||||
//texmat.scale(rep->scale.x, rep->scale.y, 1.0f);
|
//texmat.scale(rep->scale.x, rep->scale.y, 1.0f);
|
||||||
//GLInterface.SetMatrix(Matrix_Texture, &texmat);
|
//GLInterface.SetMatrix(Matrix_Texture, &texmat);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// Also load additional layers needed for this texture.
|
// Also load additional layers needed for this texture.
|
||||||
if (hw_detailmapping && hw_hightile && picnum > -1)
|
if (hw_detailmapping && hw_hightile && picnum > -1)
|
||||||
|
|
Loading…
Reference in a new issue