View Issue Details

IDProjectCategoryView StatusLast Update
0005326DarkRadiantModelspublic15.01.2021 17:25
Reporterelojalapeno Assigned To 
PrioritynormalSeveritymajorReproducibilityalways
Status feedbackResolutionopen 
Product Version2.8.0 
Summary0005326: Exporting .obj lacks .mtl; UV is inverted; scale by 2.54 ?
DescriptionWhen exporting parts of the map as .obj file, there is no .mtl for material/texture info. This would be very useful to know what exactly should be used.
Another issue is that .obj files appear to have inverted UV.
Would it be possible to add scale on export?
Tagsmodel, model export
Attached Files
UE4Editor_nsCsa8UL6k.png (1,448,147 bytes)

Activities

greebo

greebo

11.08.2020 14:06

administrator   ~0012721

Thanks for stopping by!
I'm not very proficient when it comes to handling OBJ files - can you give me a few more directions? Like a working .OBJ and .MTL file, or a comparison of expected and actual results when using the export? Then I can try to fix it.
elojalapeno

elojalapeno

11.08.2020 17:45

reporter   ~0012723

Thanks for your response! I didn't expect it so fast.
Format is purely text based.
I guess you will have to read materials from radiant, and parse that into .mtl file. Here is a 1 object sample with one material applied .OBJ:

[CODE]# Blender v2.83.2 OBJ File: ''
# www.blender.org
mtllib sample.mtl
g stedoorpanel1_d
v 1.000000 1.000000 -1.000000
v 1.000000 -1.000000 -1.000000
v 1.000000 1.000000 1.000000
v 1.000000 -1.000000 1.000000
v -1.000000 1.000000 -1.000000
v -1.000000 -1.000000 -1.000000
v -1.000000 1.000000 1.000000
v -1.000000 -1.000000 1.000000
vt 0.625000 0.500000
vt 0.875000 0.500000
vt 0.875000 0.750000
vt 0.625000 0.750000
vt 0.375000 0.750000
vt 0.625000 1.000000
vt 0.375000 1.000000
vt 0.375000 0.000000
vt 0.625000 0.000000
vt 0.625000 0.250000
vt 0.375000 0.250000
vt 0.125000 0.500000
vt 0.375000 0.500000
vt 0.125000 0.750000
vn 0.0000 1.0000 0.0000
vn 0.0000 0.0000 1.0000
vn -1.0000 0.0000 0.0000
vn 0.0000 -1.0000 0.0000
vn 1.0000 0.0000 0.0000
vn 0.0000 0.0000 -1.0000
usemtl Material
s off
f 1/1/1 5/2/1 7/3/1 3/4/1
f 4/5/2 3/4/2 7/6/2 8/7/2
f 8/8/3 7/9/3 5/10/3 6/11/3
f 6/12/4 2/13/4 4/5/4 8/14/4
f 2/13/5 1/1/5 3/4/5 4/5/5
f 6/11/6 5/10/6 1/1/6 2/13/6
[/CODE]

And here is corresponding .MTL file:
[CODE]
# Blender MTL File: 'None'
# Material Count: 1

newmtl Material
Ns 323.999994
Ka 1.000000 1.000000 1.000000
Kd 0.800000 0.800000 0.800000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.450000
d 1.000000
illum 2
map_Kd textures\\base_door\\stedoorpanel1_d.tga
map_Kn textures\\base_door\\stedoorpanel1_d
map_Ks textures\\base_door\\stedoorpanel1_s.tga
[/code]

Long story short, map_Kd/Kn/Ks correspond to matching diffuse/normal/specular textures. When this is included, all textures should load automatically.

As for inverting UV, that's going to be a lot of numbers I think. I could probably export sample brush from Radiant, fix it in Blender, and then show you final .obj so you can see the differences for yourself.
Is there any discord for more real-life communication?
TEMP.zip (762 bytes)
elojalapeno

elojalapeno

11.08.2020 17:46

reporter   ~0012724

