Skip to content

Commit

Permalink
Merge pull request from branch 'develop'
Browse files Browse the repository at this point in the history
v1.5.1
  • Loading branch information
pvl-bot committed Jul 12, 2024
2 parents 931d1e5 + e692ce8 commit c537e24
Show file tree
Hide file tree
Showing 31 changed files with 257 additions and 105 deletions.
11 changes: 0 additions & 11 deletions .github/dependabot.yml

This file was deleted.

39 changes: 13 additions & 26 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,23 @@ RUN if [ "$APP_IMAGE" = "nvidia/cuda:12.0.0-devel-ubuntu22.04" ]; then \
echo "Using CUDA image" && \
apt-get update && \
apt-get install -y unzip sudo git g++ libglm-dev libglew-dev libglfw3-dev libgles2-mesa-dev zlib1g-dev wget cmake vim libxi6 libgconf-2-4 && \
wget \
https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh \
&& mkdir /root/.conda \
&& bash Miniconda3-latest-Linux-x86_64.sh -b \
&& rm -f Miniconda3-latest-Linux-x86_64.sh; \
&& apt-get install libxkbcommon-x11-0 \
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh && \
mkdir /root/.conda && \
bash Miniconda3-latest-Linux-x86_64.sh -b && \
rm -f Miniconda3-latest-Linux-x86_64.sh && \
apt-get install -y libxkbcommon-x11-0; \
else \
echo "Using Conda image" && \
apt-get update -yq \
&& apt-get install -yq \
cmake \
g++ \
libgconf-2-4 \
libgles2-mesa-dev \
libglew-dev \
libglfw3-dev \
libglm-dev \
libxi6 \
sudo \
unzip \
vim \
zlib1g-dev; \
&& apt-get install libxkbcommon-x11-0 \
apt-get update -yq && \
apt-get install -yq cmake g++ libgconf-2-4 libgles2-mesa-dev libglew-dev libglfw3-dev libglm-dev libxi6 sudo unzip vim zlib1g-dev && \
apt-get install -y libxkbcommon-x11-0; \
fi

RUN mkdir /opt/infinigen
WORKDIR /opt/infinigen
COPY . .
RUN conda init bash \
&& . ~/.bashrc \
&& conda create --name infinigen python=3.10 \
&& conda activate infinigen \
&& pip install -e .[dev]
RUN conda init bash && \
. ~/.bashrc && \
conda create --name infinigen python=3.10 -y && \
conda activate infinigen && \
pip install -e .[dev]
8 changes: 8 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,11 @@ v1.5.0
- minimize pip dependences: remove unused packages & move terrain/gt-vis packages into optional \[terrain,vis\] extras.
- add parameters for object clutter, reduce excessively cluttered / slow indoors scenes
- minorly improve infinigen-indoors performance via logging & asset hiding

v1.5.1
- Fix "base.gin" crash in generate_individual_assets
- Fix individual_export in export.py
- Fix Dockerfile
- Remove dependabot
- Add scatter unit tests and fix scatter imports
- Fix black renders due to non-hidden particle emitter
18 changes: 17 additions & 1 deletion docs/GeneratingIndividualAssets.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,23 @@ python -m infinigen_examples.generate_individual_assets --output_folder outputs/

Running the above commands will save images and .blend files into your `outputs` folder. You can customize what object is generated by changing the `-f` argument to the name of a different AssetFactory defined in the codebase (see the file `tests/test_meshes_basic.txt` for a partial list).

Please run `python -m infinigen.tools.generate_individual_assets --help` for a full list of commandline arguments.
Please run `python -m infinigen_examples.generate_individual_assets --help` for a full list of commandline arguments.

### Generate many different assets in one command

