OBJ support in GZDoom

Handy guides on how to do things, written by users for users.

Moderators: GZDoom Developers, Raze Developers

Forum rules
Please don't start threads here asking for help. This forum is not for requesting guides, only for posting them. If you need help, the Editing forum is for you.
Post Reply
Talon1024
 
 
Posts: 374
Joined: Mon Jun 27, 2016 7:26 pm
Preferred Pronouns: He/Him
Graphics Processor: nVidia with Vulkan support
Contact:

OBJ support in GZDoom

Post by Talon1024 »

If you've seen the recent GZDoom changelog, you'll notice that I've added OBJ model support to GZDoom. However, due to the way GZDoom works, OBJ models for GZDoom are a little bit different than regular OBJ models.

First of all, GZDoom does not load the .mtl files that usually come with .obj models. Instead, GZDoom uses the materials that it has already loaded. So, if you have a material in your OBJ file called STARGR2, GZDoom will use the STARGR2 texture from the Doom/Doom 2 IWAD, instead of the STARGR2 material defined in the .mtl file.

Secondly, you can swap out materials on OBJ models using SurfaceSkin in the model definition file. Each "surface" on an OBJ model corresponds to a "usemtl" statement, so if you use "SurfaceSkin 0 0" in your model definition file, you'll change the texture on the faces below the first "usemtl" statement in the OBJ file, and if you use "SurfaceSkin 0 1" in your model definition file, you'll change the texture on the faces below the second "usemtl" statement. Because of an engine limit, however, you cannot replace any textures after the 32nd "usemtl" statement. If you really want, you can just open the OBJ file in a text editor and change the usemtl statements directly.

Third, some features supported by OBJ have been omitted because I thought they would be unimportant or too hard to add. Parametric surfaces, smooth groups for models without normals (although I am considering adding this feature), (Added as of this commit!) and faces with more than 4 sides fall under this category.

But, with this new feature, you can already load gigantic, highly detailed 3D models, such as levels exported from GZDoom Builder, or this model from Turbosquid (thanks, Rachael!). I've already stress-tested GZDoom's OBJ loader with a model of The Given RC2 MAP01 exported from GZDB, and several other maps from Ancient Aliens and Freedoom. Although OBJ rendering is supported in the software renderers, just bear in mind that the more highly-detailed models may crash the software renderers.
Last edited by Talon1024 on Thu Oct 18, 2018 3:10 am, edited 2 times in total.
Reinchard2
Posts: 310
Joined: Fri Sep 21, 2007 1:08 am
Location: Poland - Bytom

Re: OBJ support in GZDoom

Post by Reinchard2 »

Wow, that's really great news. Thanks for your work. I'm hope you can add support for smoothing groups some time, it's very important in some cases.
Talon1024
 
 
Posts: 374
Joined: Mon Jun 27, 2016 7:26 pm
Preferred Pronouns: He/Him
Graphics Processor: nVidia with Vulkan support
Contact:

Re: OBJ support in GZDoom

Post by Talon1024 »

Well, you can get smooth groups if you include the normals in the OBJ, since smooth groups are only a way to control calculation of vertex normals. However, I'm afraid that if I were to add code that searches for adjacent faces, I would end up increasing loading times too much.
Reinchard2
Posts: 310
Joined: Fri Sep 21, 2007 1:08 am
Location: Poland - Bytom

Re: OBJ support in GZDoom

Post by Reinchard2 »

Oh, so smoothing groups works ok, I just don't understand you correctly in your previous post.
User avatar
HAL9000
Posts: 266
Joined: Fri Mar 16, 2018 7:44 am
Contact:

Re: OBJ support in GZDoom

Post by HAL9000 »

