Faster conetrace

This commit is contained in:
Lubos Lenco 2017-05-11 23:08:47 +02:00
parent 5ab704852d
commit d75d6dc849
2 changed files with 3 additions and 16 deletions

View file

@ -80,7 +80,7 @@ void main() {
fragColor.rgb = indirectDiffuse.rgb * 1.3 * albedo + indirectSpecular;
// fragColor.rgb = max(vec3(1.0 - (indirectDiffuse.a / 2.0)), 0.05) * albedo;
fragColor.rgb *= 1.0 - (indirectDiffuse.a / 2.2); // Occ
fragColor.rgb *= 1.0 - indirectDiffuse.a; // Occ
fragColor.rgb *= texture(ssaotex, texCoord).r * 0.5 + 0.5;
// if (opacity < 1.0) fragColor.rgb = mix(indirectRefractiveLight(-v), fragColor.rgb); // Transparency

View file

@ -21,7 +21,7 @@ vec4 traceDiffuseVoxelCone(const vec3 from, vec3 direction) {
vec4 acc = vec4(0.0);
// Controls bleeding from close surfaces
// Low values look rather bad if using shadow cone tracing
float dist = 0.1953125;
float dist = 0.1953125 / 9.0;
const float SQRT2 = 1.414213;
while (dist < SQRT2 && acc.a < 1.0) {
vec3 c = vec3(from + dist * direction) * 0.5 + vec3(0.5);
@ -33,21 +33,8 @@ vec4 traceDiffuseVoxelCone(const vec3 from, vec3 direction) {
dist += ll * VOXEL_SIZE * 2.0;
}
vec4 occ = vec4(0.0);
dist = 0.1953125 / 9.0;
const float SQRT2a = 1.414213 / 9.0;
while (dist < SQRT2a && acc.a < 1.0) {
vec3 c = vec3(from + dist * direction) * 0.5 + vec3(0.5);
float l = (1.0 + CONE_SPREAD * dist / VOXEL_SIZE);
float level = log2(l);
float ll = (level + 1.0) * (level + 1.0);
vec4 voxel = textureLod(voxels, c, min(MAX_MIPMAP, level));
occ += 0.075 * ll * voxel * pow(1.0 - voxel.a, 2.0);
dist += ll * VOXEL_SIZE * 2.0;
}
acc.rgb = pow(acc.rgb * 2.0, vec3(1.5));
acc.a = occ.a;
acc.a /= 3.8;
return acc;
}