View Issue Details

IDProjectCategoryView StatusLast Update
0005710DarkRadiantSaving and loadingpublic02.04.2022 05:56
Reporterillwieckz Assigned Togreebo  
PrioritynormalSeveritynormalReproducibilityalways
Status closedResolutionfixed 
Product Version2.13.0 
Target Version2.14.0Fixed in Version2.14.0 
Summary0005710: Q3 Legacy BrushDef parser sometime produce some wrong texture rotation
DescriptionWhen loading a map using the Q3 Legacy BrushDef format, some texture rotation looks correct and some other texture rotation appears to be wrong, like if it was rotated with a 45° angle.

Reference (Dæmon game engine):
https://dl.illwieckz.net/b/darkradiant/bugs/q3-legacy-brush-misorientated-textures/unvanquished_2021-08-13_191552_000.jpg
DarkRadiant:
https://dl.illwieckz.net/b/darkradiant/bugs/q3-legacy-brush-misorientated-textures/20210813-191427-000.darkradiant-unvanquished-vega.png
Steps To Reproduce# Assuming the PROFILE environment variable is set
# to the DarkRadiant installation directory.

# Download the .game file.
mkdir games
cd games
wget https://raw.githubusercontent.com/Unvanquished/unvanquished-mapeditor-support/master/build/darkradiant/games/unvanquished.game
cp -a unvanquished.game "${PREFIX}/share/darkradiant/games/unvanquished.game"
cd ..

# Download some data sources.
mkdir pkg
cd pkg
git clone https://github.com/UnvanquishedAssets/tex-common_src.dpkdir.git
git clone https://github.com/UnvanquishedAssets/tex-vega_src.dpkdir.git
git clone https://github.com/UnvanquishedAssets/map-vega_src.dpkdir.git

# Download .darkradiant file with preconfigured camera view.
cd map-vega_src.dpkdir/maps
wget https://dl.illwieckz.net/b/darkradiant/bugs/q3-legacy-brush-misorientated-textures/vega.darkradiant
cd ../..

# Download the definition file.
mkdir def
cd def
wget https://raw.githubusercontent.com/Unvanquished/unvanquished-mapeditor-support/master/build/darkradiant/pkg/def/entities.def
cd ../..

# Run DarkRadiant and configure it for Unvanquished game
# and set the engine path to the folder containing the pkg/ folder
# and fs_game to “pkg”.
"${PREFIX}/bin/darkradiant"

# Quit DarkRadiant and reopen it with a map source.
"${PREFIX}/bin/darkradiant" "$(pwd)/pkg/map-vega_src.dpkdir/maps/vega.map"
TagsNo tags attached.

Relationships

related to 0005711 closedgreebo Change Quake3 map exporter to write "legacy" brush syntax 

Activities

greebo

greebo

29.08.2021 13:58

administrator   ~0014322

I've extracted three brushes from that scene in the screenshot, the one with "trim02" on it has its texture rotated by 90 degrees, it seems. The "floor01" brushes have their textures shifted (and/or rotated, hard to tell).

