Skip to content

Commit

Permalink
Fix typos in export documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
araistrick committed May 26, 2024
1 parent f5bcba8 commit f98b957
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 21 deletions.
67 changes: 49 additions & 18 deletions docs/ExportingToExternalFileFormats.md
Original file line number Diff line number Diff line change
@@ -1,54 +1,85 @@


# Asset Exporter

This documentation details how to create an OBJ, FBX, STL, PLY or OpenUSD file from a `.blend` file, such as those produced by [Hello World](HelloWorld.md) or [Generating Individual Assets](./GeneratingIndividualAssets.md).

Blender does provide a built-in exporter, but it wont work out of the box for Infinigen since our files contain procedural materials and assets defined using shader programs. This tool's job is to "bake" all these procedural elements into more standard graphics formats (i.e, simple meshes with materials made of texture maps), before invoking the standard blender exporter. This process can be slow, since it uses a rendering engine, and lossy, since the resulting textures have a finite resolution.
This documentation details how to create an OBJ, FBX, STL, PLY or OpenUSD file from a `.blend` file, such as those produced by [Hello World](HelloWorld.md) or [Generating Individual Assets](./GeneratingIndividualAssets.md).


Blender does provide a built-in exporter, but it wont work out of the box for Infinigen’s blend files, since they contain procedural materials and assets. The commands below will bake these procedural elements into more standard graphics formats, such as static meshes with materials made of texture maps, before invoking the standard blender exporter.


To convert a folder of blender files into USD files (our recommmended format), use the command below:
This process can be slow, since it uses a rendering engine, and lossy, since the resulting textures have a finite resolution.


To convert a folder of blender files into USD files, use the command below:
```bash
python -m infinigen.tools.export --input_folder {PATH_TO_FOLDER_OF_BLENDFILES} --output_folder outputs/my_export -f usdc -r 1024
```


If you want a different output format, please use the "--help" flag or use one of the options below:
- `-f obj` will export in .obj format,
- `-f obj` will export in .obj format,
- `-f fbx` will export in .fbx format
- `-f stl` will export in .stl format
- `-f ply` will export in .ply format.
- `-f usdc` will export in .usdc format.
- `-v` enables per-vertex colors (only compatible with .fbx and .ply formats).
- `-f ply` will export in .ply format.
- `-f usdc` will export in .usdc format.
- `-v` enables per-vertex colors (only compatible with .fbx and .ply formats).
- `-r {INT}` controls the resolution of the baked texture maps. For instance, `-r 1024` will export 1024 x 1024 texture maps.
- `--individual` will export each object in a scene in its own individual file.

## :warning: Exporting full Infinigen scenes is only supported for USDC files.

:bulb: Note: exporting OBJ/FBX files of **single objects** *generally works fine; this discussion only refers to large-scale scenes.
## :warning: Exporting full Infinigen scenes is only supported for USDC files.


Infinigen uses of *instancing* to represent densely scattered objects. That is, rather than storing millions of unique high-detail pebbles or leaves to scatter on the floor, we use a smaller set of unique objects which are stored in memory only once, but are repeated all over the scene with many different transforms.
:bulb: Note: exporting OBJ/FBX files of **single objects** *generally works fine; this discussion only refers to large-scale nature scenes.


Infinigen uses *instancing* to represent densely scattered objects. That is, rather than storing millions of unique high-detail pebbles or leaves to scatter on the floor, we use a smaller set of unique objects which are stored in memory only once, but are repeated all over the scene with many different transforms.


To our knowledge, no file formats except '.blend' and '.usdc' support saving instanced geometry. For all file formats besides these two, instances will be *realized*: instead of storing just a few unique meshes, the meshes will be copied, pasted and transformed thousands of times (once for each unique scatter location). This creates a simple mesh that can be stored as an OBJ, but the cost is so high that we do not recommend attempting it for full Infinigen scenes.

To our knowledge, no file formats except '.blend' and '.usdc' support saving 3D files that contain instanced geometry. For all file formats besides these two, instanced will be *realized*: instead of storing just a few unique meshes, the meshes will be copied, pasted and transformed thousands of times (once for each unique scatter location). This creates a simple mesh that, but the cost is so high that we do not recommend attempting it for full Infinigen scenes.