Oh I can't edit it now, but obviously instead of "Material", it should actually using corresponding material name. I think in Doom 3 case it's always the color map filename?
greebo

greebo

11.08.2020 17:52

administrator   ~0012725

Thanks for the examples. Anything that I can compare to is helpful. I'm not sure myself right now, but does Doom 3 handle OBJ files? Or are you using some other engine?
Don't hold your breath on the fix though, I'm currently tied up in other things, so it might be a while.
elojalapeno

elojalapeno

11.08.2020 17:54

reporter   ~0012726

My final destination is UE4, however once this is implemented, it would literally work with every 3D software like Maya, Blender, Unity, 3DS Max...
The current file is fully workable, just requires manual rework of inverting UV and recreating materials.

I haven't looked into materials in Radiant, been a while since I really dipped into that, but maybe at the very least it would be possible to put all 'shaders' into a single text file to ease this process? Just text information about material name and textures it's using. Many materials are using filename + suffixes like _d _local _s, but not everything is matching.
VanishedOne

VanishedOne

12.08.2020 14:24

reporter   ~0012730

Possibly related to my experience with the UVs at https://bugs.thedarkmod.com/view.php?id=4099#c7853
elojalapeno

elojalapeno

12.08.2020 18:54

reporter   ~0012731

The steampowered link you have posted is dead. Do you have a copy of its content?
VanishedOne

VanishedOne

12.08.2020 21:03

reporter   ~0012732

Last edited: 12.08.2020 21:04

I'm afraid I didn't find anything in the Wayback Machine. But I remember that when I tried loading an OBJ from DR into UVMapper Classic it popped up an offer to fix it automatically, and that was all it took to make it usable in Sculptris's paint mode. Probably the 'message about out of range UV coordinates' mentioned in http://www.render-lab.com/Render-Lab_UV_tut.htm and https://community.foundry.com/discuss/topic/41014/solved-uv-out-of-range-with-uv-mapper?mode=Post&postID=371929
greebo

greebo

09.10.2020 14:19

administrator   ~0012799

