Clamp cascade size

This commit is contained in:
luboslenco 2019-01-21 17:59:25 +01:00
parent b6e5506612
commit 169bf4878b
5 changed files with 14 additions and 5 deletions

View file

@ -1502,7 +1502,7 @@ class ArmoryExporter:
o['shadows_bias'] = objref.arm_shadows_bias * 0.0001
rpdat = arm.utils.get_rp()
if rpdat.rp_shadows:
o['shadowmap_size'] = int(rpdat.rp_shadowmap_cube) if objtype == 'POINT' else int(rpdat.rp_shadowmap_cascade)
o['shadowmap_size'] = int(rpdat.rp_shadowmap_cube) if objtype == 'POINT' else arm.utils.get_cascade_size(rpdat)
else:
o['shadowmap_size'] = 0
if o['type'] == 'sun': # Scale bias for ortho light matrix

View file

@ -139,7 +139,7 @@ def build():
if rpdat.rp_shadows:
assets.add_khafile_def('rp_shadowmap')
assets.add_khafile_def('rp_shadowmap_cascade={0}'.format(rpdat.rp_shadowmap_cascade))
assets.add_khafile_def('rp_shadowmap_cascade={0}'.format(arm.utils.get_cascade_size(rpdat)))
assets.add_khafile_def('rp_shadowmap_cube={0}'.format(rpdat.rp_shadowmap_cube))
assets.add_khafile_def('rp_background={0}'.format(rpdat.rp_background))

View file

@ -282,7 +282,9 @@ class ArmRPListItem(bpy.types.PropertyGroup):
('512', '512', '512'),
('1024', '1024', '1024'),
('2048', '2048', '2048'),
('4096', '4096', '4096'),],
('4096', '4096', '4096'),
('8192', '8192', '8192'),
('16384', '16384', '16384'),],
name="Cascade Size", description="Shadow map resolution", default='1024', update=update_renderpath)
rp_shadowmap_cascades: EnumProperty(
items=[('1', '1', '1'),

View file

@ -440,6 +440,13 @@ def voxel_support():
# macos does not support opengl 4.5, needs metal
return state.target != 'html5' and get_os() != 'mac'
def get_cascade_size(rpdat):
cascade_size = int(rpdat.rp_shadowmap_cascade)
# Clamp to 4096 per cascade
if int(rpdat.rp_shadowmap_cascades) > 1 and cascade_size > 4096:
cascade_size = 4096
return cascade_size
def check_saved(self):
if bpy.data.filepath == "":
msg = "Save blend file first"

View file

@ -317,7 +317,7 @@ def write_config(resx, resy):
output['rp_supersample'] = float(rpdat.rp_supersampling)
rp_shadowmap_cube = int(rpdat.rp_shadowmap_cube) if rpdat.rp_shadows else 0
output['rp_shadowmap_cube'] = rp_shadowmap_cube
rp_shadowmap_cascade = int(rpdat.rp_shadowmap_cascade) if rpdat.rp_shadows else 0
rp_shadowmap_cascade = arm.utils.get_cascade_size(rpdat) if rpdat.rp_shadows else 0
output['rp_shadowmap_cascade'] = rp_shadowmap_cascade
output['rp_ssgi'] = rpdat.rp_ssgi != 'Off'
output['rp_ssr'] = rpdat.rp_ssr != 'Off'
@ -440,7 +440,7 @@ def write_indexhtml(w, h, is_publish):
add_compiledglsl = ''
def write_compiledglsl(defs):
rpdat = arm.utils.get_rp()
shadowmap_size = int(rpdat.rp_shadowmap_cascade) if rpdat.rp_shadows else 0
shadowmap_size = arm.utils.get_cascade_size(rpdat) if rpdat.rp_shadows else 0
with open(arm.utils.build_dir() + '/compiled/Shaders/compiled.inc', 'w') as f:
f.write(
"""#ifndef _COMPILED_GLSL_