From f1e625c6b495514a2b0e5e94a5f73c4a7218c3f0 Mon Sep 17 00:00:00 2001 From: Porteries Tristan Date: Thu, 16 Aug 2018 14:47:24 +0200 Subject: [PATCH] UPBGE: Simplify texture blurring. The shader used to blur a texture was using ftransform for gl_Position and so it needed the modelview/prjection matrix to be set. This can be avoided by using gl_Vertex directly. --- source/blender/gpu/intern/gpu_framebuffer.c | 17 +++++------------ .../gpu_shader_sep_gaussian_blur_vert.glsl | 3 +-- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/source/blender/gpu/intern/gpu_framebuffer.c b/source/blender/gpu/intern/gpu_framebuffer.c index cce9a6f2fc71..3cf396a003e5 100644 --- a/source/blender/gpu/intern/gpu_framebuffer.c +++ b/source/blender/gpu/intern/gpu_framebuffer.c @@ -523,21 +523,12 @@ void GPU_framebuffer_blur( GPU_shader_bind(blur_shader); GPU_shader_uniform_vector(blur_shader, scale_uniform, 2, 1, scaleh); + GPU_texture_bind(tex, 0); GPU_shader_uniform_texture(blur_shader, texture_source_uniform, tex); glViewport(0, 0, GPU_texture_width(blurtex), GPU_texture_height(blurtex)); - /* Preparing to draw quad */ - glMatrixMode(GL_TEXTURE); - glLoadIdentity(); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - glDisable(GL_DEPTH_TEST); - GPU_texture_bind(tex, 0); - /* Drawing quad */ glBegin(GL_QUADS); glTexCoord2d(0, 0); glVertex2f(1, 1); @@ -553,10 +544,10 @@ void GPU_framebuffer_blur( GG.currentfb = fb->object; - glViewport(0, 0, GPU_texture_width(tex), GPU_texture_height(tex)); GPU_shader_uniform_vector(blur_shader, scale_uniform, 2, 1, scalev); - GPU_shader_uniform_texture(blur_shader, texture_source_uniform, blurtex); GPU_texture_bind(blurtex, 0); + GPU_shader_uniform_texture(blur_shader, texture_source_uniform, blurtex); + glViewport(0, 0, GPU_texture_width(tex), GPU_texture_height(tex)); glBegin(GL_QUADS); glTexCoord2d(0, 0); glVertex2f(1, 1); @@ -567,6 +558,8 @@ void GPU_framebuffer_blur( GPU_texture_unbind(blurtex); GPU_shader_unbind(); + + glEnable(GL_DEPTH_TEST); } /* GPURenderBuffer */ diff --git a/source/blender/gpu/shaders/gpu_shader_sep_gaussian_blur_vert.glsl b/source/blender/gpu/shaders/gpu_shader_sep_gaussian_blur_vert.glsl index 5d00108b052b..a8fb0cf5e28d 100644 --- a/source/blender/gpu/shaders/gpu_shader_sep_gaussian_blur_vert.glsl +++ b/source/blender/gpu/shaders/gpu_shader_sep_gaussian_blur_vert.glsl @@ -1,6 +1,5 @@ - void main() { - gl_Position = ftransform(); + gl_Position = gl_Vertex; gl_TexCoord[0] = gl_MultiTexCoord0; }