forked from LeenkxTeam/LNXSDK
Scaled slope bias and transparent shadows fixes
This commit is contained in:
@ -43,7 +43,7 @@ def make(context_id, rpasses, shadowmap=False, shadowmap_transparent=False):
|
||||
'name': context_id,
|
||||
'vertex_elements': vs,
|
||||
'depth_write': False,
|
||||
'depth_read': True,
|
||||
'depth_read': False,
|
||||
'compare_mode': 'less',
|
||||
'cull_mode': 'clockwise',
|
||||
'blend_source': 'blend_zero',
|
||||
@ -241,6 +241,7 @@ def make(context_id, rpasses, shadowmap=False, shadowmap_transparent=False):
|
||||
vert.add_out('vec4 wvpposition')
|
||||
vert.write('wvpposition = gl_Position;')
|
||||
frag.write('float depth = (wvpposition.z / wvpposition.w) * 0.5 + 0.5;')
|
||||
frag.write('depth += 0.00002 + min(max(abs(dFdx(gl_FragCoord.z)), abs(dFdy(gl_FragCoord.z))), 0.0005);')
|
||||
frag.write('vec3 color = mix(vec3(1.0), basecol, opacity);')
|
||||
frag.write('fragColor = vec4(color, depth);')
|
||||
|
||||
@ -248,12 +249,16 @@ def make(context_id, rpasses, shadowmap=False, shadowmap_transparent=False):
|
||||
if mat_state.material.lnx_discard:
|
||||
opac = mat_state.material.lnx_discard_opacity_shadows
|
||||
frag.write('if (opacity < {0}) discard;'.format(opac))
|
||||
elif rpdat.rp_renderer == 'Deferred' and 'translucent' in rpasses and not shadowmap:
|
||||
elif shadowmap or (rpdat.rp_renderer == 'Deferred' and 'translucent' in rpasses):
|
||||
pass
|
||||
else:
|
||||
opac = '1.0'
|
||||
frag.write('if (opacity < {0}) discard;'.format(opac))
|
||||
|
||||
if shadowmap and not shadowmap_transparent:
|
||||
frag.write('vec2 sdz = vec2(dFdx(gl_FragCoord.z), dFdy(gl_FragCoord.z));')
|
||||
frag.write('gl_FragDepth = gl_FragCoord.z + (0.00002 + min(max(abs(sdz.x), abs(sdz.y)), 0.0005)) * float(gl_FragCoord.w == 1.0);')
|
||||
|
||||
make_finalize.make(con_depth)
|
||||
|
||||
assets.vs_equal(con_depth, assets.shader_cons['depth_vert'])
|
||||
|
||||
Reference in New Issue
Block a user