No way to tell obj where to look for materials

Is there something that doesn't work right in the latest GZDoom? Post about it here.

Moderator: Developers

Forum rules
Please construct and post a simple demo whenever possible for all bug reports. Please provide links to everything.

If you can include a wad demonstrating the problem, please do so. Bug reports that include fully-constructed demos have a much better chance of being investigated in a timely manner than those that don't.

No way to tell obj where to look for materials

Postby Jaxxoon R » Mon Sep 03, 2018 12:13 am

[g3.6pre-57-g2d1043d1d]

With the new obj-format models there's no way to point to the materials defined within them, leading to warnings in the console. Neither placing the mtl files in the model's directory nor in the materials directory prevents this. Even removing materials on the model altogether simply causes them to leave an error about not finding a material called "none."
Attachments
obj.pk3
(69.83 KiB) Downloaded 20 times
User avatar
Jaxxoon R
 
Joined: 04 May 2014

Re: No way to tell obj where to look for materials

Postby Talon1024 » Tue Oct 02, 2018 8:29 am

Here's my writeup on OBJ support

GZDoom looks for materials for OBJs in TEXTUREx, TEXTURES, and full paths.
Talon1024
 
 
 
Joined: 27 Jun 2016

Re: No way to tell obj where to look for materials

Postby Rachael » Tue Oct 09, 2018 2:51 am

Talon1024 wrote:Here's my writeup on OBJ support

GZDoom looks for materials for OBJs in TEXTUREx, TEXTURES, and full paths.

Does this mean that there is no bug here?
User avatar
Rachael
QZDoom + Webmaster
 
Joined: 13 Jan 2004

Re: No way to tell obj where to look for materials

Postby Graf Zahl » Tue Oct 09, 2018 2:54 am

I think it means that it doesn't look in the model definition's material path - which would definitely be a bug. This should be consistent for all model types.
User avatar
Graf Zahl
Lead GZDoom Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: No way to tell obj where to look for materials

Postby Talon1024 » Thu Oct 25, 2018 10:58 pm

The OBJ code throws those "material not found" errors while it is parsing the OBJ file, so it has no idea about SurfaceSkin replacements until you start playing on a map with the OBJ models, since curSpriteMDLFrame is not updated until the game decides to render the models. I could print a warning from RenderFrame if a certain material is not found, but I don't want to spam the console with 'Material X not found' warnings while the player is ingame, although it would be nice to notify the modder about missing materials.

On the other hand, it doesn't look like the other model formats throw warnings about missing materials either. Is the best solution to remove those warnings, or am I completely misunderstanding this bug report? I mean, the models from the pk3 are visible ingame on the demo map.
Talon1024
 
 
 
Joined: 27 Jun 2016

Re: No way to tell obj where to look for materials

Postby Graf Zahl » Thu Nov 01, 2018 2:45 am

The main problem here is that the initial model definition was never meant to solve more than an immediate need loading a Vavoom map properly.
Sadly, when it got expanded to a real feature nobody thought about cleaning up those shortcuts.
User avatar
Graf Zahl
Lead GZDoom Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: No way to tell obj where to look for materials

Postby Nash » Thu Nov 01, 2018 3:35 am

Graf Zahl wrote:The main problem here is that the initial model definition was never meant to solve more than an immediate need loading a Vavoom map properly.
Sadly, when it got expanded to a real feature nobody thought about cleaning up those shortcuts.


Time to deprecate that MODELDEF... :mrgreen:
User avatar
Nash
Nash Muhandes
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia

Re: No way to tell obj where to look for materials

Postby Graf Zahl » Thu Nov 01, 2018 3:45 am

Only the skin property needs to be deprecated, and hereby I declare it so... :mrgreen:
User avatar
Graf Zahl
Lead GZDoom Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: No way to tell obj where to look for materials

Postby Talon1024 » Thu Nov 01, 2018 5:32 am

So, in other words, I need to make GZDoom read the .mtl files that come with each .obj in order to fix this bug?

Fine...
Talon1024
 
 
 
Joined: 27 Jun 2016

Re: No way to tell obj where to look for materials

Postby Graf Zahl » Thu Nov 01, 2018 5:36 am

Aren't you doing that already?

Regarding this issue, I'm not sure what to do about it. That old skin property was initially meant to override what is set in the model. So the case that a model comes without its internally set skins provided is a valid situation that needs to be considered.

That is, unless we really decide to deprecate that property...
User avatar
Graf Zahl
Lead GZDoom Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: No way to tell obj where to look for materials

Postby Enjay » Thu Nov 01, 2018 2:24 pm

Having spent a bit of time messing around with models that I have downloaded from a variety of sources and extracted from a fair number of games, it is VERY common for models to have internally set skin names that are different to the graphics files/skins that are actually packed with them (either relying on some game specific config lump to specify them correctly or (if not directly from a game) expecting an end user to create such a lump themselves before they can be used). So, under those circumstances, being able to use the skin property to override internally set names is actually very useful.

