Skip to content

Commit

Permalink
Update docker files.
Browse files Browse the repository at this point in the history
Add makefile to build, remove git submodules check and new tests
  • Loading branch information
lalalune authored and fire committed Jun 21, 2024
1 parent fb7991e commit 1e12272
Show file tree
Hide file tree
Showing 25 changed files with 201 additions and 294 deletions.
5 changes: 4 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
# but some are still explicitly included in the .whl via

include .gitmodules
include Makefile

recursive-include scripts *.*

recursive-include infinigen *.*
recursive-include tests *.*
Expand All @@ -14,4 +17,4 @@ prune */__pycache__
prune infinigen/datagen/customgt/build/*
prune infinigen/datagen/customgt/dependencies/*

global-exclude *.o *.so *.pyc .git *.png
global-exclude *.o *.so *.pyc *.png
52 changes: 18 additions & 34 deletions infinigen/assets/materials/aluminumdisp2tut.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,35 @@
# Authors: Mingzhe Wang
# Acknowledgment: This file draws inspiration from https://www.youtube.com/watch?v=FY0lR96Mwas by Sam Bowman

import os, sys
import numpy as np
import math as ma

import os
import bpy
import mathutils
from numpy.random import uniform, normal, randint

from infinigen.assets.materials.utils.surface_utils import clip, sample_range, sample_ratio, sample_color, geo_voronoi_noise
from infinigen.assets.materials.utils.surface_utils import sample_range, sample_ratio, sample_color
from infinigen.core.nodes.node_wrangler import Nodes, NodeWrangler
from infinigen.core.nodes import node_utils
from infinigen.core.util.color import color_category

from infinigen.core import surface

def shader_aluminumdisp2tut(nw: NodeWrangler, rand=False, **input_kwargs):
# Code generated using version 2.4.3 of the node_transpiler

texture_coordinate = nw.new_node(Nodes.TextureCoord)

separate_xyz = nw.new_node(Nodes.SeparateXYZ,
input_kwargs={'Vector': texture_coordinate.outputs["Generated"]})

multiply = nw.new_node(Nodes.Math,
input_kwargs={0: separate_xyz.outputs["X"], 1: 0.1},
input_kwargs={'Value': separate_xyz.outputs["X"], 'Value_001': 0.1},
attrs={'operation': 'MULTIPLY'})
if rand:
multiply.inputs[1].default_value = sample_range(-1, 1)
multiply.inputs['Value_001'].default_value = sample_range(-1, 1)

multiply_1 = nw.new_node(Nodes.Math,
input_kwargs={0: separate_xyz.outputs["Y"]},
input_kwargs={'Value': separate_xyz.outputs["Y"], 'Value_001': 0.1},
attrs={'operation': 'MULTIPLY'})
if rand:
multiply_1.inputs[1].default_value = sample_range(-1, 1)
multiply_1.inputs['Value_001'].default_value = sample_range(-1, 1)

add = nw.new_node(Nodes.Math,
input_kwargs={0: multiply, 1: multiply_1})
input_kwargs={'Value': multiply.outputs["Value"], 'Value_001': multiply_1.outputs["Value"]},
attrs={'operation': 'ADD'})

combine_xyz = nw.new_node(Nodes.CombineXYZ,
input_kwargs={'Z': add})
Expand All @@ -48,15 +43,12 @@ def shader_aluminumdisp2tut(nw: NodeWrangler, rand=False, **input_kwargs):
mapping = nw.new_node(Nodes.VectorMath,
input_kwargs={0: mapping_1.outputs["Vector"], 1: (1, 75, 1)},
attrs={'operation': 'MULTIPLY'})

#mapping = nw.new_node(Nodes.Mapping,
# input_kwargs={'Vector': mapping_1, 'Scale': (1.0, sample_range(50, 100) if rand else 75.0, 1.0)})

musgrave_texture = nw.new_node(Nodes.MusgraveTexture,
input_kwargs={'Vector': mapping, 'W': 0.7, 'Scale': 2.0, 'Detail': 10.0, 'Dimension': 1.0},
input_kwargs={'Vector': mapping.outputs["Vector"], 'Roughness': 0.7, 'Scale': 2.0, 'Detail': 10.0},
attrs={'musgrave_dimensions': '4D'})
if rand:
musgrave_texture.inputs['W'].default_value = sample_range(0, 5)
musgrave_texture.inputs['Roughness'].default_value = sample_range(0, 5)
musgrave_texture.inputs['Scale'].default_value = sample_ratio(2, 0.5, 2)

colorramp_4 = nw.new_node(Nodes.ColorRamp,
Expand All @@ -80,7 +72,6 @@ def shader_aluminumdisp2tut(nw: NodeWrangler, rand=False, **input_kwargs):
for e in colorramp_1.color_ramp.elements:
sample_color(e.color, offset=0.02)


colorramp = nw.new_node(Nodes.ColorRamp,
input_kwargs={'Fac': colorramp_4.outputs["Color"]})
colorramp.color_ramp.elements[0].position = 0.74
Expand All @@ -96,24 +87,17 @@ def shader_aluminumdisp2tut(nw: NodeWrangler, rand=False, **input_kwargs):
colorramp_3.color_ramp.elements[1].color = (1.0, 1.0, 1.0, 1.0)

principled_bsdf = nw.new_node(Nodes.PrincipledBSDF,
input_kwargs={'Base Color': colorramp_1.outputs["Color"], 'Metallic': colorramp.outputs["Color"], 'Roughness': colorramp_3.outputs["Color"]},
input_kwargs={'Base Color': colorramp_1.outputs["Color"], 'Metallic': colorramp.outputs["Color"], 'Specular IOR Level': colorramp_3.outputs["Color"]},
attrs={'subsurface_method': 'BURLEY'})

material_output = nw.new_node(Nodes.MaterialOutput,
input_kwargs={'Surface': principled_bsdf})

def geo_aluminumdisp2tut(nw: NodeWrangler, rand=False, **input_kwargs):
# Code generated using version 2.4.3 of the node_transpiler
# NodeWrangler has a new `interface` attribute that allows you to access the node wrangler interface

group_input = nw.new_node(Nodes.GroupInput,
expose_input=[('NodeSocketGeometry', 'Geometry', None)])

#subdivide_level = nw.new_node(Nodes.Value,
# label='SubdivideLevel')
#subdivide_level.outputs[0].default_value = 0

#subdivide_mesh = nw.new_node(Nodes.SubdivideMesh,
# input_kwargs={'Mesh': group_input.outputs["Geometry"], 'Level': subdivide_level})
group_input = nw.expose_input('Geometry', dtype='NodeSocketGeometry')

position = nw.new_node(Nodes.InputPosition)

Expand All @@ -125,7 +109,7 @@ def geo_aluminumdisp2tut(nw: NodeWrangler, rand=False, **input_kwargs):
input_kwargs={0: position, 1: scale},
attrs={'operation': 'MULTIPLY'})

noise_texture = nw.new_node(Nodes.NoiseTexture,
noise_texture = nw.new_node(Nodes.MusgraveTexture,
input_kwargs={'Vector': multiply.outputs["Vector"], 'Scale': 4.0},
attrs={'noise_dimensions': '4D'})
if rand:
Expand Down Expand Up @@ -178,7 +162,7 @@ def geo_aluminumdisp2tut(nw: NodeWrangler, rand=False, **input_kwargs):
attrs={'operation': 'MULTIPLY'})

set_position = nw.new_node(Nodes.SetPosition,
input_kwargs={'Geometry': group_input.outputs["Geometry"], 'Offset': multiply_2.outputs["Vector"]})
input_kwargs={'Geometry': group_input, 'Offset': multiply_2.outputs["Vector"]})

capture_attribute = nw.new_node(Nodes.CaptureAttribute,
input_kwargs={'Geometry': set_position, 1: mix},
Expand Down
80 changes: 27 additions & 53 deletions infinigen/assets/materials/bark.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import random


def shader_bark(nw, rand=False, **input_kwargs):
def shader_bark(nw: NodeWrangler, rand=False, **input_kwargs):

texture_coordinate = nw.new_node(Nodes.TextureCoord)

Expand Down Expand Up @@ -68,68 +68,42 @@ def shader_bark(nw, rand=False, **input_kwargs):
colorramp_2.color_ramp.elements[1].color = (1.0, 1.0, 1.0, 1.0)

principled_bsdf = nw.new_node(Nodes.PrincipledBSDF,
input_kwargs={'Base Color': mix_1, 'Roughness': colorramp_2.outputs["Color"]},
attrs={'subsurface_method': 'BURLEY'})

material_output = nw.new_node(Nodes.MaterialOutput,
input_kwargs={'Surface': principled_bsdf})
input_kwargs={'Base Color': mix_1, 'Roughness': colorramp_2.outputs["Color"]})

output_node = nw.new_node(Nodes.MaterialOutput)
nw.links.new(principled_bsdf.outputs["BSDF"], output_node.inputs["Surface"])
return principled_bsdf

def geo_bark(nw: NodeWrangler):
# Code generated using version 2.6.4 of the node_transpiler
group_input = nw.new_node(Nodes.GroupInput)
# Make sure the 'Geometry' output is correctly initialized and exposed
if 'Geometry' not in group_input.outputs:
print("Error: 'Geometry' output not found in GroupInput node.")
return # Exit if no Geometry output is found

group_input = nw.new_node(Nodes.GroupInput, expose_input=[('NodeSocketGeometry', 'Geometry', None)])

position = nw.new_node(Nodes.InputPosition)

value = nw.new_node(Nodes.Value)
value.outputs[0].default_value = 5.0000
multiply = nw.new_node(Nodes.VectorMath, input_kwargs={0: position, 1: value}, attrs={'operation': 'MULTIPLY'})
separate_xyz = nw.new_node(Nodes.SeparateXYZ, input_kwargs={'Vector': multiply.outputs["Vector"]})
noise_texture = nw.new_node(Nodes.NoiseTexture,

multiply = nw.new_node(Nodes.VectorMath, input_kwargs={'Vector1': position.outputs['Vector'], 'Vector2': value.outputs['Value']}, attrs={'operation': 'MULTIPLY'})

separate_xyz = nw.new_node(Nodes.SeparateXYZ, input_kwargs={'Vector': multiply.outputs['Vector']})

noise_texture = nw.new_node(Nodes.NoiseTexture,
input_kwargs={'Scale': N(10, 2), 'W': U(-10, 10)},
attrs={'noise_dimensions': '4D'},
)

subtract = nw.new_node(Nodes.Math, input_kwargs={0: noise_texture.outputs["Fac"]}, attrs={'operation': 'SUBTRACT'})

multiply_1 = nw.new_node(Nodes.Math, input_kwargs={0: subtract, 1: 3.0000}, attrs={'operation': 'MULTIPLY'})

add = nw.new_node(Nodes.Math, input_kwargs={0: separate_xyz.outputs["Y"], 1: multiply_1})

multiply_2 = nw.new_node(Nodes.Math, input_kwargs={0: add, 1: 1.0000}, attrs={'operation': 'MULTIPLY'})

fract = nw.new_node(Nodes.Math, input_kwargs={0: multiply_2}, attrs={'operation': 'FRACT'})

subtract_1 = nw.new_node(Nodes.Math, input_kwargs={0: fract}, attrs={'operation': 'SUBTRACT'})

multiply_3 = nw.new_node(Nodes.Math, input_kwargs={0: subtract_1, 1: subtract_1}, attrs={'operation': 'MULTIPLY'})

multiply_4 = nw.new_node(Nodes.Math, input_kwargs={0: multiply_3, 1: 4.0000}, attrs={'operation': 'MULTIPLY'})

normal = nw.new_node(Nodes.InputNormal)

multiply_5 = nw.new_node(Nodes.VectorMath, input_kwargs={0: multiply_4, 1: normal}, attrs={'operation': 'MULTIPLY'})

value_1 = nw.new_node(Nodes.Value)
value_1.outputs[0].default_value = 0.0100

multiply_6 = nw.new_node(Nodes.VectorMath,
input_kwargs={0: multiply_5.outputs["Vector"], 1: value_1},
attrs={'operation': 'MULTIPLY'})


subtract = nw.new_node(Nodes.Math, input_kwargs={'Value1': noise_texture.outputs['Fac']}, attrs={'operation': 'SUBTRACT'})

multiply_1 = nw.new_node(Nodes.Math, input_kwargs={'Value1': subtract.outputs['Value'], 'Value2': 3.0000}, attrs={'operation': 'MULTIPLY'})

add = nw.new_node(Nodes.Math, input_kwargs={'Value1': separate_xyz.outputs['Y'], 'Value2': multiply_1.outputs['Value']})

set_position = nw.new_node(Nodes.SetPosition,
input_kwargs={'Geometry': group_input.outputs["Geometry"], 'Offset': multiply_6.outputs["Vector"]})

capture_attribute = nw.new_node(Nodes.CaptureAttribute,
input_kwargs={'Geometry': set_position, 1: multiply_4},
attrs={'data_type': 'FLOAT_VECTOR'})

group_output = nw.new_node(Nodes.GroupOutput,
input_kwargs={'Geometry': capture_attribute.outputs["Geometry"], 'Attribute': capture_attribute.outputs["Attribute"]},
attrs={'is_active_output': True})
input_kwargs={'Geometry': group_input.outputs['Geometry'], 'Offset': add.outputs['Value']})


def apply(obj, geo_kwargs=None, shader_kwargs=None, **kwargs):
surface.add_geomod(obj, geo_bark, apply=False, input_kwargs=geo_kwargs, attributes=['offset'])
Expand Down
2 changes: 1 addition & 1 deletion infinigen/assets/materials/basic_bsdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def shader_basic_bsdf(nw):
'Base Color': color,
'Roughness': np.clip(normal(0.6, 0.3), 0.05, 0.95),
'Metallic': uniform(0, 1) if uniform() < 0.3 else 0,
'Subsurface': 0 if uniform() < 0.8 else uniform(0, 0.2)
'Subsurface Weight': 0 if uniform() < 0.8 else uniform(0, 0.2)
},
attrs={'subsurface_method': 'BURLEY'})

Expand Down
6 changes: 3 additions & 3 deletions infinigen/assets/materials/bird.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ def shader_bird_body(nw: NodeWrangler, rand=True, kind='duck', **input_kwargs):
group.inputs['W'].default_value = sample_range(-2, 2)

principled_bsdf = nw.new_node(Nodes.PrincipledBSDF,
input_kwargs={'Base Color': group, 'Subsurface IOR': 0.0, 'Specular': 0.0, 'Roughness': 1.0})
input_kwargs={'Base Color': group, 'Subsurface Weight': 0.0, 'Roughness': 1.0})

material_output = nw.new_node(Nodes.MaterialOutput,
input_kwargs={'Surface': principled_bsdf})
Expand Down Expand Up @@ -356,7 +356,7 @@ def shader_bird_feather(nw: NodeWrangler, rand=True, kind='duck', tail=False, **
input_kwargs={'Fac': 0.5 if tail else 1.0, 'Color1': colorramp2.outputs["Color"], 'Color2': colorramp.outputs["Color"]})

principled_bsdf = nw.new_node(Nodes.PrincipledBSDF,
input_kwargs={'Base Color': (mix, "Result"), 'Specular': 0.0, 'Roughness': 1.0},
input_kwargs={'Base Color': (mix, "Result"), 'Roughness': 1.0},
attrs={'subsurface_method': 'BURLEY'})

material_output = nw.new_node(Nodes.MaterialOutput,
Expand Down Expand Up @@ -445,7 +445,7 @@ def shader_bird_claw(nw: NodeWrangler, rand=True, **input_kwargs):
# Code generated using version 2.4.3 of the node_transpiler

principled_bsdf = nw.new_node(Nodes.PrincipledBSDF,
input_kwargs={'Base Color': (0.0091, 0.0091, 0.0091, 1.0), 'Specular': 0.0, 'Roughness': 0.4409})
input_kwargs={'Base Color': (0.0091, 0.0091, 0.0091, 1.0), 'Roughness': 0.4409})

material_output = nw.new_node(Nodes.MaterialOutput,
input_kwargs={'Surface': principled_bsdf})
Expand Down
27 changes: 13 additions & 14 deletions infinigen/assets/materials/chitin.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

def shader_chitin(nw: NodeWrangler, rand=True, **input_kwargs):
# Code generated using version 2.4.3 of the node_transpiler

# NodeWrangler has a new `interface` attribute that allows you to access the node wrangler interface
geometry = nw.new_node('ShaderNodeNewGeometry')

colorramp_1 = nw.new_node(Nodes.ColorRamp,
Expand Down Expand Up @@ -151,8 +151,6 @@ def shader_chitin(nw: NodeWrangler, rand=True, **input_kwargs):
colorramp_2.color_ramp.elements[1].color = (0.1347, 0.0156, 0.0115, 1.0)
if rand:
colorramp_2.color_ramp.elements[1].color = hsv2rgba((np.mod(normal(0.2, 0.4), 1), uniform(0, 1), uniform(0.05, 0.5)))
#for i in range(3):
# colorramp_2.color_ramp.elements[1].color[i] /= 7

invert = nw.new_node('ShaderNodeInvert',
input_kwargs={'Color': multiply_2})
Expand All @@ -168,15 +166,21 @@ def shader_chitin(nw: NodeWrangler, rand=True, **input_kwargs):
input_kwargs={'Base Color': colorramp_2.outputs["Color"], 'Metallic': 0.7, 'Roughness': colorramp_11.outputs["Color"]},
attrs={'subsurface_method': 'BURLEY'})

material_output = nw.new_node(Nodes.MaterialOutput,
input_kwargs={'Surface': principled_bsdf})
output_node = nw.new_node(Nodes.MaterialOutput)
nw.links.new(principled_bsdf.outputs["BSDF"], output_node.inputs["Surface"])
return principled_bsdf


def geometry_chitin(nw: NodeWrangler, rand=True, **input_kwargs):
# Code generated using version 2.4.3 of the node_transpiler
# NodeWrangler has a new `interface` attribute that allows you to access the node wrangler interface

group_input = nw.new_node(Nodes.GroupInput)
# Make sure the 'Geometry' output is correctly initialized and exposed
if 'Geometry' not in group_input.outputs:
print("Error: 'Geometry' output not found in GroupInput node.")
return # Exit if no Geometry output is found

group_input = nw.new_node(Nodes.GroupInput,
expose_input=[('NodeSocketGeometry', 'Geometry', None)])

normal = nw.new_node(Nodes.InputNormal)

noise_texture = nw.new_node(Nodes.NoiseTexture,
Expand Down Expand Up @@ -213,12 +217,7 @@ def apply(obj, geo_kwargs=None, shader_kwargs=None, **kwargs):
if __name__ == "__main__":
for i in range(1):
bpy.ops.wm.open_mainfile(filepath='dev_scene_1019.blend')
#creature(73349, 0).parts(0, factory=QuadrupedBody)
obj = "creature(36230, 0).parts(0, factory=BeetleBody)"
#obj = "creature(73349, 0).parts(0, factory=QuadrupedBody)"
apply(bpy.data.objects[obj], geo_kwargs={'rand': True}, shader_kwargs={'rand': True})
fn = os.path.join(os.path.abspath(os.curdir), 'dev_scene_test_beetle_attr.blend')
bpy.ops.wm.save_as_mainfile(filepath=fn)
#bpy.context.scene.render.filepath = os.path.join('surfaces/surface_thumbnails', 'bone%d.jpg'%(i))
#bpy.context.scene.render.image_settings.file_format='JPEG'
#bpy.ops.render.render(write_still=True)
bpy.ops.wm.save_as_mainfile(filepath=fn)
9 changes: 4 additions & 5 deletions infinigen/assets/materials/face_size_visualizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,18 @@ def shader_material(nw: NodeWrangler):
input_kwargs={'Surface': principled_bsdf})

def geo_face_colors(nw: NodeWrangler):
# Code generated using version 2.4.3 of the node_transpiler
# Code generated using version 2.6.5 of the node_transpiler

group_input = nw.new_node(Nodes.GroupInput,
expose_input=[('NodeSocketGeometry', 'Geometry', None)])
group_input = nw.expose_input('Geometry', dtype='NodeSocketGeometry')

random_value = nw.new_node(Nodes.RandomValue,
attrs={'data_type': 'FLOAT_VECTOR'})

store_named_attribute = nw.new_node(Nodes.StoreNamedAttribute,
input_kwargs={'Geometry': group_input.outputs["Geometry"], 'Name': 'col', "Value": random_value.outputs["Value"]},
input_kwargs={'Geometry': group_input, 'Name': 'col', "Value": random_value.outputs["Value"]},
attrs={'data_type': 'FLOAT_VECTOR', 'domain': 'FACE'})

group_output = nw.new_node(Nodes.GroupOutput,
nw.new_node(Nodes.GroupOutput,
input_kwargs={'Geometry': store_named_attribute})


Expand Down
2 changes: 1 addition & 1 deletion infinigen/assets/materials/grass_blade_texture.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def shader_grass_texture_original(nw: NodeWrangler):
input_kwargs={'Vector': separate_xyz.outputs["Y"], 'Scale': 25.0, 'Distortion': 8.0, 'Detail Scale': 6.0})

musgrave_texture = nw.new_node(Nodes.MusgraveTexture,
input_kwargs={'Vector': combine_xyz, 'Scale': 8.0, 'Detail': 5.0, 'Dimension': 0.1, 'Lacunarity': 3.0})
input_kwargs={'Vector': combine_xyz, 'Scale': 8.0, 'Detail': 5.0, 'Roughness': 0.1, 'Lacunarity': 3.0})

mix_1 = nw.new_node(Nodes.MixRGB,
input_kwargs={'Fac': 0.2, 'Color1': wave_texture.outputs["Color"], 'Color2': musgrave_texture})
Expand Down
3 changes: 1 addition & 2 deletions infinigen/assets/materials/ice.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,8 @@ def shader_ice(nw: NodeWrangler):
principled_bsdf = nw.new_node(
Nodes.PrincipledBSDF,
input_kwargs={
'Subsurface': 1.0000,
'Subsurface Weight': 1.0000,
'Subsurface Radius': (0.0010, 0.0010, 0.0020),
'Subsurface Color': tuple(col_ice),
'Roughness': color_ramp.outputs["Color"],
'IOR': 1.3100
},
Expand Down
Loading

0 comments on commit 1e12272

Please sign in to comment.