diff --git a/infinigen/assets/materials/aluminumdisp2tut.py b/infinigen/assets/materials/aluminumdisp2tut.py index 0977d4c20..e8ac1ffe6 100644 --- a/infinigen/assets/materials/aluminumdisp2tut.py +++ b/infinigen/assets/materials/aluminumdisp2tut.py @@ -1,15 +1,15 @@ -import os, sys -import numpy as np -import math as ma +# Copyright (c) Princeton University. +# This source code is licensed under the BSD 3-Clause license found in the LICENSE file in the root directory of this source tree. + +# Authors: Mingzhe Wang +# Acknowledgment: This file draws inspiration from https://www.youtube.com/watch?v=FY0lR96Mwas by Sam Bowman + + +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): diff --git a/infinigen/assets/materials/face_size_visualizer.py b/infinigen/assets/materials/face_size_visualizer.py index aaada27d6..d8106f8ba 100644 --- a/infinigen/assets/materials/face_size_visualizer.py +++ b/infinigen/assets/materials/face_size_visualizer.py @@ -3,7 +3,13 @@ # Authors: Alexander Raistrick + +import bpy +import mathutils +from numpy.random import uniform, normal, randint 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_material(nw: NodeWrangler): @@ -21,18 +27,21 @@ def shader_material(nw: NodeWrangler): def geo_face_colors(nw: NodeWrangler): # Code generated using version 2.4.3 of the node_transpiler - group_input = nw.expose_input('Geometry', dtype='NodeSocketGeometry') + group_input = nw.new_node(Nodes.GroupInput, + expose_input=[('NodeSocketGeometry', 'Geometry', None)]) 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, 'Name': 'col', "Value": random_value.outputs["Value"]}, + input_kwargs={'Geometry': group_input.outputs["Geometry"], 'Name': 'col', "Value": random_value.outputs["Value"]}, attrs={'data_type': 'FLOAT_VECTOR', 'domain': 'FACE'}) group_output = nw.new_node(Nodes.GroupOutput, input_kwargs={'Geometry': store_named_attribute}) + + def apply(obj, selection=None, **kwargs): surface.add_geomod(obj, geo_face_colors, selection=selection, attributes=[]) surface.add_material(obj, shader_material, selection=selection) \ No newline at end of file diff --git a/infinigen/assets/materials/water.py b/infinigen/assets/materials/water.py index 79e0ccb5d..7d90f3470 100644 --- a/infinigen/assets/materials/water.py +++ b/infinigen/assets/materials/water.py @@ -1,22 +1,3 @@ -# START RUN -# pathspec = 'infinigen.assets.materials.water', kwargs = {}, asset = bpy.data.objects['Icosphere'] -# mat = - -# @pytest.mark.ci -# @pytest.mark.parametrize('pathspec', load_txt_list('test_materials_basic.txt')) -# def test_material_runs(pathspec, **kwargs): - -# butil.clear_scene() -# bpy.ops.mesh.primitive_ico_sphere_add(radius=.8, subdivisions=5) -# asset = bpy.context.active_object - -# mat = import_item(pathspec) -# > mat.apply(asset) - -# tests/test_materials_basic.py:27: -# END RUN - - # Copyright (c) Princeton University. # This source code is licensed under the BSD 3-Clause license found in the LICENSE file in the root directory of this source tree. @@ -85,7 +66,7 @@ def geo_water( if with_ripples: water_height_node.outputs[0].default_value *= 0.1 ripple_height_node.outputs[0].default_value = water_height - water_height_node = nw.scalar_multiply(water_height_node, nw.scalar_add(0.5, nw.new_node(Nodes.MusgraveTexture, input_kwargs={"Scale": rg(height_modulation_scale)}))) + water_height_node = nw.scalar_multiply(water_height_node, nw.scalar_add(0.5, nw.new_node("ShaderNodeTexMusgrave", input_kwargs={"Scale": rg(height_modulation_scale)}))) water_dimension_node = nw.new_node(Nodes.Value, label=f"water_dimension") water_dimension_node.outputs[0].default_value = rg(water_dimension) water_lacunarity_node = nw.new_node(Nodes.Value, label=f"water_lacunarity") @@ -99,7 +80,7 @@ def geo_water( if waves_animation_speed is not None: drive_param(animated_position.inputs[0], rg(waves_animation_speed), offset=uniform(0, 10), index=1) - wave0 = nw.new_node(Nodes.MusgraveTexture, [ + wave0 = nw.new_node("ShaderNodeTexMusgrave", [ animated_position, None, water_scale_node, water_detail_node, @@ -157,7 +138,7 @@ def geo_water( weight1 = nw.scalar_multiply(1 / np.pi, nw.scalar_sub(np.pi / 2, nw.new_node(Nodes.Math, [nw.scalar_multiply(0.1, nw.scalar_add(30, X))], attrs={'operation': 'ARCTANGENT'}))) weight2 = nw.scalar_add(0.5, nw.scalar_multiply(1 / np.pi, nw.new_node(Nodes.Math, [nw.scalar_multiply(0.1, nw.scalar_add(60, X))], attrs={'operation': 'ARCTANGENT'}))) offset = nw.multiply(offset, nw.scalar_multiply(weight1, weight2)) - offset = nw.add(offset, nw.multiply(nw.new_node(Nodes.MusgraveTexture, input_kwargs={"Scale": 1}), [0, 0, 0.03])) + offset = nw.add(offset, nw.multiply(nw.new_node("ShaderNodeTexMusgrave", input_kwargs={"Scale": 1}), [0, 0, 0.03])) foam = nw.multiply(foam, weight2) group_input = nw.new_node(