Moreover, because internally set skin names have historically basically been ignored by GZDoom, there has been no need to ensure the internal name and the skin match. e.g. in my case it's not uncommon for me to have a working name for the model and skin files but I might change them to something more suitable for distribution when packaging up the mod and, of course, there is no reason to edit the model to change the internal name because I can just override it with MODELDEF (so I have done).

Then there is the possibility of different actors using the same model but different skins (e.g. many of the enemies in my Genetech mod - such as the workers, the basic grunt soldiers, the scientists, the civilians and a few others). Without the skin property in MODELDEF, and only being able to use internal names from the model, each new skin would need a new copy of an otherwise identical model too (potentially increasing a mod size by many megabytes).

So, the skin property in MODELDEF is very useful IMO.
User avatar
Enjay
Everyone is a moon, and has a dark side which he never shows to anybody. Twain
 
 
 
Joined: 15 Jul 2003
Location: Scotland

Re: No way to tell obj where to look for materials

Postby Gez » Thu Nov 01, 2018 4:27 pm

Enjay wrote:Having spent a bit of time messing around with models that I have downloaded from a variety of sources and extracted from a fair number of games, it is VERY common for models to have internally set skin names that are different to the graphics files/skins that are actually packed with them (either relying on some game specific config lump to specify them correctly or (if not directly from a game) expecting an end user to create such a lump themselves before they can be used).

And it's still something actively used in modern games, because it's more efficient to have one model, twelve texturesets, and twelve definitions associating the model with a different textureset than the one backed in than to have twelve different models.
Gez
 
 
 
Joined: 06 Jul 2007

Re: No way to tell obj where to look for materials

Postby Major Cooke » Fri Nov 02, 2018 11:42 am

Graf Zahl wrote:Aren't you doing that already?

Regarding this issue, I'm not sure what to do about it. That old skin property was initially meant to override what is set in the model. So the case that a model comes without its internally set skins provided is a valid situation that needs to be considered.

That is, unless we really decide to deprecate that property...


I for starters would LOVE it if a .mtl file could be read so I don't have to deal with the bullshit of having to unwrap/retexture objects I export from GZDoom Builder (which, yes, has that option). This would be a very welcome addition for OBJ formats.

But deprecating the skin property... How else are we supposed to provide the textures for it? How do you put them in and have them export via blender directly into the model then? I for one have seen NO signs of being able to ever do this. Please do tell me how! I'd love being able to avoid needing to export the skin as well.

Second, if you deprecate the skin property, I don't see how we'll be able to apply materials like specular, normals, and bright maps.
User avatar
Major Cooke
The road to Hell is paved in the carrion she leaves behind.
 
Joined: 28 Jan 2007
Discord: Major Cooke#0846

Re: No way to tell obj where to look for materials

Postby Major Cooke » Fri Nov 02, 2018 11:49 am

Jaxxoon, there is a way to do it. As you can see from this image it's possible. This is a bit of a roundabout way but it works.

  1. Create an entry in a TEXTURES lump like this, setting the lump's dimensions to the size of the image (in my case, 1024 x 1024).
    Code: Select allExpand view
    Graphic "BFGAmmoSkin", 1024, 1024
    {
       Patch "Materials/BFGAmmoSkin.jpg", 0, 0
    }
  2. Set all your materials into the Auto folders. withe the same name as "BFGAmmoSkin.jpg" or the likes (you can leave the extensions like .jpg in, it'll read them just fine)
  3. Define your model as such:
    Code: Select allExpand view
    Model "D4BFGAmmo"
    {
       Scale 1.0 1.0 1.2
       Skin 0 "BFGAmmoSkin"
       Model 0 "Models/BFGAmmoBase.md3"
       FrameIndex AMBF B 0 0
    }
  4. Not sure if this is actually needed but just in case... Define the material in GLDefs like this.
    Code: Select allExpand view
    Material Sprite BFGAmmoSkin {}

If you want to see more on how I did it, check out D4D Alpha 8.3 where I used this method for all the pickup items on ammo, armor, and health.
Last edited by Major Cooke on Fri Nov 02, 2018 11:55 am, edited 1 time in total.
User avatar
Major Cooke
The road to Hell is paved in the carrion she leaves behind.
 
Joined: 28 Jan 2007
Discord: Major Cooke#0846

Re: No way to tell obj where to look for materials

Postby dpJudas » Fri Nov 02, 2018 11:55 am

I'm not familiar with the contents of .mtl files, but the general approach I've used for materials has been that the base texture name acts as the material name within GZDoom.

For simplicity sake, I don't think it is a good idea to introduce another material format into the mix. If the mtl filename itself can't be mapped directly to a base texture, then we do need some kind of entry in GLDEFS that does this mapping.
dpJudas
 
 
 
Joined: 28 May 2016

Next

Return to Bugs

Who is online

Users browsing this forum: No registered users and 2 guests