Skip to content

Commit f1e625c

Browse files
committed
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.
1 parent 9fb0a3b commit f1e625c

File tree

2 files changed

+6
-14
lines changed

2 files changed

+6
-14
lines changed

source/blender/gpu/intern/gpu_framebuffer.c

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -523,21 +523,12 @@ void GPU_framebuffer_blur(
523523

524524
GPU_shader_bind(blur_shader);
525525
GPU_shader_uniform_vector(blur_shader, scale_uniform, 2, 1, scaleh);
526+
GPU_texture_bind(tex, 0);
526527
GPU_shader_uniform_texture(blur_shader, texture_source_uniform, tex);
527528
glViewport(0, 0, GPU_texture_width(blurtex), GPU_texture_height(blurtex));
528529

529-
/* Preparing to draw quad */
530-
glMatrixMode(GL_TEXTURE);
531-
glLoadIdentity();
532-
glMatrixMode(GL_PROJECTION);
533-
glLoadIdentity();
534-
glMatrixMode(GL_MODELVIEW);
535-
glLoadIdentity();
536-
537530
glDisable(GL_DEPTH_TEST);
538531

539-
GPU_texture_bind(tex, 0);
540-
541532
/* Drawing quad */
542533
glBegin(GL_QUADS);
543534
glTexCoord2d(0, 0); glVertex2f(1, 1);
@@ -553,10 +544,10 @@ void GPU_framebuffer_blur(
553544

554545
GG.currentfb = fb->object;
555546

556-
glViewport(0, 0, GPU_texture_width(tex), GPU_texture_height(tex));
557547
GPU_shader_uniform_vector(blur_shader, scale_uniform, 2, 1, scalev);
558-
GPU_shader_uniform_texture(blur_shader, texture_source_uniform, blurtex);
559548
GPU_texture_bind(blurtex, 0);
549+
GPU_shader_uniform_texture(blur_shader, texture_source_uniform, blurtex);
550+
glViewport(0, 0, GPU_texture_width(tex), GPU_texture_height(tex));
560551

561552
glBegin(GL_QUADS);
562553
glTexCoord2d(0, 0); glVertex2f(1, 1);
@@ -567,6 +558,8 @@ void GPU_framebuffer_blur(
567558

568559
GPU_texture_unbind(blurtex);
569560
GPU_shader_unbind();
561+
562+
glEnable(GL_DEPTH_TEST);
570563
}
571564

572565
/* GPURenderBuffer */
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
21
void main()
32
{
4-
gl_Position = ftransform();
3+
gl_Position = gl_Vertex;
54
gl_TexCoord[0] = gl_MultiTexCoord0;
65
}

0 commit comments

Comments
 (0)