rt: make indirect light run at half res
This commit is contained in:
parent
218bd0a9c2
commit
64ac964dfc
|
@ -164,9 +164,11 @@ void computeBounce(ivec2 pix, vec3 direction, out vec3 diffuse, out vec3 specula
|
|||
}
|
||||
}
|
||||
|
||||
const int INDIRECT_SCALE = 2;
|
||||
|
||||
void main() {
|
||||
const ivec2 pix = ivec2(gl_GlobalInvocationID);
|
||||
const ivec2 res = ivec2(imageSize(out_indirect_diffuse));
|
||||
const ivec2 res = ivec2(imageSize(out_indirect_diffuse)) / INDIRECT_SCALE;
|
||||
if (any(greaterThanEqual(pix, res))) {
|
||||
return;
|
||||
}
|
||||
|
@ -179,7 +181,7 @@ void main() {
|
|||
rand01_state = ubo.ubo.random_seed + pix.x * 1833 + pix.y * 31337 + 12;
|
||||
|
||||
vec3 diffuse, specular;
|
||||
computeBounce(pix, direction, diffuse, specular);
|
||||
computeBounce(pix * INDIRECT_SCALE, direction, diffuse, specular);
|
||||
imageStore(out_indirect_diffuse, pix, vec4(diffuse, 0.f));
|
||||
imageStore(out_indirect_specular, pix, vec4(specular, 0.f));
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@ layout(set = 0, binding = 15, rgba16f) uniform image2D prev_temporal_diffuse;
|
|||
layout(set = 0, binding = 16, rgba16f) uniform image2D out_temporal_specular;
|
||||
layout(set = 0, binding = 17, rgba16f) uniform image2D prev_temporal_specular;
|
||||
|
||||
const int INDIRECT_SCALE = 2;
|
||||
|
||||
//layout(set = 0, binding = 2, rgba16f) uniform readonly image2D light_poly_diffuse;
|
||||
/* layout(set = 0, binding = 3, rgba16f) uniform readonly image2D specular; */
|
||||
|
@ -102,6 +103,7 @@ Components blurSamples(const ivec2 res, const ivec2 pix) {
|
|||
float indirect_diffuse_total = 0.;
|
||||
float specular_total = 0.;
|
||||
|
||||
const ivec2 res_scaled = res / INDIRECT_SCALE;
|
||||
for (int x = -KERNEL_SIZE; x <= KERNEL_SIZE; ++x)
|
||||
for (int y = -KERNEL_SIZE; y <= KERNEL_SIZE; ++y) {
|
||||
const ivec2 p = pix + ivec2(x, y);
|
||||
|
@ -122,7 +124,7 @@ Components blurSamples(const ivec2 res, const ivec2 pix) {
|
|||
|
||||
const vec4 sample_pos = imageLoad(position_t, p);
|
||||
// FIXME what are these magic numbers?
|
||||
scale *= smoothstep(4. * center_pos.w / 100., 0., distance(center_pos.xyz, sample_pos.xyz));
|
||||
scale *= smoothstep(center_pos.w * 4. / 100., 0., distance(center_pos.xyz, sample_pos.xyz));
|
||||
|
||||
if ( scale <= 0. )
|
||||
continue;
|
||||
|
@ -138,10 +140,14 @@ Components blurSamples(const ivec2 res, const ivec2 pix) {
|
|||
|
||||
if (all(lessThan(abs(ivec2(x, y)), ivec2(INDIRECT_DIFFUSE_KERNEL))))
|
||||
{
|
||||
const float indirect_diffuse_scale = scale * normpdf(x, indirect_diffuse_sigma) * normpdf(y, indirect_diffuse_sigma);
|
||||
indirect_diffuse_total += indirect_diffuse_scale;
|
||||
const ivec2 pscaled = pix / INDIRECT_SCALE + ivec2(x, y);
|
||||
|
||||
c.indirect_diffuse += imageLoad(indirect_diffuse, p).rgb * indirect_diffuse_scale;
|
||||
if (all(lessThan(pscaled, res_scaled)) && all(greaterThanEqual(pscaled, ivec2(0)))) {
|
||||
const float indirect_diffuse_scale = scale * normpdf(x, indirect_diffuse_sigma) * normpdf(y, indirect_diffuse_sigma);
|
||||
indirect_diffuse_total += indirect_diffuse_scale;
|
||||
|
||||
c.indirect_diffuse += imageLoad(indirect_diffuse, pscaled).rgb * indirect_diffuse_scale;
|
||||
}
|
||||
}
|
||||
|
||||
if (all(lessThan(abs(ivec2(x, y)), ivec2(SPECULAR_KERNEL))))
|
||||
|
@ -151,7 +157,8 @@ Components blurSamples(const ivec2 res, const ivec2 pix) {
|
|||
|
||||
c.direct_specular += imageLoad(light_poly_specular, p).rgb * specular_scale;
|
||||
c.direct_specular += imageLoad(light_point_specular, p).rgb * specular_scale;
|
||||
c.indirect_specular += imageLoad(indirect_specular, p).rgb * specular_scale;
|
||||
|
||||
c.indirect_specular += imageLoad(indirect_specular, p / INDIRECT_SCALE).rgb * specular_scale;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -194,6 +201,7 @@ void main() {
|
|||
//imageStore(out_dest, pix, vec4((imageLoad(light_poly, pix).rgb * base_color_a.rgb), 0.)); return;
|
||||
//imageStore(out_dest, pix, vec4(imageLoad(normals, pix)*.5 + .5f)); return;
|
||||
//imageStore(out_dest, pix, vec4(imageLoad(specular, pix)*.5 + .5f)); return;
|
||||
//imageStore(out_dest, pix, vec4(imageLoad(indirect_diffuse, pix)*.5 + .5f)); return;
|
||||
//imageStore(out_dest, pix, vec4(aces_tonemap(imageLoad(light_poly, pix).rgb), 0.)); return;
|
||||
//imageStore(out_dest, pix, vec4(aces_tonemap(imageLoad(specular, pix).rgb), 0.)); return;
|
||||
//imageStore(out_dest, pix, vec4(aces_tonemap(imageLoad(indirect_diffuse, pix).rgb), 0.)); return;
|
||||
|
@ -264,7 +272,7 @@ void main() {
|
|||
imageStore(out_temporal_specular, pix, vec4(specular, 0./*unused*/));
|
||||
colour = diffuse + specular;
|
||||
|
||||
//imageStore(out_dest, pix, vec4(LINEARtoSRGB(colour), 0.)); return;
|
||||
//imageStore(out_dest, pix, vec4(LINEARtoSRGB(diffuse), 0.)); return;
|
||||
}
|
||||
|
||||
const vec4 base_color_a = imageLoad(base_color_a, pix);
|
||||
|
|
Loading…
Reference in New Issue