Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to bpy 4.1.0 and Python 3.11, packaging for installation to pypi is working (WIP) #252

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ jobs:
# default set of ruff rules with GitHub Annotations
#ruff --format=github . # to be enabled in a future PR

- name: Set up Python 3.10
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: "3.10"
python-version: "3.11"

- name: Install infinigen & dependencies
run: |
Expand Down
72 changes: 44 additions & 28 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,55 @@ FROM ${APP_IMAGE}
ARG APP_IMAGE
ENV PATH="/root/miniconda3/bin:${PATH}"
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 \
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 \
fi
echo "Using CUDA image" && \
apt-get update && \
apt-get install -y libxkbcommon-x11-0 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; \
else \
echo "Using Conda image" && \
apt-get update && \
apt-get install -yq \
cmake \
g++ \
libgconf-2-4 \
libgles2-mesa-dev \
libglew-dev \
libglfw3-dev \
libglm-dev \
libxi6 \
libxrender1 \
libxxf86vm-dev \
libxfixes3 \
xorg \
sudo \
unzip \
vim \
dbus \
software-properties-common \
zlib1g-dev \
libxkbcommon-x11-0 \
wget && \
wget https://www.python.org/ftp/python/3.11.3/Python-3.11.3.tgz && \
tar -xf Python-3.11.3.tgz && \
cd Python-3.11.3 && \
./configure --enable-optimizations && \
make -j$(nproc) && \
make altinstall && \
update-alternatives --install /usr/bin/python3 python3 /usr/local/bin/python3.11 1 && \
update-alternatives --install /usr/bin/python python /usr/local/bin/python3.11 1 && \
python3.11 -m pip install --upgrade pip && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*; \
fi

RUN mkdir /opt/infinigen
WORKDIR /opt/infinigen
COPY . .
RUN conda init bash \
&& . ~/.bashrc \
&& conda create --name infinigen python=3.10 \
&& conda create --name infinigen python=3.11 \
&& conda activate infinigen \
&& pip install -e .[dev]
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
2 changes: 1 addition & 1 deletion docs/Installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ On Linux / Mac / WSL:
```bash
git clone https://github.com/princeton-vl/infinigen.git
cd infinigen
conda create --name infinigen python=3.10
conda create --name infinigen python=3.11
conda activate infinigen
```

Expand Down
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
Loading
Loading