Skip to content

Commit

Permalink
UPBGE: Simplify texture blurring.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
panzergame committed Aug 16, 2018
1 parent 9fb0a3b commit f1e625c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
17 changes: 5 additions & 12 deletions source/blender/gpu/intern/gpu_framebuffer.c
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -567,6 +558,8 @@ void GPU_framebuffer_blur(

GPU_texture_unbind(blurtex);
GPU_shader_unbind();

glEnable(GL_DEPTH_TEST);
}

/* GPURenderBuffer */
Expand Down
@@ -1,6 +1,5 @@

void main()
{
gl_Position = ftransform();
gl_Position = gl_Vertex;
gl_TexCoord[0] = gl_MultiTexCoord0;
}

0 comments on commit f1e625c

Please sign in to comment.