:warning: There are a small number of assets which are used in the main system but are not included in the tests/assets/*.txt lists for various reasons. You can read the commented lines in `tests/assets/list_nature_meshes.txt` for a partial list. There are also other types of procedural generators (lighting, colors, scatters, volumetrics, animations, etc) besides meshes/materials, which add diversity to the main rendering system but are not included in the commands below.

Generate one of each mesh in the unit tests list:
```bash
python -m infinigen_examples.generate_individual_assets --output_folder outputs/corals -f tests/assets/list_nature_meshes.txt -n 1 --save_blend
python -m infinigen_examples.generate_individual_assets --output_folder outputs/corals -f tests/assets/list_indoor_meshes.txt -n 1 --save_blend
```

Generate one of each material in the unit tests list:
```bash
python -m infinigen_examples.generate_individual_assets --output_folder outputs/corals -f tests/assets/list_nature_materials.txt -n 1 --save_blend
python -m infinigen_examples.generate_individual_assets --output_folder outputs/corals -f tests/assets/list_indoor_materials.txt -n 1 --save_blend
```

### Creating OBJ, USD, FBX and other file formats

Expand Down
Empty file added infinigen/.dockerignore
Empty file.
2 changes: 1 addition & 1 deletion infinigen/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logging
from pathlib import Path

__version__ = "1.5.0"
__version__ = "1.5.1"


def repo_root():
Expand Down
2 changes: 1 addition & 1 deletion infinigen/assets/objects/deformed_trees/fallen.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import numpy as np
from numpy.random import uniform

from infinigen.assets.deformed_trees.base import BaseDeformedTreeFactory
from infinigen.assets.objects.deformed_trees.base import BaseDeformedTreeFactory
from infinigen.assets.utils.decorate import remove_vertices
from infinigen.assets.utils.draw import cut_plane
from infinigen.assets.utils.misc import assign_material
Expand Down
10 changes: 4 additions & 6 deletions infinigen/assets/objects/deformed_trees/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@

import numpy as np

from infinigen.assets.deformed_trees import (
FallenTreeFactory,
HollowTreeFactory,
RottenTreeFactory,
)
from infinigen.assets.deformed_trees.truncated import TruncatedTreeFactory
from infinigen.assets.objects.deformed_trees.fallen import FallenTreeFactory
from infinigen.assets.objects.deformed_trees.hollow import HollowTreeFactory
from infinigen.assets.objects.deformed_trees.rotten import RottenTreeFactory
from infinigen.assets.objects.deformed_trees.truncated import TruncatedTreeFactory
from infinigen.core.placement.factory import AssetFactory
from infinigen.core.util.math import FixedSeed

Expand Down
2 changes: 1 addition & 1 deletion infinigen/assets/objects/deformed_trees/hollow.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import numpy as np
from numpy.random import uniform

from infinigen.assets.deformed_trees.base import BaseDeformedTreeFactory
from infinigen.assets.objects.deformed_trees.base import BaseDeformedTreeFactory
from infinigen.assets.utils.decorate import (
read_co,
read_material_index,
Expand Down
2 changes: 1 addition & 1 deletion infinigen/assets/objects/deformed_trees/rotten.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import numpy as np
from numpy.random import uniform

from infinigen.assets.deformed_trees.base import BaseDeformedTreeFactory
from infinigen.assets.objects.deformed_trees.base import BaseDeformedTreeFactory
from infinigen.assets.utils.decorate import (
read_material_index,
remove_vertices,
Expand Down
2 changes: 1 addition & 1 deletion infinigen/assets/objects/deformed_trees/truncated.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import numpy as np
from numpy.random import uniform

from infinigen.assets.deformed_trees import FallenTreeFactory
from infinigen.assets.objects.deformed_trees import FallenTreeFactory
from infinigen.assets.utils.decorate import read_co
from infinigen.core import surface
from infinigen.core.nodes.node_info import Nodes
Expand Down
3 changes: 2 additions & 1 deletion infinigen/assets/scatters/chopped_trees.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
)
from infinigen.core.placement.instance_scatter import scatter_instances
from infinigen.core.util import blender as butil
from infinigen.core.util import math as mutil
from infinigen.core.util.math import randomspacing, rotate_match_directions

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -65,7 +66,7 @@ def chop_object(obj, n, cutter_size, max_tilt=15, thickness=0.03):

def cutter(t):
butil.select_none()
z = butil.lerp(bbox[:, -1].min(), bbox[:, -1].max(), t)
z = mutil.lerp(bbox[:, -1].min(), bbox[:, -1].max(), t)
loc = (*bbox[:, :-1].mean(axis=0), z)
bpy.ops.mesh.primitive_plane_add(size=cutter_size, location=loc)
cut = bpy.context.active_object
Expand Down
3 changes: 1 addition & 2 deletions infinigen/assets/scatters/clothes.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import numpy as np
from numpy.random import uniform

from infinigen.assets.objects.clothes import blanket, pants, shirt
from infinigen.assets.objects.creatures.util.cloth_sim import bake_cloth
from infinigen.assets.utils.decorate import read_co, subsurf
from infinigen.core.placement.factory import make_asset_collection
Expand Down Expand Up @@ -49,8 +50,6 @@ class ClothesCover:
def __init__(
self, bbox=(0.3, 0.7, 0.3, 0.7), factory_fn=None, width=None, size=None
):
from infinigen.assets.clothes import blanket, pants, shirt

probs = np.array([2, 1, 1])
if factory_fn is None:
factory_fn = np.random.choice(
Expand Down
5 changes: 5 additions & 0 deletions infinigen/assets/scatters/ground_mushroom.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,8 @@ def apply(self, obj, scale=0.3, density=1.0, selection=None):
)

return scatter_obj


def apply(obj):
mushrooms = Mushrooms()
return mushrooms.apply(obj)
1 change: 0 additions & 1 deletion infinigen/assets/scatters/mollusk.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ def scaling(nw):
)

scatter_obj = scatter_instances(
"mollusk",
base_obj=obj,
collection=mollusk,
density=density,
Expand Down
5 changes: 5 additions & 0 deletions infinigen/assets/scatters/moss.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,8 @@ def instance_index(nw: NodeWrangler, n):
)

return scatter_obj


def apply(obj):
moss_cover = MossCover()
return moss_cover.apply(obj)
4 changes: 4 additions & 0 deletions infinigen/assets/scatters/slime_mold.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,7 @@ def weight(nw):
assign_material(scatter_obj, shaderfunc_to_material(shader_mold, base_hue))

return scatter_obj


def apply(obj, selection=None):
SlimeMold().apply(obj, selection)
7 changes: 7 additions & 0 deletions infinigen/assets/scatters/snow_layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

class Snowlayer:
def __init__(self):
bpy.ops.preferences.addon_enable(module="real_snow")
pass

def apply(self, obj, **kwargs):
Expand All @@ -21,3 +22,9 @@ def apply(self, obj, **kwargs):
snow = bpy.context.active_object
tag_object(snow, "snow")
tag_object(snow, "boulder")


def apply(obj):
snowlayer = Snowlayer()
snowlayer.apply(obj)
return snowlayer
1 change: 1 addition & 0 deletions infinigen/assets/weather/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
marine_snow_param_distribution,
rain_param_distribution,
snow_param_distribution,
spawn_emitter,
)
from .wind_effectors import TurbulenceEffector, WindEffector
21 changes: 21 additions & 0 deletions infinigen/assets/weather/particles.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,27 @@
logger = logging.getLogger(__name__)


def spawn_emitter(follow_cam, mesh_type, size, offset, name=None):
match mesh_type:
case "plane":
emitter = butil.spawn_plane(location=offset, size=size)
case "cube":
emitter = butil.spawn_cube(location=offset, size=size)
case _:
raise ValueError(f"Unknown mesh type {mesh_type}")

butil.constrain_object(emitter, "COPY_LOCATION", use_offset=True, target=follow_cam)

if name is None:
name = follow_cam.name
emitter.name = f"emitter({name=}, {mesh_type=})"

emitter.hide_viewport = True
emitter.hide_render = True

return emitter


def rain_param_distribution():
drops_per_sec_m2 = uniform(0.05, 1)
velocity = uniform(9, 20)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ def angle_alignment_cost_base(
b_edges = []
for b_name, b_mesh in zip(b, b_meshes):
b_poly = iu.project_to_xy_poly(b_mesh)
if b_poly is not None:
if (b_poly is not None) and (not b_poly.is_empty):
if isinstance(b_poly, Polygon):
for i, coord in enumerate(b_poly.exterior.coords[:-1]):
start, end = coord, b_poly.exterior.coords[i + 1]
Expand Down
3 changes: 1 addition & 2 deletions infinigen/core/placement/animation_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
from numpy.random import uniform as U
from tqdm import tqdm

import infinigen.assets.utils.mesh
from infinigen.assets.utils.geometry.curve import Curve
from infinigen.core.placement.path_finding import path_finding
from infinigen.core.util import blender as butil
Expand Down Expand Up @@ -603,7 +602,7 @@ def animate_trajectory(
obj.rotation_euler.z = U(0, 2 * np.pi)

if hasattr(policy_func, "reset"):
infinigen.assets.utils.mesh.reset_preset()
policy_func.reset()

keyframe(obj, obj.location, obj.rotation_euler, 0, interp="LINEAR")
try_animate_trajectory_func = (
Expand Down
5 changes: 4 additions & 1 deletion infinigen/core/placement/instance_scatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,10 @@ def scatter_instances(

name = "scatter:" + collection.name.split(":")[-1]

avg_scale = scale * (1 - scale_rand / 2) * (1 - scale_rand_axi / 2)
if scale is not None:
avg_scale = scale * (1 - scale_rand / 2) * (1 - scale_rand_axi / 2)
else:
avg_scale = 1

if vol_density is not None:
assert (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
include 'infinigen/datagen/gt_options/opengl_gt.gin' # incase someone adds other settings to it
include 'infinigen/datagen/configs/gt_options/opengl_gt.gin' # incase someone adds other settings to it

iterate_scene_tasks.camera_dependent_tasks = [
{'name': 'renderbackup', 'func': @renderbackup/queue_render}, # still call it "backup" since it is reusing the compute_platform's backup config. we are just skipping straight to the backup
{'name': 'savemesh', 'func': @queue_mesh_save},
{'name': 'opengl', 'func': @queue_opengl}
]
]
18 changes: 17 additions & 1 deletion infinigen/datagen/job_funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,13 +425,29 @@ def queue_mesh_save(

output_folder.mkdir(parents=True, exist_ok=True)

input_folder_priority_options = [
f"fine{input_suffix}",
"fine",
f"coarse{input_suffix}",
"coarse",
]

for option in input_folder_priority_options:
input_folder = f"{folder}/{option}"
if (Path(input_folder) / "scene.blend").exists():
break
else:
raise ValueError(
f"No scene.blend found in {input_folder} for any of {input_folder_priority_options}"
)

cmd = (
get_cmd(
seed,
"mesh_save",
configs,
taskname,
input_folder=f"{folder}/coarse{input_suffix}",
input_folder=input_folder,
output_folder=f"{folder}/savemesh{output_suffix}",
)
+ f"""
Expand Down
4 changes: 2 additions & 2 deletions infinigen/tools/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -764,12 +764,12 @@ def export_scene(
bpy.ops.wm.open_mainfile(filepath=str(input_blend))
folder = output_folder / f"export_{input_blend.name}"
folder.mkdir(exist_ok=True, parents=True)
result = export_curr_scene(folder, **kwargs)
export_curr_scene(folder, **kwargs)

if pipeline_folder is not None and task_uniqname is not None:
(pipeline_folder / "logs" / f"FINISH_{task_uniqname}").touch()

return result
return folder


# side effects: will remove parents of inputted obj and clean its name, hides viewport of all objects
Expand Down
Loading

0 comments on commit c537e24

Please sign in to comment.