diff options
author | Juan Linietsky <reduzio@gmail.com> | 2017-08-29 11:46:02 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2017-08-29 11:46:02 -0300 |
commit | e8b05ca996baa9819f55fc1d190a79d24906bde7 (patch) | |
tree | 422acbb72c190d83f6a5055478c560ae595517ab /drivers | |
parent | 089cf8176e225f0eee111e835a53c0245674c229 (diff) |
-Fixed screen edge SSAO filter, fixes #9678
-Raised the SSAO limits, making the effect a lot more useful
-Still pending to enable tresholding to avoid some hollow places
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/gles3/rasterizer_scene_gles3.cpp | 2 | ||||
-rw-r--r-- | drivers/gles3/shaders/ssao_blur.glsl | 7 |
2 files changed, 7 insertions, 2 deletions
diff --git a/drivers/gles3/rasterizer_scene_gles3.cpp b/drivers/gles3/rasterizer_scene_gles3.cpp index 9c7a1dd859..f4dd9682a1 100644 --- a/drivers/gles3/rasterizer_scene_gles3.cpp +++ b/drivers/gles3/rasterizer_scene_gles3.cpp @@ -3259,6 +3259,8 @@ void RasterizerSceneGLES3::_render_mrts(Environment *env, const CameraMatrix &p_ state.ssao_blur_shader.set_uniform(SsaoBlurShaderGLES3::CAMERA_Z_NEAR, p_cam_projection.get_z_near()); GLint axis[2] = { i, 1 - i }; glUniform2iv(state.ssao_blur_shader.get_uniform(SsaoBlurShaderGLES3::AXIS), 1, axis); + glUniform2iv(state.ssao_blur_shader.get_uniform(SsaoBlurShaderGLES3::SCREEN_SIZE), 1, ss); + glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, storage->frame.current_rt->effects.ssao.blur_red[i]); glActiveTexture(GL_TEXTURE1); diff --git a/drivers/gles3/shaders/ssao_blur.glsl b/drivers/gles3/shaders/ssao_blur.glsl index ce4154f50c..c7c978dc37 100644 --- a/drivers/gles3/shaders/ssao_blur.glsl +++ b/drivers/gles3/shaders/ssao_blur.glsl @@ -56,6 +56,8 @@ uniform ivec2 axis; uniform float camera_z_far; uniform float camera_z_near; +uniform ivec2 screen_size; + void main() { ivec2 ssC = ivec2(gl_FragCoord.xy); @@ -83,6 +85,7 @@ void main() { float totalWeight = BASE; sum *= totalWeight; + ivec2 clamp_limit = screen_size - ivec2(1); for (int r = -R; r <= R; ++r) { // We already handled the zero case above. This loop should be unrolled and the static branch optimized out, @@ -90,8 +93,8 @@ void main() { if (r != 0) { ivec2 ppos = ssC + axis * (r * SCALE); - float value = texelFetch(source_ssao, ppos, 0).r; - float temp_depth = texelFetch(source_depth, ssC, 0).r; + float value = texelFetch(source_ssao, clamp(ppos,ivec2(0),clamp_limit), 0).r; + float temp_depth = texelFetch(source_depth, clamp(ssC,ivec2(0),clamp_limit), 0).r; temp_depth = temp_depth * 2.0 - 1.0; temp_depth = 2.0 * camera_z_near * camera_z_far / (camera_z_far + camera_z_near - temp_depth * (camera_z_far - camera_z_near)); |