[Bf-blender-cvs] [27fe02f] viewport_experiments: Intermediate commit.
Antony Riakiotakis
noreply at git.blender.org
Tue Jan 6 19:16:29 CET 2015
Commit: 27fe02f21379d23affff76feb19e1136abd5f7d8
Author: Antony Riakiotakis
Date: Tue Jan 6 19:16:06 2015 +0100
Branches: viewport_experiments
https://developer.blender.org/rB27fe02f21379d23affff76feb19e1136abd5f7d8
Intermediate commit.
Basically, we try to output coc values to a second render target, but
apparently OpenGL somehow hates us. Committing so that Mac may give a
better diagnostic on what is happening.
===================================================================
M source/blender/gpu/GPU_extensions.h
M source/blender/gpu/intern/gpu_compositing.c
M source/blender/gpu/intern/gpu_extensions.c
M source/blender/gpu/shaders/gpu_shader_fx_dof_high_frag.glsl
M source/blender/gpu/shaders/gpu_shader_fx_dof_high_vert.glsl
===================================================================
diff --git a/source/blender/gpu/GPU_extensions.h b/source/blender/gpu/GPU_extensions.h
index 5bc0762..42f8a95 100644
--- a/source/blender/gpu/GPU_extensions.h
+++ b/source/blender/gpu/GPU_extensions.h
@@ -155,7 +155,7 @@ void GPU_texture_bind_as_framebuffer(GPUTexture *tex);
GPUFrameBuffer *GPU_framebuffer_create(void);
int GPU_framebuffer_texture_attach(GPUFrameBuffer *fb, GPUTexture *tex, int slot, char err_out[256]);
void GPU_framebuffer_texture_detach(GPUTexture *tex);
-void GPU_framebuffer_slot_bind(GPUFrameBuffer *fb, int slot);
+void GPU_framebuffer_slots_bind(GPUFrameBuffer *fb, int slot);
void GPU_framebuffer_texture_unbind(GPUFrameBuffer *fb, GPUTexture *tex);
void GPU_framebuffer_free(GPUFrameBuffer *fb);
bool GPU_framebuffer_check_valid(GPUFrameBuffer *fb, char err_out[256]);
diff --git a/source/blender/gpu/intern/gpu_compositing.c b/source/blender/gpu/intern/gpu_compositing.c
index 13596a2..bc530d7 100644
--- a/source/blender/gpu/intern/gpu_compositing.c
+++ b/source/blender/gpu/intern/gpu_compositing.c
@@ -878,7 +878,7 @@ bool GPU_fx_do_composite_pass(GPUFX *fx, float projmat[4][4], bool is_persp, str
numslots = 0;
}
}
- /* high quality diffusion solver */
+ /* high quality */
else {
GPUShader *dof_shader_pass1, *dof_shader_pass2;//, *dof_shader_pass3, *dof_shader_pass4;
@@ -922,8 +922,10 @@ bool GPU_fx_do_composite_pass(GPUFX *fx, float projmat[4][4], bool is_persp, str
/* target is the downsampled coc buffer */
GPU_framebuffer_texture_attach(fx->gbuffer, fx->dof_half_downsampled, 0, NULL);
+ GPU_framebuffer_texture_attach(fx->gbuffer, fx->dof_nearfar_coc[0], 1, NULL);
/* binding takes care of setting the viewport to the downsampled size */
- GPU_texture_bind_as_framebuffer(fx->dof_half_downsampled);
+ GPU_framebuffer_slots_bind(fx->gbuffer, 0);
+ GPU_framebuffer_check_valid(fx->gbuffer, NULL);
glDisable(GL_DEPTH_TEST);
glDrawArrays(GL_QUADS, 0, 4);
@@ -934,6 +936,7 @@ bool GPU_fx_do_composite_pass(GPUFX *fx, float projmat[4][4], bool is_persp, str
GPU_framebuffer_texture_unbind(fx->gbuffer, fx->dof_half_downsampled);
GPU_framebuffer_texture_detach(fx->dof_half_downsampled);
+ GPU_framebuffer_texture_detach(fx->dof_nearfar_coc[0]);
numslots = 0;
}
diff --git a/source/blender/gpu/intern/gpu_extensions.c b/source/blender/gpu/intern/gpu_extensions.c
index c186487..9afa2cf 100644
--- a/source/blender/gpu/intern/gpu_extensions.c
+++ b/source/blender/gpu/intern/gpu_extensions.c
@@ -1096,13 +1096,23 @@ void GPU_texture_bind_as_framebuffer(GPUTexture *tex)
glPushMatrix();
}
-void GPU_framebuffer_slot_bind(GPUFrameBuffer *fb, int slot)
+void GPU_framebuffer_slots_bind(GPUFrameBuffer *fb, int slot)
{
+ int numslots = 0, i;
+ GLubyte attachments[4];
+
if (!fb->colortex[slot]) {
fprintf(stderr, "Error, framebuffer slot empty!");
return;
}
-
+
+ for (i = 0 ; i < 4; i++) {
+ if (fb->colortex[i]) {
+ attachments[numslots] = GL_COLOR_ATTACHMENT0_EXT + i;
+ numslots++;
+ }
+ }
+
/* push attributes */
glPushAttrib(GL_ENABLE_BIT | GL_VIEWPORT_BIT);
glDisable(GL_SCISSOR_TEST);
@@ -1111,7 +1121,7 @@ void GPU_framebuffer_slot_bind(GPUFrameBuffer *fb, int slot)
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb->object);
/* last bound prevails here, better allow explicit control here too */
- glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT + slot);
+ glDrawBuffers(numslots, attachments);
glReadBuffer(GL_COLOR_ATTACHMENT0_EXT + slot);
/* push matrices and set default viewport and matrix */
@@ -1343,7 +1353,7 @@ void GPU_offscreen_bind(GPUOffScreen *ofs, bool save)
{
glDisable(GL_SCISSOR_TEST);
if (save)
- GPU_framebuffer_slot_bind(ofs->fb, 0);
+ GPU_framebuffer_slots_bind(ofs->fb, 0);
else {
GPU_framebuffer_bind_no_save(ofs->fb, 0);
}
diff --git a/source/blender/gpu/shaders/gpu_shader_fx_dof_high_frag.glsl b/source/blender/gpu/shaders/gpu_shader_fx_dof_high_frag.glsl
index 277c028..423b06c 100644
--- a/source/blender/gpu/shaders/gpu_shader_fx_dof_high_frag.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_fx_dof_high_frag.glsl
@@ -35,19 +35,21 @@ void half_downsample_frag(void)
depthv.a = calculate_signed_coc(texture2D(depthbuffer, depth_uv4).r);
/* near coc, keep the min here */
- gl_FragData[1].r = min(min(depthv.r, depthv.g), min(depthv.b, depthv.a));
+ //gl_FragData[1].r = max(-min(min(depthv.r, depthv.g), min(depthv.b, depthv.a)), 0.0);
/* far coc keep the max */
- gl_FragData[1].g = max(-min(min(depthv.r, depthv.g), min(depthv.b, depthv.a)), 0.0);
- gl_FragData[1].b = gl_FragData[1].a = 0.0;
-
+ //gl_FragData[1].g = max(max(max(depthv.r, depthv.g), max(depthv.b, depthv.a)), 0.0);
+ gl_FragData[1] = vec4(1.0);
/* framebuffer output 1 is bound to half size color. linear filtering should take care of averaging here */
gl_FragData[0] = texture2D(colorbuffer, uvcoordsvar.xy);
}
void final_combine_frag(void)
{
+ vec4 coc = texture2D(cocbuffer, uvcoordsvar.xy);
/* framebuffer output 1 is bound to half size color. linear filtering should take care of averaging here */
- gl_FragColor = texture2D(colorbuffer, uvcoordsvar.xy);
+// gl_FragColor = texture2D(colorbuffer, uvcoordsvar.xy);
+ gl_FragColor = coc;
+// gl_FragColor.g *= coc.g;
}
void main(void)
diff --git a/source/blender/gpu/shaders/gpu_shader_fx_dof_high_vert.glsl b/source/blender/gpu/shaders/gpu_shader_fx_dof_high_vert.glsl
index ffc1733..7feccbe 100644
--- a/source/blender/gpu/shaders/gpu_shader_fx_dof_high_vert.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_fx_dof_high_vert.glsl
@@ -13,10 +13,10 @@ void vert_half_downsample(void)
uvcoordsvar = gl_MultiTexCoord0;
gl_Position = gl_Vertex;
- depth_uv1 = gl_MultiTexCoord0.xy + vec2(0.0, 0.0) * invrendertargetdim;
- depth_uv2 = gl_MultiTexCoord0.xy + vec2(0.0, 1.0) * invrendertargetdim;
- depth_uv3 = gl_MultiTexCoord0.xy + vec2(1.0, 0.0) * invrendertargetdim;
- depth_uv4 = gl_MultiTexCoord0.xy + vec2(1.0, 1.0) * invrendertargetdim;
+ depth_uv1 = gl_MultiTexCoord0.xy + vec2(-0.5, -0.5) * invrendertargetdim;
+ depth_uv2 = gl_MultiTexCoord0.xy + vec2(-0.5, 0.5) * invrendertargetdim;
+ depth_uv3 = gl_MultiTexCoord0.xy + vec2(0.5, -0.5) * invrendertargetdim;
+ depth_uv4 = gl_MultiTexCoord0.xy + vec2(0.5, 0.5) * invrendertargetdim;
}
void vert_final_combine(void)
More information about the Bf-blender-cvs
mailing list