diff options
Diffstat (limited to 'source/blender/gpu/intern/gpu_pbr.c')
-rw-r--r-- | source/blender/gpu/intern/gpu_pbr.c | 59 |
1 files changed, 50 insertions, 9 deletions
diff --git a/source/blender/gpu/intern/gpu_pbr.c b/source/blender/gpu/intern/gpu_pbr.c index bc244941bd8..17d2d4da99b 100644 --- a/source/blender/gpu/intern/gpu_pbr.c +++ b/source/blender/gpu/intern/gpu_pbr.c @@ -43,6 +43,7 @@ #include "GPU_texture.h" #include "GPU_framebuffer.h" #include "GPU_pbr.h" +#include "GPU_draw.h" #include "gpu_codegen.h" @@ -54,6 +55,10 @@ void GPU_scenebuf_free(GPUScreenBuffer *buf) { + if (buf->fb) { + GPU_framebuffer_free(buf->fb); + buf->fb = NULL; + } if (buf->tex) { GPU_texture_free(buf->tex); buf->tex = NULL; @@ -62,9 +67,9 @@ void GPU_scenebuf_free(GPUScreenBuffer *buf) GPU_texture_free(buf->depth); buf->depth = NULL; } - if (buf->fb) { - GPU_framebuffer_free(buf->fb); - buf->fb = NULL; + if (buf->downsamplingfb) { + GPU_framebuffer_free(buf->downsamplingfb); + buf->downsamplingfb = NULL; } MEM_freeN(buf); @@ -76,7 +81,7 @@ static GPUScreenBuffer *gpu_scenebuf_create(int width, int height, bool depth_on buf->w = width; buf->h = height; - buf->tex = NULL; + buf->depth = NULL; buf->fb = GPU_framebuffer_create(); if (!buf->fb) { @@ -84,6 +89,13 @@ static GPUScreenBuffer *gpu_scenebuf_create(int width, int height, bool depth_on return NULL; } + /* DOWNSAMPLING FB */ + buf->downsamplingfb = GPU_framebuffer_create(); + if (!buf->downsamplingfb) { + GPU_scenebuf_free(buf); + return NULL; + } + if (depth_only) { buf->tex = GPU_texture_create_depth(width, height, NULL); if (!buf->tex) { @@ -95,6 +107,12 @@ static GPUScreenBuffer *gpu_scenebuf_create(int width, int height, bool depth_on GPU_scenebuf_free(buf); return NULL; } + + /* check validity at the very end! */ + if (!GPU_framebuffer_check_valid(buf->fb, NULL)) { + GPU_scenebuf_free(buf); + return NULL; + } } else { buf->depth = GPU_texture_create_depth(width, height, NULL); @@ -118,13 +136,14 @@ static GPUScreenBuffer *gpu_scenebuf_create(int width, int height, bool depth_on GPU_scenebuf_free(buf); return NULL; } + + /* check validity at the very end! */ + if (!GPU_framebuffer_check_valid(buf->fb, NULL)) { + GPU_scenebuf_free(buf); + return NULL; + } } - /* check validity at the very end! */ - if (!GPU_framebuffer_check_valid(buf->fb, NULL)) { - GPU_scenebuf_free(buf); - return NULL; - } GPU_framebuffer_restore(); @@ -195,6 +214,28 @@ void GPU_scenebuf_unbind(GPUScreenBuffer* buf) glEnable(GL_SCISSOR_TEST); } +void GPU_scenebuf_filter_texture(GPUScreenBuffer* buf) +{ + return; + /* MinZ Pyramid for depth */ + if (buf->depth) { + GPU_texture_bind(buf->depth, 0); + GPU_generate_mipmap(GL_TEXTURE_2D); + GPU_texture_unbind(buf->depth); + GPU_framebuffer_hiz_construction(buf->downsamplingfb, buf->depth, false); + GPU_framebuffer_texture_attach(buf->fb, buf->depth, 0, NULL); + } + else { + GPU_texture_bind(buf->tex, 0); + GPU_generate_mipmap(GL_TEXTURE_2D); + GPU_texture_unbind(buf->tex); + GPU_framebuffer_hiz_construction(buf->downsamplingfb, buf->tex, true); + GPU_framebuffer_texture_attach(buf->fb, buf->tex, 0, NULL); + } + + GPU_framebuffer_restore(); +} + /* PBR core */ GPUPBR *GPU_pbr_create(void) |