forked from LeenkxTeam/LNXSDK
Consolidate and update
This commit is contained in:
@ -398,11 +398,14 @@ def make_forward_mobile(con_mesh):
|
||||
return
|
||||
|
||||
is_shadows = '_ShadowMap' in wrd.world_defs
|
||||
is_transparent_shadows = '_ShadowMapTransparent' in wrd.world_defs
|
||||
is_shadows_atlas = '_ShadowMapAtlas' in wrd.world_defs
|
||||
shadowmap_sun = 'shadowMap'
|
||||
shadowmap_sun_tr = 'shadowMapTransparent'
|
||||
if is_shadows_atlas:
|
||||
is_single_atlas = '_SingleAtlas' in wrd.world_defs
|
||||
shadowmap_sun = 'shadowMapAtlasSun' if not is_single_atlas else 'shadowMapAtlas'
|
||||
shadowmap_sun_tr = 'shadowMapAtlasSunTransparent' if not is_single_atlas else 'shadowMapAtlasTransparent'
|
||||
frag.add_uniform('vec2 smSizeUniform', '_shadowMapSize', included=True)
|
||||
frag.write('vec3 direct = vec3(0.0);')
|
||||
|
||||
@ -417,6 +420,8 @@ def make_forward_mobile(con_mesh):
|
||||
vert.write('lightPosition = LWVP * spos;')
|
||||
frag.add_uniform('bool receiveShadow')
|
||||
frag.add_uniform(f'sampler2DShadow {shadowmap_sun}')
|
||||
if is_transparent_shadows:
|
||||
frag.add_uniform(f'sampler2D {shadowmap_sun_tr}')
|
||||
frag.add_uniform('float shadowsBias', '_sunShadowsBias')
|
||||
|
||||
frag.write('if (receiveShadow) {')
|
||||
@ -427,14 +432,20 @@ def make_forward_mobile(con_mesh):
|
||||
if is_shadows_atlas:
|
||||
frag.add_uniform('vec4 tileBoundsSunArray[maxLights * shadowmapCascades]', '_tileBoundsSunArray', included=True)
|
||||
frag.write('tileBounds = tileBoundsSunArray[0];')
|
||||
frag.write(f'svisibility = shadowTestCascade({shadowmap_sun}, eye, wposition + n * shadowsBias * 10, shadowsBias, opacity != 1.0);')
|
||||
frag.write(f'svisibility = shadowTestCascade({shadowmap_sun},')
|
||||
if is_transparent_shadows:
|
||||
frag.write(f'{shadowmap_sun_tr},')
|
||||
frag.write('eye, wposition + n * shadowsBias * 10, shadowsBias')
|
||||
if is_transparent_shadows:
|
||||
frag.write(', opacity != 1.0')
|
||||
frag.write(');')
|
||||
else:
|
||||
frag.write('if (lightPosition.w > 0.0) {')
|
||||
frag.write(' vec3 lPos = lightPosition.xyz / lightPosition.w;')
|
||||
if '_Legacy' in wrd.world_defs:
|
||||
frag.write(f' svisibility = float(texture({shadowmap_sun}, vec2(lPos.xy)).r > lPos.z - shadowsBias, opacity != 1.0);')
|
||||
frag.write(f' svisibility = vec3(float(texture({shadowmap_sun}, vec2(lPos.xy)).r > lPos.z - shadowsBias));')
|
||||
else:
|
||||
frag.write(f' svisibility = texture({shadowmap_sun}, vec3(lPos.xy, lPos.z - shadowsBias), opacity != 1.0).r;')
|
||||
frag.write(f' svisibility = vec3(texture({shadowmap_sun}, vec3(lPos.xy, lPos.z - shadowsBias)).r);')
|
||||
frag.write('}')
|
||||
frag.write('}') # receiveShadow
|
||||
frag.write('direct += basecol * sdotNL * sunCol * svisibility;')
|
||||
|
||||
Reference in New Issue
Block a user