So, a quick question.... What are the benefits of using OBJ over MD3 file format in GZDoom?
(Except that I don't have to use extra steps to convert OBJ to MD3)

Don't get me wrong, I welcome this addition to the engine.
It's a nice thing that I can use OBJ straight away without converting it to other file formats
Talon1024
 
 
Posts: 374
Joined: Mon Jun 27, 2016 7:26 pm
Preferred Pronouns: He/Him
Graphics Processor: nVidia with Vulkan support
Contact:

Re: OBJ support in GZDoom

Post by Talon1024 »

  • Blender's MD3 export plugins are poorly documented and clunky to use IMO. OBJs are much more convenient, and much easier to change if necessary.
  • OBJs are not bound by the same limits as MD2, MD3, or UE1 models. For example, you can export a model of The Given MAP01 from GZDoom Builder and use it in GZDoom. With OBJ support, GZDoom has come full circle in that regard.
Reinchard2
Posts: 310
Joined: Fri Sep 21, 2007 1:08 am
Location: Poland - Bytom

Re: OBJ support in GZDoom

Post by Reinchard2 »

Is automatic polygonal collision detection possible in near future? Or is it still one of engine limitations?
User avatar
Nash
 
 
Posts: 17434
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

Re: OBJ support in GZDoom

Post by Nash »

How to embed texture paths into each mesh group? This is still unclear. MD3 let you use full texture path names ("models/my character/head 01.png") per object/mesh group/surface/whatever you call it.
Talon1024
 
 
Posts: 374
Joined: Mon Jun 27, 2016 7:26 pm
Preferred Pronouns: He/Him
Graphics Processor: nVidia with Vulkan support
Contact:

Re: OBJ support in GZDoom

Post by Talon1024 »

Nash wrote:How to embed texture paths into each mesh group?

Code: Select all

usemtl "models/my character/head 01.png"
You won't need quotes if you remove the spaces or replace them with underscores, BTW.
Reinchard2 wrote:Is automatic polygonal collision detection possible in near future? Or is it still one of engine limitations?
ZZYZX did just that with ZScript.
User avatar
Trusty McLegit
Posts: 264
Joined: Sun Feb 07, 2016 8:42 pm

Re: OBJ support in GZDoom

Post by Trusty McLegit »

Talon1024 wrote:
  • OBJs are not bound by the same limits as MD2, MD3, or UE1 models. For example, you can export a model of The Given MAP01 from GZDoom Builder and use it in GZDoom. With OBJ support, GZDoom has come full circle in that regard.
Wait, what??? You can export an .Obj of a map and use it AS a map? Or do you just mean you could use a 3d model of a doom map as a decoration or something? Because if you mean the first one, that would imply collision detection out of the box right? And if you meant the latter, than what would hold you back from exporting the map as an .obj, converting that to an md3, and using that as a decoration? Slightly confused as to what you meant here :P

Also, not very familiar with .obj in general. Can you still animate with OBJ models, or is it just for static models? Or would you need to have a separate obj for each frame?

Finally, hope I'm not asking too much, but could you provide a simple example wad so I can get a clearer understanding of how to use them? I didn't really follow what you wrote in the OP, and it would be easier to simply see it in action
User avatar
Caligari87
Admin
Posts: 6174
Joined: Thu Feb 26, 2004 3:02 pm
Preferred Pronouns: He/Him
Contact:

Re: OBJ support in GZDoom

Post by Caligari87 »

Trusty McLegit wrote:
Talon1024 wrote:
  • OBJs are not bound by the same limits as MD2, MD3, or UE1 models. For example, you can export a model of The Given MAP01 from GZDoom Builder and use it in GZDoom. With OBJ support, GZDoom has come full circle in that regard.
Wait, what??? You can export an .Obj of a map and use it AS a map? Or do you just mean you could use a 3d model of a doom map as a decoration or something? Because if you mean the first one, that would imply collision detection out of the box right? And if you meant the latter, than what would hold you back from exporting the map as an .obj, converting that to an md3, and using that as a decoration? Slightly confused as to what you meant here :P
You can use an OBJ as a "map" in GZDoom, but it will not have collision support. You'd still need to build a "skeleton" level for the player to walk and move in, but the visible geometry could be a single OBJ model with much more detail than can be achieved with linedefs/sectors.
Trusty McLegit wrote:Also, not very familiar with .obj in general. Can you still animate with OBJ models, or is it just for static models? Or would you need to have a separate obj for each frame?
OBJ does not support animations, to my knowledge, you're better off using MD3 for that. OBJ is better for static decorations.

8-)
User avatar
Trusty McLegit
Posts: 264
Joined: Sun Feb 07, 2016 8:42 pm

Re: OBJ support in GZDoom

Post by Trusty McLegit »

Ohhhhh okay, that makes sense. This is something you couldn't do with MD3?
User avatar
Steve5563
Posts: 82
Joined: Sun Jan 27, 2019 11:18 pm
Operating System Version (Optional): windows 10
Graphics Processor: nVidia with Vulkan support
Location: Australia
Contact:

Re: OBJ support in GZDoom

Post by Steve5563 »

hi there, quick question. i am trying to export a very basic map as the .obj file and then import the same exact same file ( map ) back into gzdoom builder using the "wavefront obj as terrain" so i can open the level back up in gzdoom builder and then save the map as a .wad file. but its coming up with a error saying "only triangular faces are supported".
am i doing something wrong here as its my first time using this feature or doing anything with 3d model / files.
i am wanting to modify some textures in a 3d program with out altering the maps geometry in anyway. can this be fixed or a feature added to gzdoom builder, exporting the map as a .obj file and then importing the file back into gzdoom builder as a map and saving it as a .wad file? cheers
User avatar
Kappes Buur
 
 
Posts: 4114
Joined: Thu Jul 17, 2003 12:19 am
Graphics Processor: nVidia (Legacy GZDoom)
Location: British Columbia, Canada
Contact:

Re: OBJ support in GZDoom

Post by Kappes Buur »

Request :D :

Could somebody make a step by step tutorial about using wavefront obj for GZDOOM.
How to export from GZDoom, manipulate with Blender and import back into GZDoom.
Something like OBJ for Dummies.

moved to viewtopic.php?f=39&t=63858
Last edited by Kappes Buur on Sun Mar 03, 2019 5:51 pm, edited 1 time in total.
User avatar
Arctangent
Posts: 1235
Joined: Thu Nov 06, 2014 1:53 pm
Contact:

Re: OBJ support in GZDoom

Post by Arctangent »

Trusty McLegit wrote:Ohhhhh okay, that makes sense. This is something you couldn't do with MD3?
I'm pretty sure you could make an MD3 of a map, but the MD3 format has hard limits on various aspects of the model and thus any map past a certain complexity would be a complete no-go.
Post Reply

Return to “Tutorials”