Forward cubemap shadow capture
This commit is contained in:
parent
b46d0ca15f
commit
40eb158021
|
@ -803,7 +803,7 @@ def parse_render_target(node, node_group, render_targets, depth_buffers):
|
|||
tnode = nodes.find_node_by_link(node_group, node, node.inputs[0])
|
||||
parse_render_target(tnode, node_group, render_targets, depth_buffers)
|
||||
|
||||
elif node.bl_idname == 'TargetNodeType' or node.bl_idname == 'ShadowMapNodeType':
|
||||
elif node.bl_idname == 'TargetNodeType': # or node.bl_idname == 'ShadowMapNodeType': # Create SM dynamically instead
|
||||
# Target already exists
|
||||
id = node.inputs[0].default_value
|
||||
for t in render_targets:
|
||||
|
@ -841,17 +841,6 @@ def parse_render_target(node, node_group, render_targets, depth_buffers):
|
|||
else: # ShadowMapNodeType
|
||||
target = make_shadowmap_target(node, scale)
|
||||
render_targets.append(target)
|
||||
|
||||
# Second shadowmap for point lamps
|
||||
# TODO: check if lamp users are visible
|
||||
# for lamp in bpy.data.lamps:
|
||||
# if lamp.type == 'POINT':
|
||||
# target = make_shadowmap_target(node, scale, '2')
|
||||
# render_targets.append(target)
|
||||
# break
|
||||
# Clamp omni-shadows, remove
|
||||
# if lamp.lamp_omni_shadows:
|
||||
# bpy.data.worlds['Arm'].rp_defs += '_Clampstc'
|
||||
|
||||
elif node.bl_idname == 'ImageNodeType' or node.bl_idname == 'Image3DNodeType':
|
||||
# Target already exists
|
||||
|
|
|
@ -272,9 +272,10 @@ def make_forward_base(con_mesh, parse_opacity=False):
|
|||
is_pcss = False
|
||||
|
||||
frag.write('float visibility = 1.0;')
|
||||
frag.write('vec3 lp = lightPos - wposition;')
|
||||
frag.write('vec3 l;')
|
||||
frag.write('if (lightType == 0) l = lightDir;')
|
||||
frag.write('else { l = normalize(lightPos - wposition); visibility *= attenuate(distance(wposition, lightPos)); }')
|
||||
frag.write('else { l = normalize(lp); visibility *= attenuate(distance(wposition, lightPos)); }')
|
||||
frag.write('vec3 h = normalize(vVec + l);')
|
||||
frag.write('float dotNL = dot(n, l);')
|
||||
frag.write('float dotNH = dot(n, h);')
|
||||
|
@ -284,11 +285,13 @@ def make_forward_base(con_mesh, parse_opacity=False):
|
|||
if tese != None:
|
||||
tese.add_out('vec4 lampPos')
|
||||
tese.add_uniform('mat4 LVP', '_biasLampViewProjectionMatrix')
|
||||
tese.write('lampPos = LVP * vec4(wposition, 1.0);')
|
||||
tese.add_uniform('int lightShadow', '_lampCastShadow')
|
||||
tese.write('if (lightShadow == 1) lampPos = LVP * vec4(wposition, 1.0);')
|
||||
else:
|
||||
vert.add_out('vec4 lampPos')
|
||||
vert.add_uniform('mat4 LWVP', '_biasLampWorldViewProjectionMatrix')
|
||||
vert.write('lampPos = LWVP * spos;')
|
||||
vert.add_uniform('int lightShadow', '_lampCastShadow')
|
||||
vert.write('if (lightShadow == 1) lampPos = LWVP * spos;')
|
||||
|
||||
if is_pcss:
|
||||
frag.add_include('../../Shaders/std/shadows_pcss.glsl')
|
||||
|
@ -297,18 +300,22 @@ def make_forward_base(con_mesh, parse_opacity=False):
|
|||
else:
|
||||
frag.add_include('../../Shaders/std/shadows.glsl')
|
||||
frag.add_uniform('sampler2D shadowMap', included=True)
|
||||
frag.add_uniform('sampler2D shadowMapCube', included=True)
|
||||
frag.add_uniform('bool receiveShadow')
|
||||
frag.add_uniform('float shadowsBias', '_lampShadowsBias')
|
||||
frag.add_uniform('int lightShadow', '_lampCastShadow')
|
||||
frag.add_uniform('vec2 lightPlane', '_lampPlane')
|
||||
|
||||
frag.write('if (receiveShadow && lampPos.w > 0.0) {')
|
||||
frag.tab += 1
|
||||
frag.write('vec3 lpos = lampPos.xyz / lampPos.w;')
|
||||
frag.write('if (receiveShadow) {')
|
||||
frag.write(' if (lightShadow == 1 && lampPos.w > 0.0) {')
|
||||
frag.write(' vec3 lpos = lampPos.xyz / lampPos.w;')
|
||||
# frag.write('float bias = clamp(shadowsBias * 1.0 * tan(acos(clamp(dotNL, 0.0, 1.0))), 0.0, 0.01);')
|
||||
if is_pcss:
|
||||
frag.write('visibility *= PCSS(lpos.xy, lpos.z - shadowsBias);')
|
||||
frag.write(' visibility *= PCSS(lpos.xy, lpos.z - shadowsBias);')
|
||||
else:
|
||||
frag.write('visibility *= PCF(lpos.xy, lpos.z - shadowsBias);')
|
||||
frag.tab -= 1
|
||||
frag.write(' visibility *= PCF(lpos.xy, lpos.z - shadowsBias);')
|
||||
frag.write(' }')
|
||||
frag.write(' else if (lightShadow == 2) visibility *= PCFCube(lp, -l, shadowsBias, lightPlane);')
|
||||
frag.write('}')
|
||||
|
||||
frag.write('if (lightType == 2) {')
|
||||
|
|
|
@ -522,20 +522,11 @@ def init_properties_on_save():
|
|||
wrd.arm_project_scene = bpy.data.scenes[0].name
|
||||
# Switch to Cycles
|
||||
for scene in bpy.data.scenes:
|
||||
# if scene.render.engine != 'CYCLES':
|
||||
# scene.render.engine = 'CYCLES'
|
||||
scene.render.fps = 60 # Default to 60fps for chromium update loop
|
||||
scene.render.fps = 60 # Default to 60fps
|
||||
# Force camera far to at least 200 units for now, to prevent fighting with light far plane
|
||||
for c in bpy.data.cameras:
|
||||
if c.clip_end < 200:
|
||||
c.clip_end = 200
|
||||
# Move default lamp a little further to keep fov low for now
|
||||
if 'Lamp' in bpy.data.objects:
|
||||
loc = bpy.data.objects['Lamp'].location
|
||||
if int(loc.x) == 4 and int(loc.y) == 1 and int(loc.z) == 5:
|
||||
loc.x = 11.0
|
||||
loc.y = 4.0
|
||||
loc.z = 16.0
|
||||
# Use nodes
|
||||
for w in bpy.data.worlds:
|
||||
w.use_nodes = True
|
||||
|
@ -545,7 +536,6 @@ def init_properties_on_save():
|
|||
l.use_nodes = True
|
||||
for m in bpy.data.materials:
|
||||
m.use_nodes = True
|
||||
|
||||
init_properties_on_load()
|
||||
|
||||
def init_properties_on_load():
|
||||
|
|
Loading…
Reference in a new issue