diff --git a/leenkx/blender/lnx/material/make_mesh.py b/leenkx/blender/lnx/material/make_mesh.py index d4088e5..b021ee7 100644 --- a/leenkx/blender/lnx/material/make_mesh.py +++ b/leenkx/blender/lnx/material/make_mesh.py @@ -685,8 +685,10 @@ def make_forward_base(con_mesh, parse_opacity=False, transluc_pass=False): if '_VoxelGI' in wrd.world_defs: if parse_opacity: frag.write('indirect = traceDiffuse(wposition, n, voxels, clipmaps).rgb * albedo * voxelgiDiff;') - frag.write('if (roughness < 1.0 && specular > 0.0)') - frag.write(' indirect += traceSpecular(wposition, n, voxels, voxelsSDF, normalize(eye - wposition), roughness, clipmaps, gl_FragCoord.xy).rgb * specular * voxelgiRefl;') + 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, normalize(eye - wposition), roughness, clipmaps, gl_FragCoord.xy, velocity).rgb * specular * voxelgiRefl;}') else: frag.add_uniform("sampler2D voxels_diffuse") frag.add_uniform("sampler2D voxels_specular") @@ -792,12 +794,10 @@ 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('vec3 refraction = traceRefraction(wposition, n, voxels, voxelsSDF, normalize(eye - wposition), ior, roughness, clipmaps, gl_FragCoord.xy).rgb;') + frag.write(' vec2 velocity = -textureLod(sveloc, gl_FragCoord.xy, 0.0).rg;') + frag.write(' vec3 refraction = traceRefraction(wposition, n, voxels, voxelsSDF, normalize(eye - wposition), 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, texCoord).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):