Skip to content

Commit

Permalink
Code separation
Browse files Browse the repository at this point in the history
  • Loading branch information
Zeyu Ma authored and pvl-bot committed Jul 1, 2023
1 parent 1ebed67 commit 3040c22
Show file tree
Hide file tree
Showing 45 changed files with 78 additions and 5,232 deletions.
17 changes: 10 additions & 7 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
[submodule "worldgen/terrain/gen_occlusions/dependencies/eigen"]
[submodule "worldgen/infinigen_gpl"]
path = worldgen/infinigen_gpl
url = https://github.com/princeton-vl/infinigen_gpl.git
[submodule "process_mesh/dependencies/eigen"]
path = process_mesh/dependencies/eigen
url = https://gitlab.com/libeigen/eigen.git
[submodule "worldgen/terrain/gen_occlusions/dependencies/argparse"]
[submodule "process_mesh/dependencies/argparse"]
path = process_mesh/dependencies/argparse
url = https://github.com/p-ranav/argparse.git
[submodule "worldgen/terrain/gen_occlusions/dependencies/cnpy"]
[submodule "process_mesh/dependencies/cnpy"]
path = process_mesh/dependencies/cnpy
url = https://github.com/rogersce/cnpy.git
[submodule "worldgen/terrain/gen_occlusions/dependencies/indicators"]
[submodule "process_mesh/dependencies/indicators"]
path = process_mesh/dependencies/indicators
url = https://github.com/p-ranav/indicators.git
[submodule "worldgen/terrain/gen_occlusions/dependencies/tinycolormap"]
[submodule "process_mesh/dependencies/tinycolormap"]
path = process_mesh/dependencies/tinycolormap
url = https://github.com/yuki-koyama/tinycolormap.git
[submodule "worldgen/terrain/gen_occlusions/dependencies/glm"]
[submodule "process_mesh/dependencies/glm"]
path = process_mesh/dependencies/glm
url = https://github.com/g-truc/glm.git
[submodule "worldgen/terrain/gen_occlusions/dependencies/fast_obj"]
[submodule "process_mesh/dependencies/fast_obj"]
path = process_mesh/dependencies/fast_obj
url = https://github.com/thisistherk/fast_obj.git
[submodule "process_mesh/dependencies/json"]
Expand Down
2 changes: 1 addition & 1 deletion install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,4 @@ cd -

if [ "$1" = "opengl" ]; then
bash ./worldgen/tools/compile_opengl.sh
fi
fi
1 change: 1 addition & 0 deletions process_mesh/dependencies/argparse
Submodule argparse added at 40a388
1 change: 1 addition & 0 deletions process_mesh/dependencies/cnpy
Submodule cnpy added at 4e8810
1 change: 1 addition & 0 deletions process_mesh/dependencies/eigen
Submodule eigen added at 84cf3f
1 change: 1 addition & 0 deletions process_mesh/dependencies/fast_obj
Submodule fast_obj added at 85778d
1 change: 1 addition & 0 deletions process_mesh/dependencies/glfw
Submodule glfw added at 3fa236
1 change: 1 addition & 0 deletions process_mesh/dependencies/glm
Submodule glm added at cc9846
1 change: 1 addition & 0 deletions process_mesh/dependencies/indicators
Submodule indicators added at a5bc05
1 change: 1 addition & 0 deletions process_mesh/dependencies/json
Submodule json added at 80dfb0
1 change: 1 addition & 0 deletions process_mesh/dependencies/stb
Submodule stb added at 5736b1
1 change: 1 addition & 0 deletions process_mesh/dependencies/tinycolormap
Submodule tinycolormap added at 67198d
2 changes: 1 addition & 1 deletion worldgen/assets/corals/diff_growth.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from assets.corals.base import BaseCoralFactory
from assets.corals.tentacles import make_upward_points_fn, make_radius_points_fn
from assets.utils.diff_growth import build_diff_growth
from infinigen_gpl.extras.diff_growth import build_diff_growth
from assets.utils.object import mesh2obj, data2mesh
from assets.utils.decorate import geo_extension, read_co
from assets.utils.mesh import polygon_angles
Expand Down
3 changes: 2 additions & 1 deletion worldgen/assets/particles.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
from util.random import random_general
from assets.utils.tag import tag_object, tag_nodegroup

from surfaces.templates import dirt, snow
from surfaces.templates import dirt
from infinigen_gpl.surfaces import snow

