Update leenkx/blender/lnx/material/make_mesh.py
This commit is contained in:
parent
4625fdb6b2
commit
9fa399371a
@ -609,9 +609,11 @@ def make_forward_base(con_mesh, parse_opacity=False, transluc_pass=False):
|
||||
frag.write_attrib('float dotNV = max(dot(n, vVec), 0.0);')
|
||||
|
||||
sh = tese if tese is not None else vert
|
||||
sh.add_uniform('mat4 W', '_worldMatrix')
|
||||
sh.write_attrib('vec3 wposition = vec4(W * spos).xyz;')
|
||||
sh.add_out('vec3 eyeDir')
|
||||
sh.add_uniform('vec3 eye', '_cameraPosition')
|
||||
sh.write('eyeDir = eye - spos.xyz;')
|
||||
sh.write('eyeDir = eye - wposition;')
|
||||
|
||||
frag.add_include('std/light.glsl')
|
||||
is_shadows = '_ShadowMap' in wrd.world_defs
|
||||
@ -666,17 +668,23 @@ def make_forward_base(con_mesh, parse_opacity=False, transluc_pass=False):
|
||||
frag.write('envl *= envmapStrength * occlusion;')
|
||||
|
||||
if '_VoxelAOvar' in wrd.world_defs or '_VoxelGI' in wrd.world_defs:
|
||||
if parse_opacity or '_VoxelShadow' in wrd.world_defs:
|
||||
frag.add_include('std/conetrace.glsl')
|
||||
frag.add_uniform('sampler3D voxels')
|
||||
frag.add_uniform('sampler3D voxelsSDF')
|
||||
frag.add_uniform('vec3 eye', "_cameraPosition")
|
||||
frag.add_uniform('vec3 eye', '_cameraPosition')
|
||||
frag.add_uniform('float clipmaps[10 * voxelgiClipmapCount]', '_clipmaps')
|
||||
vert.add_out('vec4 wvpposition')
|
||||
vert.write('wvpposition = gl_Position;')
|
||||
frag.write('vec2 texCoord = (wvpposition.xy / wvpposition.w) * 0.5 + 0.5;')
|
||||
|
||||
if '_VoxelAOvar' in wrd.world_defs and not parse_opacity:
|
||||
if '_VoxelGI' in wrd.world_defs or '_VoxelShadow' in wrd.world_defs or '_VoxelRefract' in wrd.world_defs:
|
||||
frag.add_uniform('sampler2D gbuffer2', included=True)
|
||||
frag.write('vec2 velocity = -textureLod(gbuffer2, gl_FragCoord.xy, 0.0).rg;')
|
||||
|
||||
if '_VoxelAOvar' in wrd.world_defs:
|
||||
if parse_opacity:
|
||||
frag.write('envl *= 1.0 - traceAO(wposition, n, voxels, clipmaps);')
|
||||
else:
|
||||
frag.add_uniform("sampler2D voxels_ao");
|
||||
frag.write('envl *= textureLod(voxels_ao, texCoord, 0.0).rrr;')
|
||||
|
||||
@ -687,12 +695,10 @@ def make_forward_base(con_mesh, parse_opacity=False, transluc_pass=False):
|
||||
|
||||
if '_VoxelGI' in wrd.world_defs:
|
||||
if parse_opacity:
|
||||
frag.write('vec4 trace = traceDiffuse(wposition, wnormal, voxels, clipmaps);')
|
||||
frag.write('indirect = ((trace.rgb * albedo + envl * (1.0 - trace.a)) * voxelgiDiff);')
|
||||
frag.write('vec4 indirect_diffuse = traceDiffuse(wposition, n, voxels, clipmaps);')
|
||||
frag.write('indirect = (indirect_diffuse.rgb * albedo + envl.rgb * (1.0 - indirect_diffuse.a)) * voxelgiDiff;')
|
||||
frag.write('if (roughness < 1.0 && specular > 0.0) {')
|
||||
frag.add_uniform('sampler2D sveloc')
|
||||
frag.write(' vec2 velocity = -textureLod(sveloc, gl_FragCoord.xy, 0.0).rg;')
|
||||
frag.write(' indirect += traceSpecular(wposition, n, voxels, voxelsSDF, vVec, roughness, clipmaps, gl_FragCoord.xy, velocity).rgb * specular * voxelgiRefl;}')
|
||||
frag.write(' indirect += traceSpecular(wposition, n, voxels, voxelsSDF, vVec, roughness * roughness, clipmaps, gl_FragCoord.xy, velocity).rgb * specular * voxelgiRefl; }')
|
||||
else:
|
||||
frag.add_uniform("sampler2D voxels_diffuse")
|
||||
frag.add_uniform("sampler2D voxels_specular")
|
||||
@ -746,7 +752,7 @@ def make_forward_base(con_mesh, parse_opacity=False, transluc_pass=False):
|
||||
else:
|
||||
frag.write(f'svisibility = PCF({shadowmap_sun}, {shadowmap_sun_tr}, lPos.xy, lPos.z - shadowsBias, smSize, false);')
|
||||
if '_VoxelShadow' in wrd.world_defs:
|
||||
frag.write('svisibility *= (1.0 - traceShadow(wposition, n, voxels, voxelsSDF, sunDir, clipmaps, gl_FragCoord.xy).r) * voxelgiShad;')
|
||||
frag.write('svisibility *= (1.0 - traceShadow(wposition, n, voxels, voxelsSDF, sunDir, clipmaps, gl_FragCoord.xy, velocity).r) * voxelgiShad;')
|
||||
frag.write('}') # receiveShadow
|
||||
frag.write('direct += (lambertDiffuseBRDF(albedo, sdotNL) + specularBRDF(f0, roughness, sdotNL, sdotNH, dotNV, sdotVH) * specular) * sunCol * svisibility;')
|
||||
# sun
|
||||
@ -784,10 +790,9 @@ def make_forward_base(con_mesh, parse_opacity=False, transluc_pass=False):
|
||||
if '_MicroShadowing' in wrd.world_defs:
|
||||
frag.write(', occlusion')
|
||||
if '_SSRS' in wrd.world_defs:
|
||||
frag.add_uniform('sampler2D gbufferD', top=True)
|
||||
frag.add_uniform('mat4 invVP', '_inverseViewProjectionMatrix')
|
||||
frag.add_uniform('vec3 eye', '_cameraPosition')
|
||||
frag.write(', gbufferD, invVP, eye')
|
||||
frag.write(', wposition.z, inVP, eye')
|
||||
frag.write(');')
|
||||
|
||||
if '_Clusters' in wrd.world_defs:
|
||||
@ -800,10 +805,9 @@ def make_forward_base(con_mesh, parse_opacity=False, transluc_pass=False):
|
||||
|
||||
if '_VoxelRefract' in wrd.world_defs and parse_opacity:
|
||||
frag.write('if (opacity < 1.0) {')
|
||||
frag.write(' vec2 velocity = -textureLod(sveloc, gl_FragCoord.xy, 0.0).rg;')
|
||||
frag.write(' vec3 refraction = traceRefraction(wposition, n, voxels, voxelsSDF, vVec, ior, roughness, clipmaps, gl_FragCoord.xy,velocity).rgb;')
|
||||
frag.write(' indirect = mix(refraction, indirect, opacity) * voxelgiRefr;')
|
||||
frag.write(' direct = mix(refraction, direct, opacity) * voxelgiRefr;')
|
||||
frag.write(' vec3 refraction = traceRefraction(wposition, n, voxels, voxelsSDF, vVec, ior, roughness, clipmaps, gl_FragCoord.xy, velocity, opacity).rgb * voxelgiRefr;')
|
||||
frag.write(' indirect = mix(refraction, indirect, opacity);')
|
||||
frag.write(' direct = mix(refraction, direct, opacity);')
|
||||
frag.write('}')
|
||||
|
||||
def _write_material_attribs_default(frag: shader.Shader, parse_opacity: bool):
|
||||
|
Loading…
x
Reference in New Issue
Block a user