If you require OBJ/FBX/PLY files for your research, you have a few options:
- You can use individual objects, rather than full scenes. These *generally dont contain instancing so can be exported to simple mesh formats.
- You can use individual objects, rather than full scenes. These *generally don't contain instancing so can be exported to simple mesh formats.
- You can use advice in [Configuring Infinigen](./ConfiguringInfinigen.md) to create a scene that has very small extent or low detail, such that the final realized mesh will still be small enough to fit in memory.
- You can use the advice in [Configuring Infinigen](./ConfiguringInfinigen.md) to create a scene which simply doesnt contain any instanced objects. Specifically, you should turn off trees and all scattered objects.
- The simplest way to do this is to turn off everything except terrain, by including the config `no_assets.gin`.
- You can use the advice in [Configuring Infinigen](./ConfiguringInfinigen.md) to create a scene which simply does not contain any instanced objects. Specifically, you should turn off trees and all scattered objects.
- The simplest way to do this is to turn off everything except terrain, by including the config `no_assets.gin`.


*Infinigen's implementation of trees uses instances to represent leaves and branches. Trees are also generally large and detailed to cause issues if you realize them before exporting. Therefore, exporting whole trees as OBJs also generally isn't supported, unless you do so at very low resolution, or you turn off the tree's branches / leaves first.

*caveat for the above: Infinigen's implementation for trees uses instances to represent leaves and branches. Trees are also generally large and high detail enough to cause issues if you realize them before exporting. Therefore, exporting whole trees as OBJs also generally isnt supported, unless you do so at very low resolution, or you turn off the tree's branches / leaves first.

## Other Known Issues and Limitations

* Some material features used in Infinigen are not yet supported by this exporter. Specifically, this script only handles Albedo, Roughness and Metallicity maps. Any other procedural parameters of the material will be ignored, so you should not expect complex materials (e.g skin, translucent leaves, glowing lava) to be perfectly reproduced outside of Blender. Depending on file format, there is limited support for materials with non-procedural, constant values of transmission, clearcoat, and sheen.

* Some material features used in Infinigen are not yet supported by this exporter. Specifically, this script only handles Albedo, Roughness and Metallicity maps. Any other procedural parameters of the material will be ignored. Many file formats also have limited support for spatially varying transmission, clearcoat, and sheen. Generally, you should not expect any materials (but especially skin, translucent leaves, glowing lava) to be perfectly reproduced outside of Blender.


* Exporting *animated* 3D files is generally untested and not officially supported. This includes exporting particles, articulated creatures, deforming plants, etc. These features are *in principle* supported by OpenUSD, but are untested by us and not officially supported by this export script.


* Assets with transparent materials (water, glass-like materials, etc.) may have incorrect textures for all material parameters after export.

* Large scenes and assets may take a long time to export and will crash Blender if you do not have a sufficiently large amount of memory. The export results may also be unusably large.

* Large scenes and assets may take a long time to export and will crash Blender if you do not have enough RAM. The export results may also be unusably large.


* When exporting in .fbx format, the embedded roughness texture maps in the file may sometimes be too bright or too dark. The .png roughness map in the folder is accurate, however.

* .fbx exports ocassionally fail due to invalid UV values on complicated geometry. Adjusting the 'island_margin' value in bpy.ops.uv.smart_project() sometimes remedies this

* .fbx exports occasionally fail due to invalid UV values on complicated geometry. Adjusting the 'island_margin' value in bpy.ops.uv.smart_project() sometimes remedies this













Expand Down
10 changes: 7 additions & 3 deletions docs/HelloWorld.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ python -m infinigen_examples.generate_nature --seed 0 --task render -g desert.gi

Output logs should indicate what the code is working on. Use `--debug` for even more detail. After each command completes you can inspect it's `--output_folder` for results, including running `python -m infinigen.launch_blender outputs/hello_world/coarse/scene.blend` or similar to view blender files. We hide many meshes by default for viewport stability; to view them, click "Render" or use the UI to unhide them.

## Generate image(s) in one command
## Generate scenes in one command

We provide `infinigen/datagen/manage_jobs.py`, a utility which runs similar steps automatically.

Expand All @@ -47,6 +47,10 @@ python -m infinigen.datagen.manage_jobs --output_folder outputs/hello_world --nu

This command will repeatedly print summaries of the status of each stage of the pipeline. Please look in `outputs/hello_world/1/logs` for full output logs of the underlying tasks.

We encourage you to visit [Configuring Infinigen](ConfiguringInfinigen.md) for a breakdown of this command and more advanced usage instructions / example commands.
## Next steps

See [Extended ground-truth](GroundTruthAnnotations.md) for a guide on using our custom ground-truth extraction system.
Read [Configuring Infinigen](ConfiguringInfinigen.md) for more advanced usage instructions / example commands.

See [Extended ground-truth](GroundTruthAnnotations.md) for a guide on using our custom ground-truth extraction system.

See [ExportingToExternalFileFormats](ExportingToExternalFileFormats.md) for advice on exporting to OBJ/USD and more.

0 comments on commit f98b957

Please sign in to comment.