Skip to content

Commit

Permalink
Fluid Refactor (princeton-vl/infinigen_internal/princeton-vl#60)
Browse files Browse the repository at this point in the history
* Acknowledge FLIP-Fluids

* Deduplicate configs

* Remove fluid-specific logic from camera funcs, move to scene_type_fluidsim

* Move river invocation from core.py to compose_scene run_stage calls

* Remove FLIP caustics from release

* Move fire scenecomp and Cached class wrappers under fluid/

* Change on_the_fly to use run_stage

* Move installation to tools/install, make FLIP installation optional and update GeneratingFluidSimulations.md

* Deduplicate river configs, add example commands

* Only unhide assets needed for fire sim, and unhide once done

* Move enable parent cols to butil contextmanager

* Remove unnecessary --blender_path

* Typofixes

* Fix accidentally deleted config fields in new river configs

* Fix finding placeholders for river calls

* Fix impl typo

* Cleanup camera selection varname, unused kwargs

* Catch modulenotfound errors
  • Loading branch information
araistrick authored and pvl-bot committed Aug 14, 2023
1 parent 18152ea commit c534cd8
Show file tree
Hide file tree
Showing 38 changed files with 377 additions and 483 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ Next, see our ["Hello World" example](docs/HelloWorld.md) to generate an image &
- [Extended ground-truth](docs/GroundTruthAnnotations.md)
- [Generating individual assets](docs/GeneratingIndividualAssets.md)
- [Implementing new materials & assets](docs/ImplementingAssets.md)
- [Generating fluid simulations](docs/GeneratingFluidSimulations.md)

### Coming Soon
Please see our [project roadmap](https://infinigen.org/roadmap) and follow us at [https://twitter.com/PrincetonVL](https://twitter.com/PrincetonVL) for updates.
Expand All @@ -67,7 +68,7 @@ Please post this repository's Github Issues page for help. Please run your comma

### Acknowledgements

Infinigen wouldn't be possible without the fantastic work of the [Blender Foundation](https://www.blender.org/) and it's open-source contributors. Infinigen uses many open source projects, with special thanks to [Land-Lab](https://github.com/landlab/landlab), [BlenderProc](https://github.com/DLR-RM/BlenderProc) and [Blender-Differential-Growth](https://github.com/inca/blender-differential-growth).
Infinigen wouldn't be possible without the fantastic work of the [Blender Foundation](https://www.blender.org/) and it's open-source contributors. Infinigen uses many open source projects, with special thanks to [Land-Lab](https://github.com/landlab/landlab), [BlenderProc](https://github.com/DLR-RM/BlenderProc) [Blender-FLIP-Fluids](https://github.com/rlguy/Blender-FLIP-Fluids) and [Blender-Differential-Growth](https://github.com/inca/blender-differential-growth).

We thank [Thomas Kole](https://blenderartists.org/u/ThomasKole) for providing procedural clouds (which are more photorealistic than our original version) and [Pedro P. Lopes](https://blendswap.com/blend/30728) for the autoexposure nodegraph.

Expand Down
27 changes: 27 additions & 0 deletions docs/GeneratingFluidSimulations.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Generating Fluid Simulations

This documentation details how to generate fire and water simulations like those shown in the Infinigen launch video. It assumes you have already completed [Installation.md] and [HelloWorld.md]. Fluid simulations require *significant* computational resources.

## Setup

To generate fluids, you run install.sh with the optional FLIP-Fluids setup step (`bash install.sh flip_fluids`), or, please run `bash worldgen/tools/install/compile_flip_fluids.sh` to install flip fluids now.

## Example Commands

#### Generate videos of random scene types, with simulated fire generated on the fly when needed
```
python -m tools.manage_datagen_jobs --output_folder outputs/onthefly --num_scenes 10 \
--pipeline_config slurm_high_memory.gin monocular_video.gin \
--config fast_terrain_assets.gin use_on_the_fly_fire.gin \
--wandb_mode online --cleanup none --warmup_sec 12000
```

#### Generate videos of valley scenes with simulated rivers
```
python -m tools.manage_datagen_jobs --output_folder /n/fs/pvl-renders/kkayan/river --num_scenes 10 \
--pipeline_config slurm_high_memory.gin monocular_video.gin opengl_gt.gin cuda_terrain.gin \
--pipeline_overrides iterate_scene_tasks.frame_range=[100,244] \
--config simulated_river.gin no_assets.gin no_creatures.gin fast_terrain_assets.gin \
--wandb_mode online --cleanup none --warmup_sec 12000
```

3 changes: 2 additions & 1 deletion docs/Installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ conda activate infinigen
bash install.sh
```
`install.sh` may take significant time to download Blender and compile all source files.

Ignore non-fatal warnings. See [Getting Help](#getting-help) for guidelines on posting github issues

:bulb: If you anticipate you will want to enable our custom ground-truth system, or generate fluid simulatios, consider running `bash install.sh opengl` or `bash install.sh flip_fluids` to enable these optional extras as specified in [GroundTruthAnnotations.md](./GroundTruthAnnotations.md) and [GeneratingFluidSimulations](./GeneratingFluidSimulations.md).

Run the following or add it to your `~/.bashrc` (Linux/WSL) or `~/.bash_profile` (Mac)
```
# on Linux/WSL
Expand Down
15 changes: 3 additions & 12 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -120,20 +120,11 @@ rm -rf build
cd -

if [ "$1" = "opengl" ]; then
bash ./worldgen/tools/compile_opengl.sh
bash ./worldgen/tools/install/compile_opengl.sh
fi


# Build Flip Fluids addon
FLIP_FLUIDS="https://github.com/rlguy/Blender-FLIP-Fluids"
FLIP_FLUIDS_FOLDER="Blender-FLIP-Fluids"
FLIP_FLUIDS_ADDON_FOLDER="${FLIP_FLUIDS_FOLDER}/build/bl_flip_fluids/flip_fluids_addon"

if [ ! -d "${FLIP_FLUIDS_ADDON_FOLDER}" ]; then
git clone "${FLIP_FLUIDS}"
cd "${FLIP_FLUIDS_FOLDER}"
python build.py
cd -
cp -r "${FLIP_FLUIDS_ADDON_FOLDER}" "${BLENDER_ADDONS}"
"${BLENDER_EXE}" --background -noaudio -P ./worldgen/fluid/flip_init.py
if [ "$1" = "flip_fluids" ] || if [ "$2" = "flip_fluids" ]; then
bash ./worldgen/tools/install/compile_flip_fluids.sh
fi
5 changes: 1 addition & 4 deletions worldgen/assets/boulder.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,4 @@ def create_asset(self, i, placeholder, face_size=0.01, distance=0, **params):
detail.adapt_mesh_resolution(skin_obj, face_size, method=self.adapt_mesh_method, apply=True)

tag_object(skin_obj, 'boulder')
return skin_obj

class CachedBoulderFactory(BoulderFactory):
pass
return skin_obj
2 changes: 1 addition & 1 deletion worldgen/assets/cactus/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# Date: April 13 2023

from .generate import CactusFactory, ColumnarCactusFactory, GlobularCactusFactory, PrickyPearCactusFactory, \
KalidiumCactusFactory, CachedCactusFactory
KalidiumCactusFactory
from .columnar import ColumnarBaseCactusFactory
from .globular import GlobularBaseCactusFactory
from .pricky_pear import PrickyPearBaseCactusFactory
Expand Down
4 changes: 0 additions & 4 deletions worldgen/assets/cactus/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,3 @@ class KalidiumCactusFactory(CactusFactory):

def __init__(self, factory_seed, coarse=False):
super(KalidiumCactusFactory, self).__init__(factory_seed, coarse, KalidiumBaseCactusFactory)


class CachedCactusFactory(CactusFactory):
pass
2 changes: 1 addition & 1 deletion worldgen/assets/creatures/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from .genomes.beetle import BeetleFactory, AntSwarmFactory
from .genomes.bird import BirdFactory, FlyingBirdFactory
from .genomes.carnivore import CarnivoreFactory, CachedCreatureFactory
from .genomes.carnivore import CarnivoreFactory
from .genomes.fish import FishFactory, FishSchoolFactory
from .genomes.herbivore import HerbivoreFactory
from .genomes.crustacean import CrustaceanFactory, CrabFactory, LobsterFactory, SpinyLobsterFactory
Expand Down
5 changes: 1 addition & 4 deletions worldgen/assets/creatures/genomes/carnivore.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,4 @@ def create_asset(self, i, placeholder, hair=True, simulate=False, **kwargs):
cloth_sim.bake_cloth(joined, genome.postprocess_params['skin'],
attributes=dict(vertex_group_mass=rigidity))

return root

class CachedCreatureFactory(CarnivoreFactory):
pass
return root
2 changes: 1 addition & 1 deletion worldgen/assets/trees/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from .generate import BushFactory, TreeFactory, CachedTreeFactory, CachedBushFactory
from .generate import BushFactory, TreeFactory
9 changes: 1 addition & 8 deletions worldgen/assets/trees/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,11 +418,4 @@ def __init__(self, seed, coarse=False, **kwargs):
self.child_col.name = colname
assert self.child_col.name == colname, f'Blender truncated {colname} to {self.child_col.name}'
else:
self.child_col = bpy.data.collections[colname]


class CachedBushFactory(BushFactory):
pass

class CachedTreeFactory(TreeFactory):
pass
self.child_col = bpy.data.collections[colname]
14 changes: 8 additions & 6 deletions worldgen/config/base.gin
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ compose_scene.lighting_enabled = True
compose_scene.coarse_terrain_enabled = True
compose_scene.terrain_surface_enabled = True

compose_scene.simulated_river_enabled=False
compose_scene.tilted_river_enabled=False

compose_scene.fancy_clouds_chance = 0.6

compose_scene.trees_chance = 0.85
Expand Down Expand Up @@ -100,13 +103,12 @@ populate_scene.snow_layer_chance = 0

populate_scene.snow_layer_chance=0.0


populate_scene.fire_warmup = 50
populate_scene.trees_fire_chance_on_the_fly = 0
populate_scene.bushes_fire_chance_on_the_fly = 0
populate_scene.creatures_fire_chance_on_the_fly = 0
populate_scene.boulders_fire_chance_on_the_fly = 0
populate_scene.cactus_fire_chance_on_the_fly = 0
populate_scene.trees_fire_on_the_fly_chance = 0
populate_scene.bushes_fire_on_the_fly_chance = 0
populate_scene.creatures_fire_on_the_fly_chance = 0
populate_scene.boulders_fire_on_the_fly_chance = 0
populate_scene.cactus_fire_on_the_fly_chance = 0

target_face_size.global_multiplier = 2
scatter_res_distance.dist = 4
Expand Down
61 changes: 0 additions & 61 deletions worldgen/config/scene_types/simulated_river.gin

This file was deleted.

64 changes: 0 additions & 64 deletions worldgen/config/scene_types/tilted_river.gin

This file was deleted.

30 changes: 30 additions & 0 deletions worldgen/config/scene_types_fluidsim/simulated_river.gin
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
include 'config/scene_types/river.gin'

UniformMesher.enclosed=1
animate_cameras.policy_registry = @cam/AnimPolicyRandomForwardWalk
cam/AnimPolicyRandomForwardWalk.forward_vec = (0,0,-1)
cam/AnimPolicyRandomForwardWalk.speed = 1
cam/AnimPolicyRandomForwardWalk.step_range = (5, 10)
cam/AnimPolicyRandomForwardWalk.yaw_dist = ("uniform",-10, 10)

keep_cam_pose_proposal.min_terrain_distance = 1

compose_scene.hero_boulders_chance = 0.0
compose_scene.simulated_river_enabled = True

terrain.elements.landtiles.LandTiles.y_tilt = 0
terrain.elements.landtiles.LandTiles.y_tilt_clip = 0

camera_pose_proposal.override_loc = (0.45, -24, 8)
camera_pose_proposal.roll = 180
camera_pose_proposal.pitch = ("normal", -120, 5)
camera_pose_proposal.yaw = ('normal', -180, 3)

assets.boulder.create_placeholder.boulder_scale = 1
LandTiles.land_process = None
camera_selection_preprocessing.terrain_tags_ratio = {("altitude", -1e9, 0.75): (0, 1), "liquid": (0, 1)}

core.render.hide_water = True
compute_base_views.min_candidates_ratio = 1
walk_same_altitude.ignore_missed_rays = True

30 changes: 30 additions & 0 deletions worldgen/config/scene_types_fluidsim/tilted_river.gin
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
include 'config/scene_types/river.gin'

UniformMesher.enclosed=1
animate_cameras.policy_registry = @cam/AnimPolicyRandomForwardWalk
cam/AnimPolicyRandomForwardWalk.forward_vec = (0,0,-1)
cam/AnimPolicyRandomForwardWalk.speed = 1
cam/AnimPolicyRandomForwardWalk.step_range = (5, 10)
cam/AnimPolicyRandomForwardWalk.yaw_dist = ("uniform",-10, 10)


keep_cam_pose_proposal.min_terrain_distance = 1

compose_scene.hero_boulders_chance = 1.0

terrain.elements.landtiles.LandTiles.y_tilt = 0.7
terrain.elements.landtiles.LandTiles.y_tilt_clip = 11
camera_pose_proposal.override_loc = (0.678843,-30.5532, 11.7858)
camera_pose_proposal.roll = ('normal', -110, 5)
camera_pose_proposal.pitch = 180
camera_pose_proposal.yaw = ('normal', -180, 3)

compose_scene.tilted_river_enabled = True

assets.boulder.create_placeholder.boulder_scale = 3
LandTiles.land_process = None
camera_selection_preprocessing.terrain_tags_ratio = {("altitude", -1e9, 0.75): (0, 1), "liquid": (0, 1)}

core.render.hide_water = True
compute_base_views.min_candidates_ratio = 1
walk_same_altitude.ignore_missed_rays = True
Loading

0 comments on commit c534cd8

Please sign in to comment.