RobertBeckebans / RBDOOM-3-BFG

Doom 3 BFG Edition source port with updated DX12 / Vulkan renderer and modern game engine features
https://www.moddb.com/mods/rbdoom-3-bfg
GNU General Public License v3.0
1.38k stars 247 forks source link

Texture misaligned #533

Open runlevel5 opened 3 years ago

runlevel5 commented 3 years ago

Host specs

OS: Fedora 33 (ppc64le) GCC: 10.2.1 20201125 glibc: 2.32

Compiler Options:

option(FORCE_COLOR_OUTPUT: ON)
option(COMPILE_COMMANDS: OFF)
option(USE_MFC_TOOLS: OFF)
option(USE_PRECOMPILED_HEADERS: ON)
option(SDL2: ON)
option(OPENAL: ON
option(FFMPEG: ON)
option(BINKDEC: OFF)
option(USE_VULKAN: ON)
option(SPIRV_SHADERC: ON)
option(ONATIVE: ON)
option(USE_SYSTEM_ZLIB: OFF)
option(USE_SYSTEM_LIBPNG: OFF)
option(USE_SYSTEM_LIBGLEW: OFF)
option(USE_SYSTEM_RAPIDJSON: OFF)

Describe

Characters of text texture are not aligned correctly

Screenshot from 2021-02-27 22-23-05 Screenshot from 2021-02-27 22-25-00

RobertBeckebans commented 3 years ago

Strange, it is only the A letter.

runlevel5 commented 3 years ago

Indeed, any suggestion which part of logic might be?

BielBdeLuna commented 3 years ago

the "new" code for GUIs fonts maybe? the different font code and GUI code between doom3 BFG and vanilla Doom3

runlevel5 commented 3 years ago

the "new" code for GUIs fonts maybe? the different font code and GUI code between doom3 BFG and vanilla Doom3

Could you please elaborate more on this?

BielBdeLuna commented 3 years ago

I guess the code bug is within:

/neo/render/tr_frontend_guisurf.cpp

the script related to gui surfaces

or it could be in the font code in:

/neo/render/font.h / .cpp

runlevel5 commented 3 years ago

@BielBdeLuna I had a go at debugging the renderer font code but could not pin point exactly the culprits. The way that I do is to print out all infos to STDOUT then compare them with that of x86_64, but I could not find anything unusual or different. Would you be able to suggest me some troubleshooting approach? Please excuse me for asking such question, I am new to game dev

BielBdeLuna commented 3 years ago

maybe it's the GUI code rather than the font code, those letters in the image are actually a font texture that gets sliced into the different "glyphs" of every letter and placed in a two triangle rectangle mesh that has every letter that compose a message in the GUI surface, and those rectangles seem to be in the wrong places. can you show those errors while showing the triangles? r_showTris 1 or 2 might do the trick. if the squares are not well placed, then maybe it's not the fonts but the GUI code. other non text related GUI elements do show strange behaviour?

keep in mind though that the menus and the PDA menu are not GUIs but SWFs. but any ways, do you see strange letter-related defects while on SWFs too?

all the examples you posted at the moment are errors in GUIs not SWFs.

runlevel5 commented 3 years ago

The PDA GUI looks okay to me

Screenshot from 2021-03-21 10-18-10

the only GUI bug I could find is the date text alignment in the following screenshot

Screenshot from 2021-03-21 10-18-36

runlevel5 commented 3 years ago

FYI

Screenshot from 2021-03-21 10-44-44 Screenshot from 2021-03-21 10-46-11

BielBdeLuna commented 3 years ago

I tested the SWF with the video with the dates slashes in my build looks fine, that is it looks different than to you. and the GUIs looked fine to me, I'm using the Master branch, OpenGL, and Linux. what Linux are you using?

with the GUI problems: maybe there is a difference on the underlying maths algorithms that position some of the letters (the A, but again why the A in specific and not the other letters?) I wonder if A is the letter 0 in the list, maybe the member 0 in the letter list has something special done to it? a spacial case for the member 0?

maybe the maths algorithm has something done to it, some optimization that worked somewhere else but that damaged the letter rendering? or maybe the letter rendering had some optimization done to it that depended on a very specific maths algorithm and changing that algorithm broke the letter position?

on the SWF problems: I don't know, it's a font problem? it's a SWF rendering problem? the thing that only seems to be clear is that it's not a structural problem in the SWF file because then I would have the same error.

BielBdeLuna commented 3 years ago

I see you're on PowerPC, I would look into the maths algorithms related to the GUI letter positions

runlevel5 commented 3 years ago

@BielBdeLuna I can confirm the issue occur for both OpenGL and Vulkan renderer

I will dig in to see if there is math algorithm involved

BielBdeLuna commented 3 years ago

I would treat the GUI problems and the SWF problems as two separated problems though

RobertBeckebans commented 3 years ago

Could you try to compile RBDOOM-3-BFG with Clang instead of GCC?

runlevel5 commented 3 years ago

Could you try to compile RBDOOM-3-BFG with Clang instead of GCC?

@RobertBeckebans yes I have tried. Same issue

KiralyCraft commented 3 years ago

I can confirm this issue on Nvidia L4T (arm64). Does not happen everywhere, on my Manjaro desktop (x86_64) it works wonders.

It also happens with resolutions, "1" seems to be offset as well (in "1280 x 720") and in the FOV ("100")

BielBdeLuna commented 3 years ago

A and 1 might be the first characters in a list? unless the numbers start with 0 (which they might be)

KiralyCraft commented 3 years ago

I am compiling master again right now, specifically 09c9f254c87e22663c6b5a52d6907fa020c0979b with the cmake-linux-nvidia-jetson-vulkan-release.sh from neo. I will attach some screenshots as well, will edit this comment to prevent spamming this thread.

EDIT: Here they are ingame1 ingame2 ingame3 ingame4 ingame5 ingame6 ingame7 map1 options options1

KiralyCraft commented 3 years ago

A and 1 might be the first characters in a list? unless the numbers start with 0 (which they might be)

Looks like it's only A and 1. Everything else seems fine for me. The exact same code works fine on x64, so I assume it's down to the specifics?

EDIT: For the hell of it, I compiled on x64 with GCC10 using the jetson cmake and it works wonders

KiralyCraft commented 3 years ago

Also happens with W?

ingame_again

BielBdeLuna commented 3 years ago

so it's not a list of characters thing, "W" isn't the first character anywhere. Isn't it?

the A appears but out of place, so it's got to be on the mathematics on where to put those letters.

I see though it's the capital A, the normal "a" isn't affected by it. the W problematic is only the capital one too. what is the relationship between "1", "W" and "A"? do those characters also fail in the console?

wait the 1 only happen in SWF files the W and the A in the GUI files, the A and the W doesn't happen in SWF. Those two use different font system I think. I still think those are two different problems.

KiralyCraft commented 3 years ago

do those characters also fail in the console?

Could you please elaborate on this part? I've never played Doom 3 before, so I'm not quite sure which console you are referring to. Also, from what I understand, the SWF things are the interactive displays? This excludes the PDA

KiralyCraft commented 3 years ago

Also seems to happen for Y:

image

BielBdeLuna commented 3 years ago

the console is heavily controlled by the c++ code, so it's not a GUI file or a SWF file.

the GUI file allows to do interactive screens within the game, this are plain text files in the .gui extension that conform a graphics interface scripting to do so. in the past ( read vanilla Doom3, Quake4, Prey ) those used to also handle the full screen graphic interfaces of all the game. but with Doom3 BFG a new system was introduced:

the SWF system (this is flash based) uses de .swf files from flash and handle just the full screen graphic user interface (the main menus, and the PDA)

So those two system are separate. It is pretty interesting that ID provided a way to render flash based graphic user interface in it's released code under a open source licence ( flash is proprietary tech from Adobe, although there are other open source implementations) I think ID used flash for Rage.

GUI uses /render/font.h in: https://github.com/RobertBeckebans/RBDOOM-3-BFG/blob/09c9f254c87e22663c6b5a52d6907fa020c0979b/neo/ui/DeviceContext.h#L36

and SFW uses /render/font.h indirectly through /render/RenderCommon.h in: https://github.com/RobertBeckebans/RBDOOM-3-BFG/blob/09c9f254c87e22663c6b5a52d6907fa020c0979b/neo/swf/SWF_Render.cpp#L31

so both seem to use the same font system, now this font system has changed in Doom3BFG compared to vanilla as:

https://github.com/id-Software/DOOM-3-BFG/blob/master/neo/renderer/Font.cpp is vastly different than:

https://github.com/id-Software/DOOM-3/blob/master/neo/renderer/tr_font.cpp the code changed, starting by there is no font class in vanilla Doom3.

The console uses: https://github.com/RobertBeckebans/RBDOOM-3-BFG/blob/09c9f254c87e22663c6b5a52d6907fa020c0979b/neo/framework/Console.cpp#L30 that I think it gets created in compile time, so it might also use font.h indirectly inside it.

KiralyCraft commented 3 years ago

I see, thank you so much for the clarifications. I also found more occurences about other leters, such as X and even inside the PDA. Attaching pictures

I just now remembered there is the ~ console!

nextdepartue pda

BielBdeLuna commented 3 years ago

why the A in EMAIL (which is capital) doesn't fail the same way in the pda? or the As in ASSISTANT? there is a difference between the text written in the emails and the name of the sections in the pda?

also why in the picture above AEROSPACE the second A doesn't fail? maybe it's not capital letters, but "the first capital letter of a given select group that fails"? but then "neXt" doesn't have the X as the first letter! so this is not it.

If it's so random, it might be some memory space that doesn't make the engine fail but that, somewhat, gets over-written or miss-read somewhere. probably (due to the different places we are seeing it) in the common system those things use, the DAMN font class.

mrcmunir commented 2 years ago

I have just verified that in all the places where this problem arises, especially in the console letters, it is 6 jumps to the right. I don't know if that will help a lot but for some reason it shifts doing those fixed jumps.