def shader_raindrop(nw):
glass_bsdf = nw.new_node(
Expand Down
2 changes: 1 addition & 1 deletion worldgen/assets/seaweed.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from assets.utils.draw import make_circular_interp
import util.blender as butil
from placement.factory import AssetFactory
from assets.utils.diff_growth import build_diff_growth
from infinigen_gpl.extras.diff_growth import build_diff_growth
from assets.utils.object import mesh2obj, data2mesh
from assets.utils.mesh import polygon_angles
from nodes.node_wrangler import NodeWrangler, Nodes
Expand Down
87 changes: 0 additions & 87 deletions worldgen/assets/utils/diff_growth.py

This file was deleted.

3 changes: 2 additions & 1 deletion worldgen/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@
slime_mold, moss, ivy, lichen, mushroom, decorative_plants, seashells
from surfaces.scatters.utils.selection import scatter_lower, scatter_upward
from surfaces.templates import mountain, sand, water, atmosphere_light_haze, sandstone, cracked_ground, \
soil, dirt, cobble_stone, chunkyrock, stone, lava, ice, mud, snow
soil, dirt, cobble_stone, chunkyrock, stone, lava, ice, mud
from infinigen_gpl.surfaces import snow

from placement import particles, placement, density, camera as cam_util, animation_policy, instance_scatter, detail
from assets import particles as particle_assets
Expand Down
1 change: 1 addition & 0 deletions worldgen/infinigen_gpl
Submodule infinigen_gpl added at 4e3b97
30 changes: 1 addition & 29 deletions worldgen/rendering/render.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import cv2
import numpy as np
import logging

from infinigen_gpl.extras.enable_gpu import enable_gpu
from imageio import imwrite, imread
from pathlib import Path
from placement import camera as cam_util
Expand Down Expand Up @@ -91,34 +91,6 @@ def make_clay():
for mat_slot in obj.material_slots:
mat_slot.material = clay_material

def enable_gpu(engine_name = 'CYCLES'):
# from: https://github.com/DLR-RM/BlenderProc/blob/main/blenderproc/python/utility/Initializer.py
compute_device_type = None
prefs = bpy.context.preferences.addons['cycles'].preferences
# Use cycles
bpy.context.scene.render.engine = engine_name
bpy.context.scene.cycles.device = 'GPU'

preferences = bpy.context.preferences.addons['cycles'].preferences
for device_type in preferences.get_device_types(bpy.context):
preferences.get_devices_for_type(device_type[0])

for gpu_type in ['OPTIX', 'CUDA']:#, 'METAL']:
found = False
for device in preferences.devices:
if device.type == gpu_type and (compute_device_type is None or compute_device_type == gpu_type):
bpy.context.preferences.addons['cycles'].preferences.compute_device_type = gpu_type
logger.info('Device {} of type {} found and used.'.format(device.name, device.type))
found = True
break
if found:
break

# make sure that all visible GPUs are used
for device in prefs.devices:
device.use = True
return prefs.devices

@gin.configurable
def compositor_postprocessing(nw, source, show=True, autoexpose=False, autoexpose_level=-2, color_correct=True, distort=0, glare=False):

Expand Down
2 changes: 1 addition & 1 deletion worldgen/surfaces/scatters/lichen.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from placement.instance_scatter import scatter_instances
from surfaces import surface
from placement.factory import AssetFactory
from assets.utils.diff_growth import build_diff_growth
from infinigen_gpl.extras.diff_growth import build_diff_growth
from assets.utils.object import data2mesh
from assets.utils.mesh import polygon_angles
from util import blender as butil
Expand Down
2 changes: 1 addition & 1 deletion worldgen/surfaces/scatters/snow_layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from util import blender as butil
from nodes import node_utils

from surfaces.templates import snow
from infinigen_gpl.surfaces import snow
from assets.utils.tag import tag_object, tag_nodegroup

class Snowlayer:
Expand Down
2 changes: 1 addition & 1 deletion worldgen/surfaces/surface.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ def get_surface(name):
if name == '':
return NoApply

prefixes = ['surfaces.templates', 'surfaces.scatters']
prefixes = ['infinigen_gpl.surfaces', 'surfaces.templates', 'surfaces.scatters']
for prefix in prefixes:
try:
return importlib.import_module(prefix + '.' + name)
Expand Down
3 changes: 2 additions & 1 deletion worldgen/surfaces/templates/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
from . import *
from . import *
from infinigen_gpl.surfaces import *
2 changes: 1 addition & 1 deletion worldgen/surfaces/templates/water.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,4 +247,4 @@ def apply(objs, is_ocean=False, coastal=0, selection=None, **kwargs):
surface.add_material(objs, shader, selection=selection, input_kwargs=input_kwargs)
if is_ocean:
(ocean_folder / "cache/disp_0001.exr").unlink()
(ocean_folder / "cache/foam_0001.exr").unlink()
(ocean_folder / "cache/foam_0001.exr").unlink()
6 changes: 3 additions & 3 deletions worldgen/terrain/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
from terrain.mesher import OpaqueSphericalMesher, TransparentSphericalMesher, UniformMesher
from terrain.scene import scene, transfer_scene_info
from terrain.surface_kernel.core import SurfaceKernel
from terrain.utils import Mesh, SurfaceTypes, move_modifier, Vars, AttributeType, FieldsType
from terrain.utils import Mesh, move_modifier, Vars, AttributeType, FieldsType
from terrain.assets.ocean import ocean_asset
from util.blender import SelectObjects, delete
from util.logging import Timer
from util.math import FixedSeed, int_hash
from util.organization import Attributes, Task, TerrainNames, ElementNames, Transparency, Materials, Assets, ElementTag, Tags, SelectionCriterions
from util.organization import SurfaceTypes, Attributes, Task, TerrainNames, ElementNames, Transparency, Materials, Assets, ElementTag, Tags, SelectionCriterions
from assets.utils.tag import tag_object, tag_system
from numpy import ascontiguousarray as AC

Expand Down Expand Up @@ -468,4 +468,4 @@ def tag_terrain(self, obj):
obj.data.attributes[f"TAG_{Tags.OutOfView}"].data.foreach_set("value", AC(tag.astype(np.float32)))
tag_object(obj)

self.tag_dict = tag_system.tag_dict
self.tag_dict = tag_system.tag_dict
59 changes: 0 additions & 59 deletions worldgen/terrain/source/common/nodes/node_float_curve.h

This file was deleted.

Loading

0 comments on commit 3040c22

Please sign in to comment.