princeton-vl / infinigen

Infinite Photorealistic Worlds using Procedural Generation
https://infinigen.org
BSD 3-Clause "New" or "Revised" License
5.16k stars 432 forks source link

Textures baked inversely during export #141

Closed aplatyps closed 10 months ago

aplatyps commented 10 months ago

Hi @David-Yan1 :) I saw that the file infinigen/worldgen/tools/export/export.py is written by you. I think the textures are baked inversely. I tried exporting an asset's (e.g. a flower) mesh and texture after generating via infinigen/worldgen/tools/generate_individual_assets.py and noticed all the textures are upside-down. Could you help take a quick look at it? Thanks!

An example would be as below: https://github.com/princeton-vl/infinigen/assets/103926799/7c06a52c-d953-49bd-8a90-11afedd43fb9

Steps to Reproduce

Run infinigen/worldgen/tools/export/export.py on a .blend file generated via infinigen/worldgen/tools/generate_individual_assets.py

Version of the code were you using? : latest

Platform

David-Yan1 commented 10 months ago

Which file format were you trying to export to?

aplatyps commented 10 months ago

.obj .mtl and .png

David-Yan1 commented 10 months ago

Ah, this seems to be an issue on MeshLab's end, which is what I assume you are using based off of the video. Try changing the Render settings for "Back-face" from Single to Double.

Before:

image

After:

image
aplatyps commented 10 months ago

Ah, I got the inverted texture when visualising it with Trimesh library and Pyrender as well. Maybe they're not compatible with the way bpy encode the faces information.

Screenshot 2023-09-04 at 10 52 01 PM

David-Yan1 commented 10 months ago

Could you send the original blend file and exported zip if possible? Could not replicate the error locally.

aplatyps commented 10 months ago

Here you go

flower.zip

David-Yan1 commented 10 months ago

At least from what I can see, the textures are not inverted when I do a side by side comparison of the objects. It seems to me the "upwards" part of the flower being dark is caused by a simple lack of illumination on that face (as I can just about replicate it if I turn off all light sources in Blender). We don't bake the scene lighting into the exported textures, so you'll have to add lighting in your renderer of choice.

image
aplatyps commented 10 months ago

I see, that explains it! I just need to find a way to illuminate the top part then. Thanks for the promptly replies :)