Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
hdoi5324 committed Dec 5, 2024
2 parents bd230cf + 8d9588e commit abdf36e
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 11 deletions.
34 changes: 29 additions & 5 deletions infinigen/assets/materials/water.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
# Acknowledgment: This file draws inspiration from https://www.youtube.com/watch?v=X3LlsdddMLo by Kev Binge


import logging

import bpy
import gin
import numpy as np
Expand All @@ -23,6 +25,7 @@
mod_name = "geo_water"
name = "water"
info = {}
logger = logging.getLogger(__name__)


@gin.configurable("geo")
Expand Down Expand Up @@ -237,11 +240,13 @@ def shader(
asset_paths,
coastal,
color=("color_category", "water"),
scatter_color=("color_category", "seawater_scatter"),
enable_scatter=True,
colored=False,
emissive_foam=False,
volume_density=("uniform", 0.07, 0.09),
anisotropy=("clip_gaussian", 0.75, 0.2, 0.5, 1),
scatter_density=("uniform", 0.0005, 0.002),
mix_surface=False,
random_seed=0,
):
Expand All @@ -250,6 +255,7 @@ def shader(
# Code generated using version 2.3.1 of the node_transpiler (partly)
with FixedSeed(random_seed):
color = rg(color)
scatter_color = rg(scatter_color)
light_path = nw.new_node(Nodes.LightPath)

if colored:
Expand Down Expand Up @@ -332,15 +338,33 @@ def shader(

rgb = nw.new_node(Nodes.RGB)
rgb.outputs[0].default_value = color
principled_volume = nw.new_node(
Nodes.PrincipledVolume,

volume_density = rg(volume_density)
volume_absorption = nw.new_node(
Nodes.VolumeAbsorption,
input_kwargs={
"Color": rgb,
"Absorption Color": rgb,
"Density": rg(volume_density) if enable_scatter else 0,
"Anisotropy": rg(anisotropy),
"Density": volume_density,
},
)
logger.debug(f"Water Volume Absorption: color {color}, density: {volume_density}")

scatter_rgb = nw.new_node(Nodes.RGB)
scatter_density = rg(scatter_density) if enable_scatter else 0
scatter_anisotropy = rg(anisotropy)
scatter_rgb.outputs[0].default_value = scatter_color
volume_scatter = nw.new_node(
Nodes.VolumeScatter,
input_kwargs={
"Color": scatter_rgb,
"Density": scatter_density,
"Anisotropy": scatter_anisotropy,
},
)
logger.debug(f"Water Volume Scattering: color {scatter_color}, density: {scatter_density}, anistropy: {scatter_anisotropy}")
#volume_scatter.phase = "FOURNIER_FORAND" # for Blender 4.3

principled_volume = nw.new_node(Nodes.AddShader, [volume_absorption, volume_scatter])

material_output = nw.new_node(
Nodes.MaterialOutput,
Expand Down
3 changes: 3 additions & 0 deletions infinigen/core/nodes/node_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,11 +224,14 @@ class Nodes:

# Shaders
MixShader = "ShaderNodeMixShader"
AddShader = "ShaderNodeAddShader"
DiffuseBSDF = "ShaderNodeBsdfDiffuse"
PrincipledBSDF = "ShaderNodeBsdfPrincipled"
TranslucentBSDF = "ShaderNodeBsdfTranslucent"
TransparentBSDF = "ShaderNodeBsdfTransparent"
PrincipledVolume = "ShaderNodeVolumePrincipled"
VolumeAbsorption = "ShaderNodeVolumeAbsorption"
VolumeScatter = "ShaderNodeVolumeScatter"
PrincipledHairBSDF = "ShaderNodeBsdfHairPrincipled"
Emission = "ShaderNodeEmission"
Fresnel = "ShaderNodeFresnel"
Expand Down
11 changes: 10 additions & 1 deletion infinigen/core/util/color.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,16 @@ def N(m, std, **kwargs):
"water": (U(0.2, 0.6), N(0.5, 0.1), U(0.7, 1)),
"darker_water": (U(0.2, 0.6), N(0.5, 0.1), U(0.2, 0.3)),
"under_water": (U(0.5, 0.7), U(0.7, 0.95), U(0.7, 1)),
"eye_schlera": (U(0.05, 0.15), U(0.2, 0.8), U(0.05, 0.5)),
"seawater_scatter": (
N(0.474, 0.05),
N(0.8, 0.1),
N(0.9, 0.1)
),
"seawater": (
N(0.453, 0.03),
N(0.95, 0.05),
N(0.5, 0.1)
), "eye_schlera": (U(0.05, 0.15), U(0.2, 0.8), U(0.05, 0.5)),
"eye_pupil": (U(0, 1), U(0.1, 0.9), U(0.1, 0.9)),
"beak": (U(0, 0.13), U(0, 0.9), U(0.1, 0.6)),
"fur": (U(0, 0.11), U(0.5, 0.95), U(0.02, 0.9)),
Expand Down
12 changes: 7 additions & 5 deletions infinigen_examples/configs_nature/scene_types/coral_reef.gin
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
include 'infinigen_examples/configs_nature/scene_types/under_water.gin'

compose_nature.kelp_chance = 0.1
compose_nature.urchin_chance = 0.1
compose_nature.kelp_chance = 0.0
compose_nature.urchin_chance = 0.0

compose_nature.corals_chance = 1.
compose_nature.seaweed_chance = 0.2
compose_nature.seashell_chance = 0.7
compose_nature.seaweed_chance = 0.0
compose_nature.seashell_chance = 0.0
compose_nature.jellyfish_chance = 0.0

water.geo.with_waves=True
water.geo.with_waves=True

water.shader.color = ("color_category", "under_water")

0 comments on commit abdf36e

Please sign in to comment.