forked from LeenkxTeam/LNXSDK
Revert PAR
This commit is contained in:
@ -62,20 +62,7 @@ class CameraObject extends Object {
|
|||||||
|
|
||||||
public function buildProjection(screenAspect: Null<Float> = null) {
|
public function buildProjection(screenAspect: Null<Float> = null) {
|
||||||
if (data.raw.ortho != null) {
|
if (data.raw.ortho != null) {
|
||||||
var left = data.raw.ortho[0];
|
P = Mat4.ortho(data.raw.ortho[0], data.raw.ortho[1], data.raw.ortho[2], data.raw.ortho[3], data.raw.near_plane, data.raw.far_plane);
|
||||||
var right = data.raw.ortho[1];
|
|
||||||
var bottom = data.raw.ortho[2];
|
|
||||||
var top = data.raw.ortho[3];
|
|
||||||
if (data.raw.aspect != null) {
|
|
||||||
var aspect: kha.FastFloat = data.raw.aspect;
|
|
||||||
if (screenAspect == null) screenAspect = iron.App.w() / iron.App.h();
|
|
||||||
var scale = aspect / screenAspect;
|
|
||||||
var cx = (left + right) * 0.5;
|
|
||||||
var hw = (right - left) * 0.5 * scale;
|
|
||||||
left = cx - hw;
|
|
||||||
right = cx + hw;
|
|
||||||
}
|
|
||||||
P = Mat4.ortho(left, right, bottom, top, data.raw.near_plane, data.raw.far_plane);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (screenAspect == null) screenAspect = iron.App.w() / iron.App.h();
|
if (screenAspect == null) screenAspect = iron.App.w() / iron.App.h();
|
||||||
|
|||||||
@ -2652,8 +2652,6 @@ class LeenkxExporter:
|
|||||||
c = proj[2][2]
|
c = proj[2][2]
|
||||||
d = proj[2][3]
|
d = proj[2][3]
|
||||||
o['fov'] = 2.0 * math.atan(1.0 / b)
|
o['fov'] = 2.0 * math.atan(1.0 / b)
|
||||||
if abs(a) > 1e-6:
|
|
||||||
o['aspect'] = b / a
|
|
||||||
if with_planes:
|
if with_planes:
|
||||||
denom = c + 1.0
|
denom = c + 1.0
|
||||||
k = (c - 1.0) / denom if abs(denom) >= 1e-6 else 0.0
|
k = (c - 1.0) / denom if abs(denom) >= 1e-6 else 0.0
|
||||||
@ -2679,29 +2677,6 @@ class LeenkxExporter:
|
|||||||
o['far_plane'] = -(1 - proj[3][2]) / proj[2][2]
|
o['far_plane'] = -(1 - proj[3][2]) / proj[2][2]
|
||||||
o['near_plane'] *= 2
|
o['near_plane'] *= 2
|
||||||
o['far_plane'] *= 2
|
o['far_plane'] *= 2
|
||||||
if abs(a) > 1e-6:
|
|
||||||
o['aspect'] = b / a
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def compute_effective_par(rpdat, render):
|
|
||||||
if rpdat is None:
|
|
||||||
return render.pixel_aspect_x, render.pixel_aspect_y
|
|
||||||
mode = rpdat.lnx_aspect_mode
|
|
||||||
if mode == 'blender':
|
|
||||||
return render.pixel_aspect_x, render.pixel_aspect_y
|
|
||||||
elif mode == 'square':
|
|
||||||
return 1.0, 1.0
|
|
||||||
elif mode == 'ntsc_43':
|
|
||||||
return 0.889, 1.0
|
|
||||||
elif mode == 'pal_43':
|
|
||||||
return 1.067, 1.0
|
|
||||||
elif mode == 'ntsc_169':
|
|
||||||
return 1.212, 1.0
|
|
||||||
elif mode == 'pal_169':
|
|
||||||
return 1.459, 1.0
|
|
||||||
elif mode == 'custom':
|
|
||||||
return rpdat.lnx_aspect_custom, 1.0
|
|
||||||
return render.pixel_aspect_x, render.pixel_aspect_y
|
|
||||||
|
|
||||||
def export_camera(self, objectRef):
|
def export_camera(self, objectRef):
|
||||||
o = {}
|
o = {}
|
||||||
@ -2710,22 +2685,16 @@ class LeenkxExporter:
|
|||||||
|
|
||||||
camera = objectRef[1]["objectTable"][0]
|
camera = objectRef[1]["objectTable"][0]
|
||||||
render = self.scene.render
|
render = self.scene.render
|
||||||
rpdat = lnx.utils.get_rp()
|
|
||||||
|
|
||||||
par_x, par_y = self.compute_effective_par(rpdat, render)
|
|
||||||
|
|
||||||
proj = camera.calc_matrix_camera(
|
proj = camera.calc_matrix_camera(
|
||||||
self.depsgraph,
|
self.depsgraph,
|
||||||
x=render.resolution_x,
|
x=render.resolution_x,
|
||||||
y=render.resolution_y,
|
y=render.resolution_y,
|
||||||
scale_x=par_x,
|
scale_x=render.pixel_aspect_x,
|
||||||
scale_y=par_y)
|
scale_y=render.pixel_aspect_y)
|
||||||
if objref.type == 'PERSP':
|
if objref.type == 'PERSP':
|
||||||
self.extract_projection(o, proj)
|
self.extract_projection(o, proj)
|
||||||
else:
|
else:
|
||||||
self.extract_ortho(o, proj)
|
self.extract_ortho(o, proj)
|
||||||
if par_x == par_y:
|
|
||||||
o.pop('aspect', None)
|
|
||||||
|
|
||||||
o['frustum_culling'] = objref.lnx_frustum_culling
|
o['frustum_culling'] = objref.lnx_frustum_culling
|
||||||
o['clear_color'] = self.get_camera_clear_color()
|
o['clear_color'] = self.get_camera_clear_color()
|
||||||
@ -3386,12 +3355,6 @@ class LeenkxExporter:
|
|||||||
'clear_color': self.get_camera_clear_color()
|
'clear_color': self.get_camera_clear_color()
|
||||||
}
|
}
|
||||||
|
|
||||||
render = self.scene.render
|
|
||||||
rpdat = lnx.utils.get_rp()
|
|
||||||
par_x, par_y = self.compute_effective_par(rpdat, render)
|
|
||||||
res_aspect = render.resolution_x / render.resolution_y if render.resolution_y > 0 else 1.0
|
|
||||||
effective_aspect = res_aspect * par_x / par_y
|
|
||||||
|
|
||||||
# Set viewport camera projection
|
# Set viewport camera projection
|
||||||
proj, is_persp = self.get_viewport_projection_matrix()
|
proj, is_persp = self.get_viewport_projection_matrix()
|
||||||
if proj is not None:
|
if proj is not None:
|
||||||
@ -3400,9 +3363,6 @@ class LeenkxExporter:
|
|||||||
else:
|
else:
|
||||||
self.extract_ortho(out_camera, proj)
|
self.extract_ortho(out_camera, proj)
|
||||||
|
|
||||||
if par_x != par_y:
|
|
||||||
out_camera['aspect'] = effective_aspect
|
|
||||||
|
|
||||||
self.output['camera_datas'].append(out_camera)
|
self.output['camera_datas'].append(out_camera)
|
||||||
|
|
||||||
out_object = {
|
out_object = {
|
||||||
|
|||||||
@ -390,14 +390,12 @@ def send_event(event_id: str, opt_data: Any = None):
|
|||||||
elif event_id == 'cam_props':
|
elif event_id == 'cam_props':
|
||||||
cam: bpy.types.Camera = obj_data.data
|
cam: bpy.types.Camera = obj_data.data
|
||||||
render = bpy.context.scene.render
|
render = bpy.context.scene.render
|
||||||
rpdat = lnx.utils.get_rp()
|
|
||||||
par_x, par_y = LeenkxExporter.compute_effective_par(rpdat, render)
|
|
||||||
projection = obj_data.calc_matrix_camera(
|
projection = obj_data.calc_matrix_camera(
|
||||||
bpy.context.evaluated_depsgraph_get(),
|
bpy.context.evaluated_depsgraph_get(),
|
||||||
x=render.resolution_x,
|
x=render.resolution_x,
|
||||||
y=render.resolution_y,
|
y=render.resolution_y,
|
||||||
scale_x=par_x,
|
scale_x=render.pixel_aspect_x,
|
||||||
scale_y=par_y)
|
scale_y=render.pixel_aspect_y)
|
||||||
focal_y = projection[1][1]
|
focal_y = projection[1][1]
|
||||||
depth_z = projection[2][2]
|
depth_z = projection[2][2]
|
||||||
depth_w = projection[2][3]
|
depth_w = projection[2][3]
|
||||||
@ -405,10 +403,8 @@ def send_event(event_id: str, opt_data: Any = None):
|
|||||||
fov = 2.0 * math.atan(1.0 / focal_y)
|
fov = 2.0 * math.atan(1.0 / focal_y)
|
||||||
near = (depth_w * (1.0 - far_near_ratio)) / (2.0 * far_near_ratio)
|
near = (depth_w * (1.0 - far_near_ratio)) / (2.0 * far_near_ratio)
|
||||||
far = far_near_ratio * near
|
far = far_near_ratio * near
|
||||||
res_aspect = render.resolution_x / render.resolution_y if render.resolution_y > 0 else 1.0
|
|
||||||
effective_aspect = res_aspect * par_x / par_y
|
|
||||||
cam_obj = f'iron.Scene.active.getCamera("{cam.name}")'
|
cam_obj = f'iron.Scene.active.getCamera("{cam.name}")'
|
||||||
js = f'var c = {cam_obj}; var cRaw = c.data.raw; cRaw.fov={fov}; cRaw.near_plane={near}; cRaw.far_plane={far}; cRaw.frustum_culling={"true" if cam.lnx_frustum_culling else "false"}; cRaw.aspect={effective_aspect}; c.buildProjection();'
|
js = f'var c = {cam_obj}; var cRaw = c.data.raw; cRaw.fov={fov}; cRaw.near_plane={near}; cRaw.far_plane={far}; cRaw.frustum_culling={"true" if cam.lnx_frustum_culling else "false"}; c.buildProjection();'
|
||||||
write_patch(js)
|
write_patch(js)
|
||||||
|
|
||||||
elif event_id == 'obj_visibility':
|
elif event_id == 'obj_visibility':
|
||||||
|
|||||||
@ -735,20 +735,6 @@ class LnxRPListItem(bpy.types.PropertyGroup):
|
|||||||
('UNSUBDIV', 'Unsubdivide', 'Reverse subdivision (ratio = iterations, 0.1 = 1 iter, 1.0 = 10 iter)'),
|
('UNSUBDIV', 'Unsubdivide', 'Reverse subdivision (ratio = iterations, 0.1 = 1 iter, 1.0 = 10 iter)'),
|
||||||
],
|
],
|
||||||
default='COLLAPSE', update=update_occlusion_culling)
|
default='COLLAPSE', update=update_occlusion_culling)
|
||||||
lnx_aspect_mode: EnumProperty(
|
|
||||||
name="Aspect Ratio",
|
|
||||||
description="Pixel aspect ratio override for camera projection. 'Blender' uses the scene's resolution and pixel aspect settings",
|
|
||||||
items=[
|
|
||||||
('blender', 'Blender', 'Use Blender\'s Output Properties resolution and pixel aspect ratio'),
|
|
||||||
('square', 'Square (1.0)', 'Square pixels (1:1)'),
|
|
||||||
('ntsc_43', 'NTSC 4:3', 'NTSC pixel aspect ratio (0.889)'),
|
|
||||||
('pal_43', 'PAL 4:3', 'PAL pixel aspect ratio (1.067)'),
|
|
||||||
('ntsc_169', 'NTSC 16:9', 'NTSC widescreen pixel aspect ratio (1.212)'),
|
|
||||||
('pal_169', 'PAL 16:9', 'PAL widescreen pixel aspect ratio (1.459)'),
|
|
||||||
('custom', 'Custom', 'Custom pixel aspect ratio'),
|
|
||||||
],
|
|
||||||
default='blender')
|
|
||||||
lnx_aspect_custom: FloatProperty(name="Custom PAR", description="Custom pixel aspect ratio (width/height of a single pixel)", default=1.0, min=0.01, max=10.0, precision=3)
|
|
||||||
lnx_two_sided_area_light: BoolProperty(name="Two-Sided Area Light", description="Emit light from both faces of area plane", default=False, update=assets.invalidate_shader_cache)
|
lnx_two_sided_area_light: BoolProperty(name="Two-Sided Area Light", description="Emit light from both faces of area plane", default=False, update=assets.invalidate_shader_cache)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|||||||
@ -1923,9 +1923,6 @@ class LNX_PT_RenderPathRendererPanel(bpy.types.Panel):
|
|||||||
col.prop(rpdat, 'lnx_occlusion_proxy_shrink')
|
col.prop(rpdat, 'lnx_occlusion_proxy_shrink')
|
||||||
col.prop(rpdat, 'lnx_occlusion_box_shrink')
|
col.prop(rpdat, 'lnx_occlusion_box_shrink')
|
||||||
col.prop(rpdat, 'lnx_occlusion_depth_eps')
|
col.prop(rpdat, 'lnx_occlusion_depth_eps')
|
||||||
col.prop(rpdat, 'lnx_aspect_mode')
|
|
||||||
if rpdat.lnx_aspect_mode == 'custom':
|
|
||||||
col.prop(rpdat, 'lnx_aspect_custom')
|
|
||||||
col.prop(rpdat, 'rp_pp')
|
col.prop(rpdat, 'rp_pp')
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user