{
"classname" "worldspawn"
"message" "Vega Industries: Research Outpost 13"
{
( -592 1168 112 ) ( -720 1040 64 ) ( -720 1168 112 ) shared_vega/floor01 128 128 180 0.125 0.125 134217728 0 0
( -592 1040 48 ) ( -720 1168 96 ) ( -720 1040 48 ) common/caulk 64 48 -90 0.5 0.5 134217728 0 0
( -592 1168 112 ) ( -720 1168 112 ) ( -720 1168 96 ) common/caulk 0 0 0 0.25 0.25 134217728 0 0
( -592 1040 64 ) ( -720 1040 48 ) ( -720 1040 64 ) common/caulk 0 0 0 0.25 0.25 134217728 0 0
( -688 1104 64 ) ( -688 1072 -64 ) ( -688 1104 -64 ) common/caulk 0 0 0 0.25 0.25 134217728 0 0
( -624 1056 64 ) ( -624 1088 -64 ) ( -624 1056 -64 ) common/caulk 0 0 0 0.25 0.25 134217728 0 0
}
{
( -752 1040 64 ) ( -560 1040 64 ) ( -560 1024 64 ) shared_vega/trim02 0 -512 90 0.0625 0.0625 134217728 0 0
( -576 1024 64 ) ( -576 1040 56 ) ( -576 1024 56 ) common/caulk 0 0 0 0.25 0.25 134217728 0 0
( -544 1040 64 ) ( -736 1040 56 ) ( -544 1040 56 ) common/caulk 0 0 0 0.25 0.25 134217728 0 0
( -752 1040 56 ) ( -560 1024 56 ) ( -560 1040 56 ) common/caulk 0 0 0 0.25 0.25 134217728 0 0
( -736 1040 64 ) ( -736 1024 56 ) ( -736 1040 56 ) common/caulk 0 0 0 0.25 0.25 134217728 0 0
( -752 1024 64 ) ( -560 1024 56 ) ( -752 1024 56 ) common/caulk 0 0 0 0.25 0.25 134217728 0 0
}
{
( -688 928 64 ) ( -624 832 64 ) ( -688 832 64 ) shared_vega/floor01 128 256 180 0.125 0.125 134217728 0 0
( -624 928 56 ) ( -688 832 56 ) ( -624 832 56 ) common/caulk 0 16 0 0.5 0.5 134217728 0 0
( -688 800 64 ) ( -624 800 64 ) ( -624 800 56 ) common/caulk 0 0 0 0.125 0.125 134217728 0 0
( -688 928 56 ) ( -688 832 64 ) ( -688 832 56 ) common/caulk 0 0 0 0.125 0.125 134217728 0 0
( -624 928 64 ) ( -624 832 56 ) ( -624 832 64 ) common/caulk 0 0 0 0.125 0.125 134217728 0 0
( -624 1024 64 ) ( -688 1024 56 ) ( -624 1024 56 ) common/caulk 0 0 0 0.25 0.25 134217728 0 0
}
}
greebo

greebo

29.08.2021 14:14

administrator   ~0014323

I can confirm and see in the above screenies that the texture is wrong when compared to the in-game screenshot. I might get it to load such that it is fitting on the brush face, but these grates and floor panels make it hard to check whether I got the orientation right.

@illwieckz can you do me a favour and take that above .map snippet (or the vega map itself), and load it with a modified texture set that allows for easier recognition of its orientation? Please modify the floor01 texture and paint some characters into each panel, ABCD|EFGH, that way I can see the desired orientation. Then please post a new in-game screenshot of these brushes or that scene.

greebo

greebo

02.09.2021 05:06

administrator   ~0014331

I've loaded it into NetRadiant, which displayed the modified texture on the brushes like this, I hope this is correct?
greebo

greebo

05.09.2021 07:59

administrator   ~0014332

Last edited: 05.09.2021 10:45

After wrapping my head around this for a few hours, I believe I understand why things are turning out different when loading Q3 maps. After calculating the 2D shift/scale/rotation matrix that is saved in Q3 (and visible in the Surface Inspector), the two game engines are taking different paths before applying the projection to their surfaces. The diference lies in the way the engines rotate their world coordinates, they choose a "base" tex coord system - from what I can see in GtkRadiant, Q3 is using exactly one of six possible transforms, whereas D3 is preserving the face normal and has an infinite number of transforms.

I can fix the appearance of all Q3 brushes that are axis-aligned in at least two directions, like an angled brush that has an upwards slope along the Y direction. For those brushes, I can maybe calculate a texture offset and scale that will likely fix the texture mapping for those angled faces. For all other brushes that are angled in two directions the projection will never match up in DarkRadiant since the idTech4 "axis base" is not matching the Q3 one.

The full fix would be to add the Q3 axis base algorithms to DarkRadiant, which means it would calculate the texture coords differently based on the chosen game type. Since DarkRadiant is specialised on idTech4, I'm hesitant to do this.

But I'm wondering, I'm almost sure at this point that when using DarkRadiant to map for Unvanquished, you should have seen texturing inconstistences already for those angled brushes. Are you familiar with a problem like this, or any of your mappers?

Related Changesets

DarkRadiant: master 2dfb14f4

03.09.2021 15:07

greebo


Details Diff
0005710: Start constructing some tests to check the legacy Q3 brush importer code Affected Issues
0005710
mod - test/Brush.cpp Diff File
mod - test/algorithm/Primitives.h Diff File
mod - test/algorithm/Scene.h Diff File
add - test/resources/tdm/maps/quake3maps/brush_no_transform.map Diff File
mod - test/resources/tdm/materials/example.mtr Diff File
add - test/resources/tdm/textures/a_1024x512.tga Diff File
mod - tools/msvc/natvis/mathlib.natvis Diff File

DarkRadiant: master a1f5207c

