Download system/blender_scripts/material_examples/infinigen_basic_bsdf_example.py from yiranranranra/blender: direct link, hf CLI and curl.
- Browser
- Download file 1.06 kB
-
https://huggingface.co/yiranranranra/blender/resolve/main/system/blender_scripts/material_examples/infinigen_basic_bsdf_example.py
- Command line
-
hf download hf://yiranranranra/blender/system/blender_scripts/material_examples/infinigen_basic_bsdf_example.py
-
curl -L -o infinigen_basic_bsdf_example.py https://huggingface.co/yiranranranra/blender/resolve/main/system/blender_scripts/material_examples/infinigen_basic_bsdf_example.py
1.06 kB
| import bpy | |
| import mathutils | |
| import numpy as np | |
| from numpy.random import uniform, normal | |
| from infinigen.core.nodes.node_wrangler import Nodes, NodeWrangler | |
| from infinigen.core.util.color import hsv2rgba | |
| from infinigen.core import surface | |
| def shader_basic_bsdf(nw): | |
| color = nw.new_node(Nodes.RGB) | |
| color.outputs[0].default_value = hsv2rgba(uniform(0.05, 0.95, 3)) | |
| principled_bsdf = nw.new_node(Nodes.PrincipledBSDF, | |
| input_kwargs={ | |
| '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) | |
| }, | |
| attrs={'subsurface_method': 'BURLEY'}) | |
| material_output = nw.new_node(Nodes.MaterialOutput, | |
| input_kwargs={'Surface': principled_bsdf}) | |
| return principled_bsdf | |
| def apply(obj, selection=None, **kwargs): | |
| surface.add_material(obj, shader_basic_bsdf, reuse=False) | |
| # material_obj is what we want to apply this onto. | |
| apply(material_obj) | |