Object Occlusion Culling

This commit is contained in:
2026-10-15 02:41:03 -07:00
parent 3273054766
commit 612a3d0a09
33 changed files with 3629 additions and 84 deletions

View File

@ -232,6 +232,15 @@ def update_renderpath(self, context):
assets.invalidate_shader_cache(self, context)
bpy.data.worlds['Lnx'].lnx_recompile = True
def update_occlusion_culling(self, context):
for m in bpy.data.meshes:
m.lnx_cached = False
for c in bpy.data.curves:
c.lnx_cached = False
for c in bpy.data.metaballs:
c.lnx_cached = False
update_renderpath(self, context)
def udpate_shadowmap_cascades(self, context):
bpy.data.worlds['Lnx'].lnx_recompile = True
update_renderpath(self, context)
@ -461,6 +470,7 @@ class LnxRPListItem(bpy.types.PropertyGroup):
('Distance', 'Distance', 'Distance'),
('Index', 'Index', 'Index')],
name='Draw Order', description='Sort objects', default='Auto', update=assets.invalidate_compiled_data)
lnx_radix: BoolProperty(name="Radix Sort", description="Sort draw calls with the radix library instead of the comparison sort", default=True, update=update_renderpath)
rp_depth_texture: BoolProperty(name="Depth Texture", description="Current render-path state", default=False)
rp_depth_texture_state: EnumProperty(
items=[('On', 'On', 'On'),
@ -697,8 +707,48 @@ class LnxRPListItem(bpy.types.PropertyGroup):
('CPU', 'CPU', 'CPU'),
('Off', 'Off', 'Off')],
name='Particles', description='Enable particle simulation', default='GPU', update=assets.invalidate_shader_cache)
# Material override flags
lnx_culling: BoolProperty(name="Culling", default=True)
# Culling flags
lnx_backface_culling: BoolProperty(name="Backface Culling", description="Cull back-facing triangles (winding-based)", default=True)
lnx_frustum_culling: BoolProperty(name="Frustum Culling", description="Cull objects outside camera frustum", default=True)
lnx_occlusion_culling: BoolProperty(name="Object Occlusion Culling (Experimental)", description="Software occlusion culling using Hi-Z buffer", default=False, update=update_occlusion_culling)
lnx_occlusion_all_objects: BoolProperty(name="All Objects Occlude", description="Every mesh can occlude - ignores the per-object 'Is Occluder' flag", default=False, update=update_occlusion_culling)
lnx_occlusion_min_size: FloatProperty(name="Min Occluder Size", description="Objects whose largest bounding-box side is smaller than this (meters) never export as occluders", default=0.5, min=0.0, update=update_occlusion_culling)
lnx_occlusion_proxy_mode: EnumProperty(
name="Proxy Mode",
description="Occluder proxy geometry type",
items=[
('box', 'Box', 'Axis-aligned bounding box - fastest, 12 triangles'),
('convex', 'Convex Hull', 'Convex hull of the mesh - tight on convex shapes, over-covers concave ones'),
('decimate', 'Decimate', 'Decimated mesh - closest fit, slowest export'),
],
default='convex', update=update_occlusion_culling)
lnx_occlusion_proxy_shrink: FloatProperty(name="Proxy Shrink %", description="Shrink proxy toward its center: 0 = full size, 50 = half size (default), 100 = point - keeps occluders conservative", default=50.0, min=0.0, max=100.0, precision=1, update=update_occlusion_culling)
lnx_occlusion_box_shrink: IntProperty(name="Box Shrink %", description="0 = full AABB (aggressive), 50 = half-size (default, balanced), 100 = point (no occlusion)", default=50, min=0, max=100, update=update_renderpath)
lnx_occlusion_depth_eps: IntProperty(name="Depth Epsilon", description="6 = 1e-6 (default, tight), higher = more tolerant (less aggressive culling), lower = stricter", default=6, min=1, max=10, update=update_renderpath)
lnx_occlusion_decimate_ratio: FloatProperty(name="Ratio", description="Proportion of edges to collapse (COLLAPSE) or angle threshold in degrees (DISSOLVE) or iterations (UNSUBDIV)", default=0.5, min=0.01, max=1.0, precision=3, update=update_occlusion_culling)
lnx_occlusion_decimate_mode: EnumProperty(
name="Decimate Mode",
description="Decimate method applied to occluder proxy geometry",
items=[
('COLLAPSE', 'Collapse', 'Collapse edges to reduce triangle count by ratio'),
('DISSOLVE', 'Dissolve', 'Dissolve vertices with angle below threshold (ratio = degrees)'),
('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