-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlightprobe.py
47 lines (38 loc) · 1.76 KB
/
lightprobe.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import bpy
def add_volume_light_probe(cube, resolution_x=4, resolution_y=4, resolution_z=4, falloff=0.75, bleed_bias=0.0):
"""
Adds a Volume Light Probe to the scene based on the dimensions and location of a given cube.
Parameters:
- cube: The cube object to base the volume light probe dimensions and location on.
- resolution_x, resolution_y, resolution_z: The resolution of the probe in the X, Y, and Z axes.
- falloff: The distance over which light from the probe fades out.
- bleed_bias: The bias (in meters) to reduce light bleeding.
"""
# Ensure the cube exists
if not cube:
print("Cube object is required.")
return
# Calculate the location and dimensions for the light probe
location = cube.location
scale = cube.scale
# Add a volume light probe
bpy.ops.object.lightprobe_add(type='VOLUME', location=location)
light_probe = bpy.context.object
light_probe.name = "VolumeLightProbe"
light_probe.data.grid_resolution_x = resolution_x
light_probe.data.grid_resolution_y = resolution_y
light_probe.data.grid_resolution_z = resolution_z
light_probe.data.falloff = falloff
light_probe.data.bleed_bias = bleed_bias
# Scale the light probe to match the cube dimensions
light_probe.scale = scale
return light_probe
def main():
# Example usage
# First, create the scene bounding cube (assuming the create_scene_bounding_cube function is defined)
cube = create_scene_bounding_cube()
# Then, add a volume light probe based on this cube
volume_light_probe = add_volume_light_probe(cube, resolution_x=8, resolution_y=8, resolution_z=8, falloff=0.75, bleed_bias=0.1)
print(f"Added {volume_light_probe.name} to the scene.")
if __name__ == "__main__":
main()