Skip to content

Commit

Permalink
Merge pull request #313 from Hubs-Foundation/fix-blender-4.2-reflecti…
Browse files Browse the repository at this point in the history
…on-probe-baking

Fix blender 4.2 reflection probe baking and image importing
  • Loading branch information
Exairnous authored Oct 19, 2024
2 parents ef9d651 + f54d164 commit e45e941
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions addons/io_hubs_addon/components/definitions/reflection_probe.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ def modal(self, context, event):
else:
update_image_editors(old_img, img)

probe_component['envMapTexture'] = img
probe_component.envMapTexture = img

# Pack image and update filepaths so that it displays/unpacks nicely for the user.
# Note: updating the filepaths prints an error to the terminal, but otherwise seems to work fine.
Expand Down Expand Up @@ -338,14 +338,15 @@ def restore_render_props(self):

def setup_probe_render(self, context):
probe = self.probes[self.probe_index]
cycles_settings = self.camera_data.cycles if bpy.app.version < (4, 2, 0) else self.camera_data

self.camera_data.type = "PANO"
self.camera_data.cycles.panorama_type = "EQUIRECTANGULAR"
cycles_settings.panorama_type = "EQUIRECTANGULAR"

self.camera_data.cycles.longitude_min = -math.pi
self.camera_data.cycles.longitude_max = math.pi
self.camera_data.cycles.latitude_min = -math.pi / 2
self.camera_data.cycles.latitude_max = math.pi / 2
cycles_settings.longitude_min = -math.pi
cycles_settings.longitude_max = math.pi
cycles_settings.latitude_min = -math.pi / 2
cycles_settings.latitude_max = math.pi / 2

self.camera_data.clip_start = probe.data.clip_start
self.camera_data.clip_end = probe.data.clip_end
Expand Down Expand Up @@ -448,11 +449,11 @@ def execute(self, context):
for probe in probes:
if f.name.startswith(f"{probe.name} - EnvMap"):
probe_component = probe.hubs_component_reflection_probe
old_img = probe_component['envMapTexture']
old_img = probe_component.envMapTexture

img = bpy.data.images.load(
filepath=os.path.join(dirname, f.name))
probe_component['envMapTexture'] = img
probe_component.envMapTexture = img

if old_img:
if self.overwrite_images:
Expand Down

0 comments on commit e45e941

Please sign in to comment.