Deferred renderer: ssao tweaks

This commit is contained in:
Nikita Lisitsa 2020-12-13 18:37:57 +03:00
parent 953544718c
commit deba82adee

View file

@ -635,7 +635,7 @@ uniform vec2 u_ssao_rotation_step;
uniform float u_ssao_radius; uniform float u_ssao_radius;
uniform vec3 u_ssao_kernel[16]; uniform vec3 u_ssao_kernel[32];
uniform mat4 u_view; uniform mat4 u_view;
uniform mat4 u_transform; uniform mat4 u_transform;
@ -659,7 +659,7 @@ void main()
mat3 tbn = mat3(tangent, bitangent, normal); mat3 tbn = mat3(tangent, bitangent, normal);
float occlusion = 0.0; float occlusion = 0.0;
for (int i = 0; i < 16; ++i) for (int i = 0; i < 32; ++i)
{ {
vec3 sample = position + (tbn * u_ssao_kernel[i]) * u_ssao_radius; vec3 sample = position + (tbn * u_ssao_kernel[i]) * u_ssao_radius;
@ -672,7 +672,7 @@ void main()
float w = length(pos - position) / u_ssao_radius; float w = length(pos - position) / u_ssao_radius;
if (w <= 1.0 && dot(pos - position, normal) >= 0.f && (u_view * vec4(pos, 1.0)).z > (u_view * vec4(sample, 1.0)).z) if (w <= 1.0 && dot(pos - position, normal) >= 0.f && (u_view * vec4(pos, 1.0)).z > (u_view * vec4(sample, 1.0)).z)
occlusion += 1.0 / 16.0; occlusion += 1.0 / 32.0;
} }
out_color = vec4(1.0 - occlusion); out_color = vec4(1.0 - occlusion);
@ -840,8 +840,8 @@ void main()
gfx::framebuffer ssao_framebuffer[3]; gfx::framebuffer ssao_framebuffer[3];
gfx::texture_2d ssao_texture[3]; gfx::texture_2d ssao_texture[3];
hblur ssao_hblur{2, 2.f}; hblur ssao_hblur{5, 2.f};
vblur ssao_vblur{2, 2.f}; vblur ssao_vblur{5, 2.f};
gfx::mesh screen_mesh; gfx::mesh screen_mesh;
@ -904,7 +904,7 @@ void main()
{ {
random::uniform_hemiball_vector_distribution<float, 3> d{geom::vector{0.f, 0.f, 1.f}}; random::uniform_hemiball_vector_distribution<float, 3> d{geom::vector{0.f, 0.f, 1.f}};
std::vector<geom::vector<float, 3>> ssao_kernel(16); std::vector<geom::vector<float, 3>> ssao_kernel(32);
for (auto & v : ssao_kernel) for (auto & v : ssao_kernel)
v = d(rng); v = d(rng);