koerismo / PBR-2-Source

A Python-powered gui for converting pbr materials into Source Engine-compatible materials.
GNU General Public License v3.0
22 stars 2 forks source link

Division by zero #10

Closed klaussilveira closed 4 weeks ago

klaussilveira commented 4 weeks ago

Here's how the configuration is set: image

Output:

Albedo icon updated!
Roughness icon updated!
Metallic icon updated!
Normal icon updated!
Ao icon updated!
Emit icon updated!
Exporting...
Constructing material...
Picking target
Export: Processing textures...
PBR-2-Source/src/module/core/io/image.py:169: RuntimeWarning: divide by zero encountered in power
  self.data **= other
PBR-2-Source/src/module/core/io/image.py:169: RuntimeWarning: overflow encountered in power
  self.data **= other
Export: Making VMT...
Export: Writing files...
Export: Finished exporting exported.vmt!

Exported maps are all off: image

These are the source textures I've used: https://user.fm/files/v2-06db7d2cb6769612004c156dddf6316c/material.zip

koerismo commented 4 weeks ago

Hi, thanks for the detailed report! Whenever this happens (which it will in some cases), it clamps the results, so it shouldn't be the cause of any issues.

I am seeing that it's misinterpreting the colorspace of some of your images, though. Have you tried exporting the textures as linear? The thumbnails should ideally match what you see in the default photo viewer.

klaussilveira commented 4 weeks ago

They are originally DDS textures, so I've used Imagick's convert example.dds -set colorspace RGB example.png. I still have the errors, but if I do convert result.png -alpha off no_alpha.png, the albedo and normal look almost correct:

image

I wonder if this could be an issue with vtex2? I'm using it to convert the VTF back to a PNG.

ps: Yes, definitely vtex2 played a part in here. Added -na as an option and it looks good now. Thank you for the attention on this!

koerismo commented 4 weeks ago

The alpha is used to store phong and envmap information, so the semitransparent output is actually correct. Why convert it back to a png? The vtfs should be readily usable via the generated vmt. (If they aren't, that's a bug.)

klaussilveira commented 4 weeks ago

Oh, I am not using Source 2, that's why. Porting PBR textures to DiffSpecNorm from Quake engines. This tool is incredibly helpful, specially for projects using rend2, like ET: Legacy, OpenJK, IORTCW, ioquake3, etc.