| 251 | |
| 252 | |
| 253 | def setup_world_hdr(): |
| 254 | world = bpy.data.worlds.get("World") |
| 255 | if world is None: |
| 256 | world = bpy.data.worlds.new("World") |
| 257 | bpy.context.scene.world = world |
| 258 | world.use_nodes = True |
| 259 | nt = world.node_tree |
| 260 | nt.nodes.clear() |
| 261 | |
| 262 | out = nt.nodes.new("ShaderNodeOutputWorld") |
| 263 | bg = nt.nodes.new("ShaderNodeBackground") |
| 264 | env = nt.nodes.new("ShaderNodeTexEnvironment") |
| 265 | mapn = nt.nodes.new("ShaderNodeMapping") |
| 266 | coord = nt.nodes.new("ShaderNodeTexCoord") |
| 267 | |
| 268 | if os.path.isfile(OUTDOOR_HDR): |
| 269 | env.image = bpy.data.images.load(OUTDOOR_HDR, check_existing=True) |
| 270 | else: |
| 271 | print(f"[cycles_reference] WARNING: HDR not found at {OUTDOOR_HDR}", file=sys.stderr) |
| 272 | |
| 273 | bg.inputs["Strength"].default_value = ENV_INTENSITY |
| 274 | |
| 275 | nt.links.new(coord.outputs["Generated"], mapn.inputs["Vector"]) |
| 276 | nt.links.new(mapn.outputs["Vector"], env.inputs["Vector"]) |
| 277 | nt.links.new(env.outputs["Color"], bg.inputs["Color"]) |
| 278 | nt.links.new(bg.outputs["Background"], out.inputs["Surface"]) |
| 279 | |
| 280 | |
| 281 | def add_sun(name, dir_bloom, color, strength): |