In the current development version. I've adjusted the OBJ exporter to write a MTL file next to it. As soon as I have a pre-release build available, I'll post in the forums (https://forums.thedarkmod.com/index.php?/forum/51-darkradiant-feedback-and-development/), so maybe you might want to set an alert on that subforum to get notified.

Thing is, I can not tell at this point if the "map_Kd" paths are meant to be absolute file system paths like C:/temp/texture.png or whether they are meant to be relative to the OBJ file.
When importing the OBJ file in Blender, there's the option "Image Search" where Blender tries to locate the mentioned texture files in the folder of the MTL file (including subfolders) - and it's working. Not sure though how Lightwave or others are treating the MTL file.
greebo

greebo

09.10.2020 14:22

administrator   ~0012800

Here's a test model export I created with the current dev build. It contains the models folder as one would expect it in a D3/Q4 mod.
testmodel.7z (17,065 bytes)
elojalapeno

elojalapeno

31.12.2020 07:02

reporter   ~0013329

I missed the reply. Will try it shortly after new year!

Related Changesets

DarkRadiant: master ba2cbc72

04.10.2020 16:26

greebo


Details Diff
0005326: Invert the V texture coordinate when exporting OBJ objects Affected Issues
0005326
mod - radiantcore/model/export/WavefrontExporter.cpp Diff File

DarkRadiant: master 53b83aa9

05.10.2020 03:18

greebo


Details Diff
0005326: Move stream opening and file rename code to ModelExporterBase Affected Issues
0005326
mod - include/imodel.h Diff File
mod - radiantcore/map/algorithm/Export.cpp Diff File
mod - radiantcore/model/export/ModelExporter.cpp Diff File
mod - radiantcore/model/export/ModelExporter.h Diff File
mod - radiantcore/model/export/ModelExporterBase.h Diff File
mod - radiantcore/model/export/ScaledModelExporter.cpp Diff File

DarkRadiant: master 41580cc9

05.10.2020 04:41

greebo


Details Diff
0005326: Introduce ExportStream wrapper, which writes to a temporary file before moving the fully written file over the target path.
Change IModelExporter interface: publically exposing the file output format is not needed anymore, since the stream mode (binary/text) will be selected by the exportToPath() implementation.
Affected Issues
0005326
mod - include/imodel.h Diff File
add - libs/stream/ExportStream.h Diff File
mod - radiantcore/model/export/AseExporter.cpp Diff File
mod - radiantcore/model/export/AseExporter.h Diff File
mod - radiantcore/model/export/Lwo2Exporter.cpp Diff File
mod - radiantcore/model/export/Lwo2Exporter.h Diff File
mod - radiantcore/model/export/ModelExporterBase.h Diff File
mod - radiantcore/model/export/WavefrontExporter.cpp Diff File
mod - radiantcore/model/export/WavefrontExporter.h Diff File
mod - tools/msvc/libs.vcxproj Diff File
mod - tools/msvc/libs.vcxproj.filters Diff File

DarkRadiant: master cbba4604

07.10.2020 18:24

greebo


Details Diff
0005326: Add option to retrieve the image path from a ShaderLayer. All shader layers with more complex expressions will return an empty string, but the most common maps like "bumpmap", "map diffuse", etc. will return the VFS path just fine. Affected Issues
0005326
mod - include/ShaderLayer.h Diff File
mod - radiantcore/shaders/Doom3ShaderLayer.cpp Diff File
mod - radiantcore/shaders/Doom3ShaderLayer.h Diff File

DarkRadiant: master 23373e85

07.10.2020 18:25

greebo


Details Diff
0005326: Export a .mtl material library file next to the .obj file Affected Issues
0005326
mod - radiantcore/model/export/WavefrontExporter.cpp Diff File
mod - radiantcore/model/export/WavefrontExporter.h Diff File

Issue History

Date Modified Username Field Change
11.08.2020 09:19 elojalapeno New Issue
11.08.2020 09:19 elojalapeno Tag Attached: model
11.08.2020 09:19 elojalapeno Tag Attached: model export
11.08.2020 09:19 elojalapeno File Added: UE4Editor_nsCsa8UL6k.png
11.08.2020 14:06 greebo Note Added: 0012721
11.08.2020 14:06 greebo Status new => feedback
11.08.2020 17:45 elojalapeno Note Added: 0012723
11.08.2020 17:45 elojalapeno File Added: TEMP.zip
11.08.2020 17:45 elojalapeno Status feedback => new
11.08.2020 17:46 elojalapeno Note Added: 0012724
11.08.2020 17:52 greebo Note Added: 0012725
11.08.2020 17:52 greebo Status new => acknowledged
11.08.2020 17:54 elojalapeno Note Added: 0012726
12.08.2020 14:24 VanishedOne Note Added: 0012730
12.08.2020 18:54 elojalapeno Note Added: 0012731
12.08.2020 21:03 VanishedOne Note Added: 0012732
12.08.2020 21:04 VanishedOne Note Edited: 0012732
05.10.2020 04:44 greebo Assigned To => greebo
05.10.2020 04:44 greebo Status acknowledged => assigned
05.10.2020 04:45 greebo Changeset attached => DarkRadiant master ba2cbc72
05.10.2020 04:45 greebo Changeset attached => DarkRadiant master 53b83aa9
05.10.2020 04:45 greebo Changeset attached => DarkRadiant master 41580cc9
07.10.2020 18:42 greebo Changeset attached => DarkRadiant master cbba4604
07.10.2020 18:42 greebo Changeset attached => DarkRadiant master 23373e85
09.10.2020 14:19 greebo Note Added: 0012799
09.10.2020 14:22 greebo Note Added: 0012800
09.10.2020 14:22 greebo File Added: testmodel.7z
31.12.2020 07:02 elojalapeno Note Added: 0013329
15.01.2021 17:25 greebo Assigned To greebo =>
15.01.2021 17:25 greebo Status assigned => feedback