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) {
|
||||
if (data.raw.ortho != null) {
|
||||
var left = data.raw.ortho[0];
|
||||
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);
|
||||
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);
|
||||
}
|
||||
else {
|
||||
if (screenAspect == null) screenAspect = iron.App.w() / iron.App.h();
|
||||
|
||||
@ -2652,8 +2652,6 @@ class LeenkxExporter:
|
||||
c = proj[2][2]
|
||||
d = proj[2][3]
|
||||
o['fov'] = 2.0 * math.atan(1.0 / b)
|
||||
if abs(a) > 1e-6:
|
||||
o['aspect'] = b / a
|
||||
if with_planes:
|
||||
denom = c + 1.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['near_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):
|
||||
o = {}
|
||||
@ -2710,22 +2685,16 @@ class LeenkxExporter:
|
||||
|
||||
camera = objectRef[1]["objectTable"][0]
|
||||
render = self.scene.render
|
||||
rpdat = lnx.utils.get_rp()
|
||||
|
||||
par_x, par_y = self.compute_effective_par(rpdat, render)
|
||||
|
||||
proj = camera.calc_matrix_camera(
|
||||
self.depsgraph,
|
||||
x=render.resolution_x,
|
||||
y=render.resolution_y,
|
||||
scale_x=par_x,
|
||||
scale_y=par_y)
|
||||
scale_x=render.pixel_aspect_x,
|
||||
scale_y=render.pixel_aspect_y)
|
||||
if objref.type == 'PERSP':
|
||||
self.extract_projection(o, proj)
|
||||
else:
|
||||
self.extract_ortho(o, proj)
|
||||
if par_x == par_y:
|
||||
o.pop('aspect', None)
|
||||
|
||||
o['frustum_culling'] = objref.lnx_frustum_culling
|
||||
o['clear_color'] = self.get_camera_clear_color()
|
||||
@ -3386,12 +3355,6 @@ class LeenkxExporter:
|
||||
'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
|
||||
proj, is_persp = self.get_viewport_projection_matrix()
|
||||
if proj is not None:
|
||||
@ -3400,9 +3363,6 @@ class LeenkxExporter:
|
||||
else:
|
||||
self.extract_ortho(out_camera, proj)
|
||||
|
||||
if par_x != par_y:
|
||||
out_camera['aspect'] = effective_aspect
|
||||
|
||||
self.output['camera_datas'].append(out_camera)
|
||||
|
||||
out_object = {
|
||||
|
||||
@ -390,14 +390,12 @@ def send_event(event_id: str, opt_data: Any = None):
|
||||
elif event_id == 'cam_props':
|
||||
cam: bpy.types.Camera = obj_data.data
|
||||
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(
|
||||
bpy.context.evaluated_depsgraph_get(),
|
||||
x=render.resolution_x,
|
||||
y=render.resolution_y,
|
||||
scale_x=par_x,
|
||||
scale_y=par_y)
|
||||
scale_x=render.pixel_aspect_x,
|
||||
scale_y=render.pixel_aspect_y)
|
||||
focal_y = projection[1][1]
|
||||
depth_z = projection[2][2]
|
||||
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)
|
||||
near = (depth_w * (1.0 - far_near_ratio)) / (2.0 * far_near_ratio)
|
||||
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}")'
|
||||
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)
|
||||
|
||||
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)'),
|
||||
],
|
||||
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)
|
||||
|
||||
@staticmethod
|
||||
|
||||
@ -1923,9 +1923,6 @@ class LNX_PT_RenderPathRendererPanel(bpy.types.Panel):
|
||||
col.prop(rpdat, 'lnx_occlusion_proxy_shrink')
|
||||
col.prop(rpdat, 'lnx_occlusion_box_shrink')
|
||||
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')
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user