by Korshun » Mon Feb 11, 2019 2:59 pm
We have decided to fork GZDoom 3.7.2 to improve performance in The Forestale by implementing a leaner and faster renderer that doesn't support unneeded features. Its code will, of course, be released along with the game. We have commented out all OpenGL calls in GZDoom except those in FHardwareTexture::CreateTexture.
Unfortunately, there is a bug we can't figure out because of how complex GZDoom's texture system is. There are dozens of texture-related classes and it's mind-boggling, which is understandable, considering how many features the texture system supports, including but not limited to texture composing, HD texture replacements, transparently converting between palletized and truecolor formats, translations, font recoloring. I'd appeciate an explanation of how these classes are structured.
We have a problem with font recoloring. Fonts in The Forestale all have truecolor HD replacements. Untranslated fonts render fine, but all translated colorings of a multi-lump font glyph return the same HD texture with messed up colors. All those colors belong to the palette. Perhaps some GZDoom developer can tell what could cause such a bug. Any help is greatly appreciated.
Screenshots:
Menu icons are all in a font with HD replacements. Menu items are single-character strings using that font. The third item's HD replacement has been replaced with a 256x256 horizontal gradient from RGB(0, 0, 0) to RGB(255, 255, 255) for test purposes. Menu items are untranslated by default. The selected menu item is colored green.
Spoiler: GZDoom correctly recoloring menu items and text
Spoiler: Custom renderer receiving translated textures with messed up colors
The following code is used to obtain an OpenGL texture ID from an FTexture. Is it correct?
Spoiler: GetTextureID
Code: Select all
// Returns the OpenGL ID of an FTexture
GLuint GetTextureID(FTexture *tex, int translation)
{
FMaterial * mat = FMaterial::ValidateTexture(tex, false);
// There are no multi-layer textures in the game, so only get the first layer
auto base = static_cast<OpenGLRenderer::FHardwareTexture*>(mat->GetLayer(0, translation));
// CLAMP_NONE is irrelevant, sampler control code has been disabled.
// CTF_CheckHires to always use the HD version of the texture, if present
base->BindOrCreate(tex, 0, CLAMP_NONE, translation, CTF_CheckHires);
return base->GetTextureHandle(translation);
}
And when rendering the text:
Spoiler: Obtaining translation ID from RenderCommand
Code: Select all
// FTexture *img; RenderCommand dg;
int translation = 0;
if (dg.mTranslation)
translation = dg.mTranslation->GetUniqueIndex();
GLuint textureID = GetTextureID(img, translation);
I'd also like to know what that "int translation" is and if there is more than one way to refer to translations by numbers, whether these translation IDs are global or only relevant to a single font/texture.
We have decided to fork GZDoom 3.7.2 to improve performance in The Forestale by implementing a leaner and faster renderer that doesn't support unneeded features. Its code will, of course, be released along with the game. We have commented out all OpenGL calls in GZDoom except those in FHardwareTexture::CreateTexture.
Unfortunately, there is a bug we can't figure out because of how complex GZDoom's texture system is. There are dozens of texture-related classes and it's mind-boggling, which is understandable, considering how many features the texture system supports, including but not limited to texture composing, HD texture replacements, transparently converting between palletized and truecolor formats, translations, font recoloring. I'd appeciate an explanation of how these classes are structured.
We have a problem with font recoloring. Fonts in The Forestale all have truecolor HD replacements. Untranslated fonts render fine, but all translated colorings of a multi-lump font glyph return the same HD texture with messed up colors. All those colors belong to the palette. Perhaps some GZDoom developer can tell what could cause such a bug. Any help is greatly appreciated.
[size=150]Screenshots:[/size]
Menu icons are all in a font with HD replacements. Menu items are single-character strings using that font. The third item's HD replacement has been replaced with a 256x256 horizontal gradient from RGB(0, 0, 0) to RGB(255, 255, 255) for test purposes. Menu items are untranslated by default. The selected menu item is colored green.
[spoiler=GZDoom correctly recoloring menu items and text][imgur]https://imgur.com/hiRwBBH[/imgur] [imgur]https://imgur.com/vdBokui[/imgur]
[imgur]https://imgur.com/z7htmM2[/imgur][/spoiler]
[spoiler=Custom renderer receiving translated textures with messed up colors][imgur]https://imgur.com/ZHk7nKG[/imgur] [imgur]https://imgur.com/XKretPi[/imgur]
[imgur]https://imgur.com/ZtzG14l[/imgur][/spoiler]
The following code is used to obtain an OpenGL texture ID from an FTexture. Is it correct?
[spoiler=GetTextureID][code]
// Returns the OpenGL ID of an FTexture
GLuint GetTextureID(FTexture *tex, int translation)
{
FMaterial * mat = FMaterial::ValidateTexture(tex, false);
// There are no multi-layer textures in the game, so only get the first layer
auto base = static_cast<OpenGLRenderer::FHardwareTexture*>(mat->GetLayer(0, translation));
// CLAMP_NONE is irrelevant, sampler control code has been disabled.
// CTF_CheckHires to always use the HD version of the texture, if present
base->BindOrCreate(tex, 0, CLAMP_NONE, translation, CTF_CheckHires);
return base->GetTextureHandle(translation);
}
[/code][/spoiler]
And when rendering the text:
[spoiler=Obtaining translation ID from RenderCommand][code]
// FTexture *img; RenderCommand dg;
int translation = 0;
if (dg.mTranslation)
translation = dg.mTranslation->GetUniqueIndex();
GLuint textureID = GetTextureID(img, translation);
[/code][/spoiler]
I'd also like to know what that "int translation" is and if there is more than one way to refer to translations by numbers, whether these translation IDs are global or only relevant to a single font/texture.