Add DoF back to PsychoBlend exporter.

This commit is contained in:
Nathan Vegdahl 2022-08-17 13:43:39 -07:00
parent cb01d1aaea
commit 4058c63637
2 changed files with 16 additions and 9 deletions

View File

@ -130,7 +130,7 @@ class RectLamp:
render_engine.update_stats("", "Psychopath: Collecting '{}' at time {}".format(self.name, time))
if ob.data.psychopath.color_type == 'Rec709':
self.time_col += [('Rec709', ob.data.color * ob.data.energy)]
self.time_col += [('Rec709', ob.data.color * ob.data.energy / 2)]
elif ob.data.psychopath.color_type == 'Blackbody':
self.time_col += [('Blackbody', ob.data.psychopath.color_blackbody_temp, ob.data.energy)]
elif ob.data.psychopath.color_type == 'ColorTemperature':

View File

@ -1,6 +1,6 @@
import bpy
from math import degrees, tan, atan
from math import degrees, sin, asin, tan, atan
from mathutils import Vector, Matrix
from .util import escape_name, mat2str, ExportCancelled
@ -42,17 +42,24 @@ class Camera:
def take_sample(self, render_engine, depsgraph, time):
render_engine.update_stats("", "Psychopath: Collecting '{}' at time {}".format(self.ob.name, time))
# Fov
self.fovs += [degrees(self.ob.data.angle_x)]
# Fov.
# TODO: account for the various ways sensor size can be specified.
x_extent = depsgraph.scene.render.resolution_x / depsgraph.scene.render.pixel_aspect_x
y_extent = depsgraph.scene.render.resolution_y / depsgraph.scene.render.pixel_aspect_y
aspect_ratio = x_extent / y_extent
if aspect_ratio >= 1.0:
self.fovs += [degrees(self.ob.data.angle_x)]
else:
self.fovs += [degrees(2.0 * atan(tan(self.ob.data.angle_x * 0.5) * aspect_ratio))]
if self.ob.data.dof.use_dof:
# TODO
# # Aperture radius
# self.aperture_radii += [self.ob.data.psychopath.aperture_radius]
# Aperture radius.
radius = self.ob.data.lens / 2000.0 / self.ob.data.dof.aperture_fstop
self.aperture_radii += [radius]
# Dof distance
if self.ob.data.dof_object == None:
self.focal_distances += [self.ob.data.dof_distance]
if self.ob.data.dof.focus_object == None:
self.focal_distances += [self.ob.data.dof.focus_distance]
else:
# TODO: implement DoF object tracking here
self.focal_distances += [0.0]