04.09.2021 04:46

greebo


Details Diff
0005710: Refactoring, move the getBasisTransformForNormal to texturelib.h since we're going to need it outside the core module too.
Add some comments to the ComputeAxisBase method, since its purpose is not exactly obvious.
Affected Issues
0005710
mod - libs/texturelib.h Diff File
mod - radiantcore/brush/TextureProjection.cpp Diff File
mod - radiantcore/brush/TextureProjection.h Diff File

DarkRadiant: master 61463345

04.09.2021 07:53

greebo


Details Diff
0005710: Port the Quake 3 texture projection calculation code from GtkRadiant and compensate the ComputeAxisBase rotation that is happening during idTech4 tex coord emission. This way we get the same visual appearance for brushes defined in Q3 map format while keeping the mandatory axis base to match what the dmap compiler in D3/TDM is inevitably doing.
Fixup some unit test cases, since I got a few vertex coords wrong.
Affected Issues
0005710
mod - radiantcore/map/format/primitiveparsers/BrushDef.cpp Diff File
mod - radiantcore/map/format/primitiveparsers/BrushDef.h Diff File
mod - test/Brush.cpp Diff File

DarkRadiant: master 2b062fb5

04.09.2021 11:04

greebo


Details Diff
0005710: Refactoring Affected Issues
0005710
mod - radiantcore/map/format/primitiveparsers/BrushDef.cpp Diff File
mod - radiantcore/map/format/primitiveparsers/BrushDef.h Diff File

DarkRadiant: master ed2d1bd0

05.09.2021 06:15

greebo


Details Diff
0005710: Another unit test checking an angled brush.
This is currently causing trouble, as the axis base compensation matrix trick is not working here - only the 2D parts of the texture matrix are stored in the face's TextureMatrix class :/
Affected Issues
0005710
mod - test/Brush.cpp Diff File

DarkRadiant: master bd7dc98e

05.09.2021 10:44

greebo


Details Diff
0005710: Add some comments about the approach and its limited usefulness. Affected Issues
0005710
mod - libs/texturelib.h Diff File
mod - radiantcore/brush/TextureProjection.cpp Diff File
mod - radiantcore/map/format/primitiveparsers/BrushDef.cpp Diff File
mod - test/Brush.cpp Diff File

DarkRadiant: master fbc3d116

05.09.2021 11:58

greebo


Details Diff
0005710: Add another unit test with an axis-aligned brush including a non-identity texdef Affected Issues
0005710
mod - test/Brush.cpp Diff File
add - test/resources/tdm/maps/quake3maps/angled_brush.map Diff File
add - test/resources/tdm/maps/quake3maps/brush_with_transform.map Diff File

Issue History

Date Modified Username Field Change
13.08.2021 17:34 illwieckz New Issue
13.08.2021 18:01 greebo Relationship added related to 0005711
29.08.2021 13:51 greebo Status new => confirmed
29.08.2021 13:58 greebo Note Added: 0014322
29.08.2021 14:14 greebo Status confirmed => feedback
29.08.2021 14:14 greebo Note Added: 0014323
02.09.2021 05:06 greebo Note Added: 0014331
02.09.2021 05:06 greebo File Added: 2021-09-02 06_58_35maps_vega_brushes.map.png
05.09.2021 07:59 greebo Note Added: 0014332
05.09.2021 10:44 greebo Changeset attached => DarkRadiant master 2dfb14f4
05.09.2021 10:44 greebo Changeset attached => DarkRadiant master a1f5207c
05.09.2021 10:44 greebo Changeset attached => DarkRadiant master 61463345
05.09.2021 10:44 greebo Changeset attached => DarkRadiant master 2b062fb5
05.09.2021 10:44 greebo Changeset attached => DarkRadiant master ed2d1bd0
05.09.2021 10:44 greebo Changeset attached => DarkRadiant master bd7dc98e
05.09.2021 10:45 greebo Note Edited: 0014332
05.09.2021 13:18 greebo Changeset attached => DarkRadiant master fbc3d116
05.09.2021 13:18 greebo Assigned To => greebo
05.09.2021 13:18 greebo Status feedback => assigned
10.10.2021 17:58 greebo Status assigned => resolved
10.10.2021 17:58 greebo Resolution open => fixed
10.10.2021 17:58 greebo Fixed in Version => 2.14.0
10.10.2021 17:58 greebo Target Version => 2.14.0
02.04.2022 05:56 greebo Status resolved => closed