Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntony Riakiotakis <kalast@gmail.com>2015-02-10 13:34:47 +0300
committerAntony Riakiotakis <kalast@gmail.com>2015-02-10 13:34:47 +0300
commitb7c1d2e898a67e3adc5c0169fb69886f330c313d (patch)
tree00c20057f18503a2135c3e96136a1864f6c1a680
parent268ae6a62b21c51c0c85835e42fcd0a2bccb0a66 (diff)
Cleanup - bring branch to merge ready condition
-rw-r--r--SConstruct2
-rw-r--r--release/scripts/startup/bl_ui/properties_data_camera.py3
-rw-r--r--release/scripts/startup/bl_ui/space_view3d.py3
-rw-r--r--source/blender/gpu/CMakeLists.txt4
-rw-r--r--source/blender/gpu/GPU_compositing.h6
-rw-r--r--source/blender/gpu/SConscript2
-rw-r--r--source/blender/gpu/intern/gpu_compositing.cpp714
-rw-r--r--source/blender/gpu/intern/gpu_extensions.c12
-rw-r--r--source/blender/gpu/shaders/gpu_shader_fx_dof_high_frag.glsl81
-rw-r--r--source/blender/gpu/shaders/gpu_shader_fx_dof_high_vert.glsl35
-rw-r--r--source/blender/makesdna/DNA_gpu_types.h7
-rw-r--r--source/blender/makesrna/intern/rna_scene.c16
12 files changed, 211 insertions, 674 deletions
diff --git a/SConstruct b/SConstruct
index 7fc87d41934..225b532c8a0 100644
--- a/SConstruct
+++ b/SConstruct
@@ -764,8 +764,6 @@ if B.targets != ['cudakernels']:
data_to_c_simple("source/blender/gpu/shaders/gpu_shader_fx_ssao_frag.glsl")
data_to_c_simple("source/blender/gpu/shaders/gpu_shader_fx_dof_frag.glsl")
data_to_c_simple("source/blender/gpu/shaders/gpu_shader_fx_dof_vert.glsl")
- data_to_c_simple("source/blender/gpu/shaders/gpu_shader_fx_dof_high_frag.glsl")
- data_to_c_simple("source/blender/gpu/shaders/gpu_shader_fx_dof_high_vert.glsl")
data_to_c_simple("source/blender/gpu/shaders/gpu_shader_fx_lib.glsl")
data_to_c_simple("source/blender/gpu/shaders/gpu_shader_fx_vert.glsl")
data_to_c_simple("intern/opencolorio/gpu_shader_display_transform.glsl")
diff --git a/release/scripts/startup/bl_ui/properties_data_camera.py b/release/scripts/startup/bl_ui/properties_data_camera.py
index 241ff4c9e91..00428f05d63 100644
--- a/release/scripts/startup/bl_ui/properties_data_camera.py
+++ b/release/scripts/startup/bl_ui/properties_data_camera.py
@@ -206,9 +206,6 @@ class DATA_PT_camera_gpu_dof(Panel):
col.prop(dof_options, "dof_fstop")
col.prop(dof_options, "dof_focal_length")
col.prop(dof_options, "dof_sensor")
- col.prop(dof_options, "dof_quality_mode")
- if dof_options.dof_quality_mode == 'HIGH':
- col.prop(dof_options, "dof_num_blades")
@classmethod
def poll(cls, context):
diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py
index 701369e0125..2df075dd209 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -2947,9 +2947,6 @@ class VIEW3D_PT_view3d_shading(Panel):
subcol.prop(dof_options, "dof_fstop")
subcol.prop(dof_options, "dof_focal_length")
subcol.prop(dof_options, "dof_sensor")
- subcol.prop(dof_options, "dof_quality_mode")
- if dof_options.dof_quality_mode == 'HIGH':
- subcol.prop(dof_options, "dof_num_blades")
col.prop(view, "ssao")
if view.ssao:
diff --git a/source/blender/gpu/CMakeLists.txt b/source/blender/gpu/CMakeLists.txt
index cc74459d22d..a9accfcb6ec 100644
--- a/source/blender/gpu/CMakeLists.txt
+++ b/source/blender/gpu/CMakeLists.txt
@@ -61,8 +61,6 @@ set(SRC
shaders/gpu_shader_fx_ssao_frag.glsl
shaders/gpu_shader_fx_dof_frag.glsl
shaders/gpu_shader_fx_dof_vert.glsl
- shaders/gpu_shader_fx_dof_high_frag.glsl
- shaders/gpu_shader_fx_dof_high_vert.glsl
shaders/gpu_shader_fx_vert.glsl
shaders/gpu_shader_material.glsl
shaders/gpu_shader_sep_gaussian_blur_frag.glsl
@@ -100,8 +98,6 @@ data_to_c_simple(shaders/gpu_shader_fx_vert.glsl SRC)
data_to_c_simple(shaders/gpu_shader_fx_ssao_frag.glsl SRC)
data_to_c_simple(shaders/gpu_shader_fx_dof_frag.glsl SRC)
data_to_c_simple(shaders/gpu_shader_fx_dof_vert.glsl SRC)
-data_to_c_simple(shaders/gpu_shader_fx_dof_high_frag.glsl SRC)
-data_to_c_simple(shaders/gpu_shader_fx_dof_high_vert.glsl SRC)
data_to_c_simple(shaders/gpu_shader_fx_lib.glsl SRC)
if(WITH_GAMEENGINE)
diff --git a/source/blender/gpu/GPU_compositing.h b/source/blender/gpu/GPU_compositing.h
index dc997b3a0ae..cc00185075c 100644
--- a/source/blender/gpu/GPU_compositing.h
+++ b/source/blender/gpu/GPU_compositing.h
@@ -58,12 +58,6 @@ typedef enum GPUFXShaderEffect {
GPU_SHADER_FX_DEPTH_OF_FIELD_PASS_THREE = 4,
GPU_SHADER_FX_DEPTH_OF_FIELD_PASS_FOUR = 5,
GPU_SHADER_FX_DEPTH_OF_FIELD_PASS_FIVE = 6,
-
- /* following are for high quality dof */
- GPU_SHADER_FX_DEPTH_OF_FIELD_DOWNSAMPLE_HALF = 7, /* downsample to half render target */
- GPU_SHADER_FX_DEPTH_OF_FIELD_DOWNSAMPLE_HALF_COC = 8, /* downsample coc (mainly near coc) */
- GPU_SHADER_FX_DEPTH_OF_FIELD_BLUR = 9, /* combined calculation of near and far dof buffers */
- GPU_SHADER_FX_DEPTH_OF_FIELD_FINAL_COMBINE = 10 /* final combination pass */
} GPUFXShaderEffect;
/* keep in synch with enum above! */
diff --git a/source/blender/gpu/SConscript b/source/blender/gpu/SConscript
index cc46ad640ae..158cfb67dda 100644
--- a/source/blender/gpu/SConscript
+++ b/source/blender/gpu/SConscript
@@ -68,8 +68,6 @@ sources.extend((
os.path.join(env['DATA_SOURCES'], "gpu_shader_fx_ssao_frag.glsl.c"),
os.path.join(env['DATA_SOURCES'], "gpu_shader_fx_dof_frag.glsl.c"),
os.path.join(env['DATA_SOURCES'], "gpu_shader_fx_dof_vert.glsl.c"),
- os.path.join(env['DATA_SOURCES'], "gpu_shader_fx_dof_high_frag.glsl.c"),
- os.path.join(env['DATA_SOURCES'], "gpu_shader_fx_dof_high_vert.glsl.c"),
os.path.join(env['DATA_SOURCES'], "gpu_shader_fx_lib.glsl.c"),
os.path.join(env['DATA_SOURCES'], "gpu_shader_fx_vert.glsl.c"),
os.path.join(env['DATA_SOURCES'], "gpu_shader_material.glsl.c"),
diff --git a/source/blender/gpu/intern/gpu_compositing.cpp b/source/blender/gpu/intern/gpu_compositing.cpp
index 20974545a1b..d13fc92d0d2 100644
--- a/source/blender/gpu/intern/gpu_compositing.cpp
+++ b/source/blender/gpu/intern/gpu_compositing.cpp
@@ -147,133 +147,6 @@ static GPUTexture * create_concentric_sample_texture(int side)
return tex;
}
-/* compositing node - it's different than material nodes because outputs are buffers - inputs can be
- * uniforms or other types. outputs are always textures */
-class GPUCompositingNode {
- private:
- GPUShader *shader;
- int w, h;
- ListBase inputs;
- ListBase outputs;
-
- public:
- GPUCompositingNode(GPUShader *shader, int w, int h);
- ~GPUCompositingNode();
- float getWidth() {return w;}
- float getHeight() {return h;}
- void setShader(GPUShader *sh) {shader = sh;}
-};
-
-GPUCompositingNode::GPUCompositingNode(GPUShader *shader, int w, int h)
-{
- this->w = w;
- this->h = h;
- this->shader = shader;
-}
-
-GPUCompositingNode::~GPUCompositingNode() {
- GPU_shader_free(shader);
- BLI_freelistN(&inputs);
- BLI_freelistN(&outputs);
-}
-
-/* compositing link between compostiting stages, */
-class GPUCompositingLink {
- private:
- GPUTexture *intexture;
- char *outslot;
- int flag;
-
- public:
- GPUCompositingLink(GPUCompositingNode *nodei, GPUCompositingNode *nodeo, int inslot, char *output);
- ~GPUCompositingLink();
-};
-
-GPUCompositingLink::GPUCompositingLink(GPUCompositingNode *nodei, GPUCompositingNode *nodeo, int inslot, char *output)
-{
- this->intexture = intexture;
- this->outslot = output;
-}
-
-class GPUEffect {
- protected:
- ListBase nodes;
-
- public:
- virtual ~GPUEffect() {}
-
- // prepare or cleanup nodes accorging to new effect parameters
- virtual void prepare(GPUFXOptions *options, int w, int h) = 0;
- // queue the effect nodes for execution
- virtual void queue() = 0;
- //checks if effect has been initialized with sane inputs
- virtual bool checkvalid() = 0;
- virtual void cleanup() = 0;
-};
-
-class GPUDOFEffect : public GPUEffect {
- public:
- GPUDOFEffect();
- ~GPUDOFEffect();
-};
-
-class GPUSSAOEffect : public GPUEffect {
- private:
- GPUShader *shader_persp;
- GPUShader *shader_ortho;
- GPUTexture *concentric_samples_tex;
- int num_samples;
- /* old target dimensions */
- int oldx, oldy;
-
- public:
- GPUSSAOEffect();
- ~GPUSSAOEffect() {cleanup();}
-
- // prepare or cleanup nodes accorging to new effect parameters
- void prepare(GPUFXOptions *options, int w, int h);
- // queue the effect nodes for execution
- void queue(){}
- bool checkvalid() {return true;}
- void cleanup(){}
-};
-
-GPUSSAOEffect::GPUSSAOEffect()
-{
- /* compile shaders here */
- shader_persp = GPU_shader_get_builtin_fx_shader(GPU_SHADER_FX_SSAO, true);
- shader_ortho = GPU_shader_get_builtin_fx_shader(GPU_SHADER_FX_SSAO, false);
-}
-
-void GPUSSAOEffect::prepare(GPUFXOptions *options, int UNUSED(w), int UNUSED(h))
-{
- if (options->ssao_options) {
- if (options->ssao_options->ssao_num_samples != num_samples || !concentric_samples_tex) {
- if (options->ssao_options->ssao_num_samples < 1)
- options->ssao_options->ssao_num_samples = 1;
-
- num_samples = options->ssao_options->ssao_num_samples;
-
- if (concentric_samples_tex) {
- GPU_texture_free(concentric_samples_tex);
- }
-
- concentric_samples_tex = create_concentric_sample_texture(num_samples);
- }
- }
- else {
- if (concentric_samples_tex) {
- GPU_texture_free(concentric_samples_tex);
- concentric_samples_tex = NULL;
- }
- }
-}
-
-/* manages resources and data flow between nodes */
-class GPUCompositorManager {
-
-};
-
/* generate a new FX compositor */
GPUFX *GPU_create_fx_compositor(void)
{
@@ -396,8 +269,8 @@ bool GPU_initialize_fx_passes(GPUFX *fx, rcti *rect, rcti *scissor_rect, int fxf
}
/* disable effects if no options passed for them */
- if (!options->dof_options || (options->dof_options->dof_quality_mode == DOF_QUALITY_HIGH)) {
- //fxflags &= ~GPU_FX_DEPTH_OF_FIELD;
+ if (!options->dof_options) {
+ fxflags &= ~GPU_FX_DEPTH_OF_FIELD;
}
if (!options->ssao_options || options->ssao_options->ssao_num_samples < 1) {
fxflags &= ~GPU_FX_SSAO;
@@ -466,68 +339,24 @@ bool GPU_initialize_fx_passes(GPUFX *fx, rcti *rect, rcti *scissor_rect, int fxf
/* create textures for dof effect */
if (fxflags & GPU_FX_DEPTH_OF_FIELD) {
- if (options->dof_options->dof_quality_mode == DOF_QUALITY_HIGH) {
- /* we use a different scheme here */
- if (!fx->dof_near_blur || !fx->dof_far_blur || !fx->dof_nearfar_coc || !fx->dof_half_downsampled) {
- int i, ds_w, ds_h;
- /* half width instead of quad width */
- fx->dof_downsampled_w = w / 2;
- fx->dof_downsampled_h = h / 2;
- ds_w = fx->dof_downsampled_w;
- ds_h = fx->dof_downsampled_h;
-
- if (!(fx->dof_near_blur = GPU_texture_create_2D(fx->dof_downsampled_w, fx->dof_downsampled_h, NULL, GPU_HDR_NONE, err_out))) {
- printf("%.256s\n", err_out);
- cleanup_fx_gl_data(fx, true);
- return false;
- }
- if (!(fx->dof_far_blur = GPU_texture_create_2D(fx->dof_downsampled_w, fx->dof_downsampled_h, NULL, GPU_HDR_NONE, err_out))) {
- printf("%.256s\n", err_out);
- cleanup_fx_gl_data(fx, true);
- return false;
- }
- if (!(fx->dof_half_downsampled = GPU_texture_create_2D(fx->dof_downsampled_w, fx->dof_downsampled_h, NULL, GPU_HDR_NONE, err_out))) {
- printf("%.256s\n", err_out);
- cleanup_fx_gl_data(fx, true);
- return false;
- }
- for (i = 0; i < 6; i++) {
- if (!(fx->dof_nearfar_coc[i] = GPU_texture_create_2D(ds_w, ds_h, NULL, GPU_HDR_NONE, err_out))) {
- printf("%.256s\n", err_out);
- cleanup_fx_gl_data(fx, true);
- return false;
- }
- ds_w /= 2;
- ds_h /= 2;
- }
- /* arbitrary number for now (7), but will be improved later */
- if (!(fx->dof_concentric_samples_tex = create_concentric_sample_texture(7))) {
- printf("%.256s\n", err_out);
- cleanup_fx_gl_data(fx, true);
- return false;
- }
+ if (!fx->dof_near_coc_buffer || !fx->dof_near_coc_blurred_buffer || !fx->dof_near_coc_final_buffer) {
+ fx->dof_downsampled_w = w / 4;
+ fx->dof_downsampled_h = h / 4;
+
+ if (!(fx->dof_near_coc_buffer = GPU_texture_create_2D(fx->dof_downsampled_w, fx->dof_downsampled_h, NULL, GPU_HDR_NONE, err_out))) {
+ printf("%.256s\n", err_out);
+ cleanup_fx_gl_data(fx, true);
+ return false;
}
- }
- else {
- if (!fx->dof_near_coc_buffer || !fx->dof_near_coc_blurred_buffer || !fx->dof_near_coc_final_buffer) {
- fx->dof_downsampled_w = w / 4;
- fx->dof_downsampled_h = h / 4;
-
- if (!(fx->dof_near_coc_buffer = GPU_texture_create_2D(fx->dof_downsampled_w, fx->dof_downsampled_h, NULL, GPU_HDR_NONE, err_out))) {
- printf("%.256s\n", err_out);
- cleanup_fx_gl_data(fx, true);
- return false;
- }
- if (!(fx->dof_near_coc_blurred_buffer = GPU_texture_create_2D(fx->dof_downsampled_w, fx->dof_downsampled_h, NULL, GPU_HDR_NONE, err_out))) {
- printf("%.256s\n", err_out);
- cleanup_fx_gl_data(fx, true);
- return false;
- }
- if (!(fx->dof_near_coc_final_buffer = GPU_texture_create_2D(fx->dof_downsampled_w, fx->dof_downsampled_h, NULL, GPU_HDR_NONE, err_out))) {
- printf("%.256s\n", err_out);
- cleanup_fx_gl_data(fx, true);
- return false;
- }
+ if (!(fx->dof_near_coc_blurred_buffer = GPU_texture_create_2D(fx->dof_downsampled_w, fx->dof_downsampled_h, NULL, GPU_HDR_NONE, err_out))) {
+ printf("%.256s\n", err_out);
+ cleanup_fx_gl_data(fx, true);
+ return false;
+ }
+ if (!(fx->dof_near_coc_final_buffer = GPU_texture_create_2D(fx->dof_downsampled_w, fx->dof_downsampled_h, NULL, GPU_HDR_NONE, err_out))) {
+ printf("%.256s\n", err_out);
+ cleanup_fx_gl_data(fx, true);
+ return false;
}
}
}
@@ -757,378 +586,257 @@ bool GPU_fx_do_composite_pass(GPUFX *fx, float projmat[4][4], bool is_persp, str
dof_params[2] = fx->gbuffer_dim[0] / (scale_camera * options->dof_sensor);
dof_params[3] = 0.0f;
- if (options->dof_quality_mode == DOF_QUALITY_NORMAL) {
- GPUShader *dof_shader_pass1, *dof_shader_pass2, *dof_shader_pass3, *dof_shader_pass4, *dof_shader_pass5;
+ GPUShader *dof_shader_pass1, *dof_shader_pass2, *dof_shader_pass3, *dof_shader_pass4, *dof_shader_pass5;
- /* DOF effect has many passes but most of them are performed on a texture whose dimensions are 4 times less than the original
+ /* DOF effect has many passes but most of them are performed on a texture whose dimensions are 4 times less than the original
* (16 times lower than original screen resolution). Technique used is not very exact but should be fast enough and is based
* on "Practical Post-Process Depth of Field" see http://http.developer.nvidia.com/GPUGems3/gpugems3_ch28.html */
- dof_shader_pass1 = GPU_shader_get_builtin_fx_shader(GPU_SHADER_FX_DEPTH_OF_FIELD_PASS_ONE, is_persp);
- dof_shader_pass2 = GPU_shader_get_builtin_fx_shader(GPU_SHADER_FX_DEPTH_OF_FIELD_PASS_TWO, is_persp);
- dof_shader_pass3 = GPU_shader_get_builtin_fx_shader(GPU_SHADER_FX_DEPTH_OF_FIELD_PASS_THREE, is_persp);
- dof_shader_pass4 = GPU_shader_get_builtin_fx_shader(GPU_SHADER_FX_DEPTH_OF_FIELD_PASS_FOUR, is_persp);
- dof_shader_pass5 = GPU_shader_get_builtin_fx_shader(GPU_SHADER_FX_DEPTH_OF_FIELD_PASS_FIVE, is_persp);
-
- /* error occured, restore framebuffers and return */
- if (!(dof_shader_pass1 && dof_shader_pass2 && dof_shader_pass3 && dof_shader_pass4 && dof_shader_pass5)) {
- GPU_framebuffer_texture_unbind(fx->gbuffer, NULL);
- GPU_framebuffer_restore();
- return false;
- }
+ dof_shader_pass1 = GPU_shader_get_builtin_fx_shader(GPU_SHADER_FX_DEPTH_OF_FIELD_PASS_ONE, is_persp);
+ dof_shader_pass2 = GPU_shader_get_builtin_fx_shader(GPU_SHADER_FX_DEPTH_OF_FIELD_PASS_TWO, is_persp);
+ dof_shader_pass3 = GPU_shader_get_builtin_fx_shader(GPU_SHADER_FX_DEPTH_OF_FIELD_PASS_THREE, is_persp);
+ dof_shader_pass4 = GPU_shader_get_builtin_fx_shader(GPU_SHADER_FX_DEPTH_OF_FIELD_PASS_FOUR, is_persp);
+ dof_shader_pass5 = GPU_shader_get_builtin_fx_shader(GPU_SHADER_FX_DEPTH_OF_FIELD_PASS_FIVE, is_persp);
+
+ /* error occured, restore framebuffers and return */
+ if (!(dof_shader_pass1 && dof_shader_pass2 && dof_shader_pass3 && dof_shader_pass4 && dof_shader_pass5)) {
+ GPU_framebuffer_texture_unbind(fx->gbuffer, NULL);
+ GPU_framebuffer_restore();
+ return false;
+ }
+
+ /* pass first, first level of blur in low res buffer */
+ {
+ int invrendertargetdim_uniform, color_uniform, depth_uniform, dof_uniform;
+ int viewvecs_uniform;
+
+ float invrendertargetdim[2] = {1.0f / fx->gbuffer_dim[0], 1.0f / fx->gbuffer_dim[1]};
+
+ dof_uniform = GPU_shader_get_uniform(dof_shader_pass1, "dof_params");
+ invrendertargetdim_uniform = GPU_shader_get_uniform(dof_shader_pass1, "invrendertargetdim");
+ color_uniform = GPU_shader_get_uniform(dof_shader_pass1, "colorbuffer");
+ depth_uniform = GPU_shader_get_uniform(dof_shader_pass1, "depthbuffer");
+ viewvecs_uniform = GPU_shader_get_uniform(dof_shader_pass1, "viewvecs");
+
+ GPU_shader_bind(dof_shader_pass1);
+
+ GPU_shader_uniform_vector(dof_shader_pass1, dof_uniform, 4, 1, dof_params);
+ GPU_shader_uniform_vector(dof_shader_pass1, invrendertargetdim_uniform, 2, 1, invrendertargetdim);
+ GPU_shader_uniform_vector(dof_shader_pass1, viewvecs_uniform, 4, 3, viewvecs[0]);
- /* pass first, first level of blur in low res buffer */
- {
- int invrendertargetdim_uniform, color_uniform, depth_uniform, dof_uniform;
- int viewvecs_uniform;
+ GPU_texture_bind(src, numslots++);
+ GPU_shader_uniform_texture(dof_shader_pass1, color_uniform, src);
- float invrendertargetdim[2] = {1.0f / fx->gbuffer_dim[0], 1.0f / fx->gbuffer_dim[1]};
+ GPU_texture_bind(fx->depth_buffer, numslots++);
+ GPU_depth_texture_mode(fx->depth_buffer, false, true);
+ GPU_shader_uniform_texture(dof_shader_pass1, depth_uniform, fx->depth_buffer);
- dof_uniform = GPU_shader_get_uniform(dof_shader_pass1, "dof_params");
- invrendertargetdim_uniform = GPU_shader_get_uniform(dof_shader_pass1, "invrendertargetdim");
- color_uniform = GPU_shader_get_uniform(dof_shader_pass1, "colorbuffer");
- depth_uniform = GPU_shader_get_uniform(dof_shader_pass1, "depthbuffer");
- viewvecs_uniform = GPU_shader_get_uniform(dof_shader_pass1, "viewvecs");
+ /* target is the downsampled coc buffer */
+ GPU_framebuffer_texture_attach(fx->gbuffer, fx->dof_near_coc_buffer, 0, NULL);
+ /* binding takes care of setting the viewport to the downsampled size */
+ GPU_texture_bind_as_framebuffer(fx->dof_near_coc_buffer);
- GPU_shader_bind(dof_shader_pass1);
+ glDisable(GL_DEPTH_TEST);
+ glDrawArrays(GL_QUADS, 0, 4);
+ /* disable bindings */
+ GPU_texture_unbind(src);
+ GPU_depth_texture_mode(fx->depth_buffer, true, false);
+ GPU_texture_unbind(fx->depth_buffer);
- GPU_shader_uniform_vector(dof_shader_pass1, dof_uniform, 4, 1, dof_params);
- GPU_shader_uniform_vector(dof_shader_pass1, invrendertargetdim_uniform, 2, 1, invrendertargetdim);
- GPU_shader_uniform_vector(dof_shader_pass1, viewvecs_uniform, 4, 3, viewvecs[0]);
+ GPU_framebuffer_texture_detach(fx->dof_near_coc_buffer);
+ numslots = 0;
+ }
- GPU_texture_bind(src, numslots++);
- GPU_shader_uniform_texture(dof_shader_pass1, color_uniform, src);
+ /* second pass, gaussian blur the downsampled image */
+ {
+ int invrendertargetdim_uniform, color_uniform, depth_uniform, dof_uniform;
+ int viewvecs_uniform;
+ float invrendertargetdim[2] = {1.0f / GPU_texture_opengl_width(fx->dof_near_coc_blurred_buffer),
+ 1.0f / GPU_texture_opengl_height(fx->dof_near_coc_blurred_buffer)};
+ float tmp = invrendertargetdim[0];
+ invrendertargetdim[0] = 0.0f;
- GPU_texture_bind(fx->depth_buffer, numslots++);
- GPU_depth_texture_mode(fx->depth_buffer, false, true);
- GPU_shader_uniform_texture(dof_shader_pass1, depth_uniform, fx->depth_buffer);
+ dof_params[2] = GPU_texture_opengl_width(fx->dof_near_coc_blurred_buffer) / (scale_camera * options->dof_sensor);
- /* target is the downsampled coc buffer */
- GPU_framebuffer_texture_attach(fx->gbuffer, fx->dof_near_coc_buffer, 0, NULL);
- /* binding takes care of setting the viewport to the downsampled size */
- GPU_texture_bind_as_framebuffer(fx->dof_near_coc_buffer);
+ dof_uniform = GPU_shader_get_uniform(dof_shader_pass2, "dof_params");
+ invrendertargetdim_uniform = GPU_shader_get_uniform(dof_shader_pass2, "invrendertargetdim");
+ color_uniform = GPU_shader_get_uniform(dof_shader_pass2, "colorbuffer");
+ depth_uniform = GPU_shader_get_uniform(dof_shader_pass2, "depthbuffer");
+ viewvecs_uniform = GPU_shader_get_uniform(dof_shader_pass2, "viewvecs");
- glDisable(GL_DEPTH_TEST);
- glDrawArrays(GL_QUADS, 0, 4);
- /* disable bindings */
- GPU_texture_unbind(src);
- GPU_depth_texture_mode(fx->depth_buffer, true, false);
- GPU_texture_unbind(fx->depth_buffer);
+ /* Blurring vertically */
+ GPU_shader_bind(dof_shader_pass2);
- GPU_framebuffer_texture_detach(fx->dof_near_coc_buffer);
- numslots = 0;
- }
+ GPU_shader_uniform_vector(dof_shader_pass2, dof_uniform, 4, 1, dof_params);
+ GPU_shader_uniform_vector(dof_shader_pass2, invrendertargetdim_uniform, 2, 1, invrendertargetdim);
+ GPU_shader_uniform_vector(dof_shader_pass2, viewvecs_uniform, 4, 3, viewvecs[0]);
- /* second pass, gaussian blur the downsampled image */
- {
- int invrendertargetdim_uniform, color_uniform, depth_uniform, dof_uniform;
- int viewvecs_uniform;
- float invrendertargetdim[2] = {1.0f / GPU_texture_opengl_width(fx->dof_near_coc_blurred_buffer),
- 1.0f / GPU_texture_opengl_height(fx->dof_near_coc_blurred_buffer)};
- float tmp = invrendertargetdim[0];
- invrendertargetdim[0] = 0.0f;
+ GPU_texture_bind(fx->depth_buffer, numslots++);
+ GPU_depth_texture_mode(fx->depth_buffer, false, true);
+ GPU_shader_uniform_texture(dof_shader_pass2, depth_uniform, fx->depth_buffer);
- dof_params[2] = GPU_texture_opengl_width(fx->dof_near_coc_blurred_buffer) / (scale_camera * options->dof_sensor);
+ GPU_texture_bind(fx->dof_near_coc_buffer, numslots++);
+ GPU_shader_uniform_texture(dof_shader_pass2, color_uniform, fx->dof_near_coc_buffer);
- dof_uniform = GPU_shader_get_uniform(dof_shader_pass2, "dof_params");
- invrendertargetdim_uniform = GPU_shader_get_uniform(dof_shader_pass2, "invrendertargetdim");
- color_uniform = GPU_shader_get_uniform(dof_shader_pass2, "colorbuffer");
- depth_uniform = GPU_shader_get_uniform(dof_shader_pass2, "depthbuffer");
- viewvecs_uniform = GPU_shader_get_uniform(dof_shader_pass2, "viewvecs");
+ /* use final buffer as a temp here */
+ GPU_framebuffer_texture_attach(fx->gbuffer, fx->dof_near_coc_final_buffer, 0, NULL);
- /* Blurring vertically */
- GPU_shader_bind(dof_shader_pass2);
+ /* Drawing quad */
+ glDrawArrays(GL_QUADS, 0, 4);
- GPU_shader_uniform_vector(dof_shader_pass2, dof_uniform, 4, 1, dof_params);
- GPU_shader_uniform_vector(dof_shader_pass2, invrendertargetdim_uniform, 2, 1, invrendertargetdim);
- GPU_shader_uniform_vector(dof_shader_pass2, viewvecs_uniform, 4, 3, viewvecs[0]);
+ /* *unbind/detach */
+ GPU_texture_unbind(fx->dof_near_coc_buffer);
+ GPU_framebuffer_texture_detach(fx->dof_near_coc_final_buffer);
- GPU_texture_bind(fx->depth_buffer, numslots++);
- GPU_depth_texture_mode(fx->depth_buffer, false, true);
- GPU_shader_uniform_texture(dof_shader_pass2, depth_uniform, fx->depth_buffer);
+ /* Blurring horizontally */
+ invrendertargetdim[0] = tmp;
+ invrendertargetdim[1] = 0.0f;
+ GPU_shader_uniform_vector(dof_shader_pass2, invrendertargetdim_uniform, 2, 1, invrendertargetdim);
- GPU_texture_bind(fx->dof_near_coc_buffer, numslots++);
- GPU_shader_uniform_texture(dof_shader_pass2, color_uniform, fx->dof_near_coc_buffer);
+ GPU_texture_bind(fx->dof_near_coc_final_buffer, numslots++);
+ GPU_shader_uniform_texture(dof_shader_pass2, color_uniform, fx->dof_near_coc_final_buffer);
- /* use final buffer as a temp here */
- GPU_framebuffer_texture_attach(fx->gbuffer, fx->dof_near_coc_final_buffer, 0, NULL);
+ GPU_framebuffer_texture_attach(fx->gbuffer, fx->dof_near_coc_blurred_buffer, 0, NULL);
+ glDrawArrays(GL_QUADS, 0, 4);
- /* Drawing quad */
- glDrawArrays(GL_QUADS, 0, 4);
+ /* *unbind/detach */
+ GPU_depth_texture_mode(fx->depth_buffer, true, false);
+ GPU_texture_unbind(fx->depth_buffer);
- /* *unbind/detach */
- GPU_texture_unbind(fx->dof_near_coc_buffer);
- GPU_framebuffer_texture_detach(fx->dof_near_coc_final_buffer);
+ GPU_texture_unbind(fx->dof_near_coc_final_buffer);
+ GPU_framebuffer_texture_detach(fx->dof_near_coc_blurred_buffer);
- /* Blurring horizontally */
- invrendertargetdim[0] = tmp;
- invrendertargetdim[1] = 0.0f;
- GPU_shader_uniform_vector(dof_shader_pass2, invrendertargetdim_uniform, 2, 1, invrendertargetdim);
+ dof_params[2] = fx->gbuffer_dim[0] / (scale_camera * options->dof_sensor);
- GPU_texture_bind(fx->dof_near_coc_final_buffer, numslots++);
- GPU_shader_uniform_texture(dof_shader_pass2, color_uniform, fx->dof_near_coc_final_buffer);
+ numslots = 0;
+ }
- GPU_framebuffer_texture_attach(fx->gbuffer, fx->dof_near_coc_blurred_buffer, 0, NULL);
- glDrawArrays(GL_QUADS, 0, 4);
+ /* third pass, calculate near coc */
+ {
+ int near_coc_downsampled, near_coc_blurred;
- /* *unbind/detach */
- GPU_depth_texture_mode(fx->depth_buffer, true, false);
- GPU_texture_unbind(fx->depth_buffer);
+ near_coc_downsampled = GPU_shader_get_uniform(dof_shader_pass3, "colorbuffer");
+ near_coc_blurred = GPU_shader_get_uniform(dof_shader_pass3, "blurredcolorbuffer");
- GPU_texture_unbind(fx->dof_near_coc_final_buffer);
- GPU_framebuffer_texture_detach(fx->dof_near_coc_blurred_buffer);
+ GPU_shader_bind(dof_shader_pass3);
- dof_params[2] = fx->gbuffer_dim[0] / (scale_camera * options->dof_sensor);
+ GPU_texture_bind(fx->dof_near_coc_buffer, numslots++);
+ GPU_shader_uniform_texture(dof_shader_pass3, near_coc_downsampled, fx->dof_near_coc_buffer);
- numslots = 0;
- }
+ GPU_texture_bind(fx->dof_near_coc_blurred_buffer, numslots++);
+ GPU_shader_uniform_texture(dof_shader_pass3, near_coc_blurred, fx->dof_near_coc_blurred_buffer);
- /* third pass, calculate near coc */
- {
- int near_coc_downsampled, near_coc_blurred;
+ GPU_framebuffer_texture_attach(fx->gbuffer, fx->dof_near_coc_final_buffer, 0, NULL);
- near_coc_downsampled = GPU_shader_get_uniform(dof_shader_pass3, "colorbuffer");
- near_coc_blurred = GPU_shader_get_uniform(dof_shader_pass3, "blurredcolorbuffer");
+ glDisable(GL_DEPTH_TEST);
+ glDrawArrays(GL_QUADS, 0, 4);
+ /* disable bindings */
+ GPU_texture_unbind(fx->dof_near_coc_buffer);
+ GPU_texture_unbind(fx->dof_near_coc_blurred_buffer);
- GPU_shader_bind(dof_shader_pass3);
+ /* unbinding here restores the size to the original */
+ GPU_framebuffer_texture_detach(fx->dof_near_coc_final_buffer);
- GPU_texture_bind(fx->dof_near_coc_buffer, numslots++);
- GPU_shader_uniform_texture(dof_shader_pass3, near_coc_downsampled, fx->dof_near_coc_buffer);
+ numslots = 0;
+ }
- GPU_texture_bind(fx->dof_near_coc_blurred_buffer, numslots++);
- GPU_shader_uniform_texture(dof_shader_pass3, near_coc_blurred, fx->dof_near_coc_blurred_buffer);
+ /* fourth pass blur final coc once to eliminate discontinuities */
+ {
+ int near_coc_downsampled;
+ int invrendertargetdim_uniform;
+ float invrendertargetdim[2] = {1.0f / GPU_texture_opengl_width(fx->dof_near_coc_blurred_buffer),
+ 1.0f / GPU_texture_opengl_height(fx->dof_near_coc_blurred_buffer)};
- GPU_framebuffer_texture_attach(fx->gbuffer, fx->dof_near_coc_final_buffer, 0, NULL);
+ near_coc_downsampled = GPU_shader_get_uniform(dof_shader_pass4, "colorbuffer");
+ invrendertargetdim_uniform = GPU_shader_get_uniform(dof_shader_pass4, "invrendertargetdim");
- glDisable(GL_DEPTH_TEST);
- glDrawArrays(GL_QUADS, 0, 4);
- /* disable bindings */
- GPU_texture_unbind(fx->dof_near_coc_buffer);
- GPU_texture_unbind(fx->dof_near_coc_blurred_buffer);
+ GPU_shader_bind(dof_shader_pass4);
- /* unbinding here restores the size to the original */
- GPU_framebuffer_texture_detach(fx->dof_near_coc_final_buffer);
+ GPU_texture_bind(fx->dof_near_coc_final_buffer, numslots++);
+ GPU_shader_uniform_texture(dof_shader_pass4, near_coc_downsampled, fx->dof_near_coc_final_buffer);
+ GPU_shader_uniform_vector(dof_shader_pass4, invrendertargetdim_uniform, 2, 1, invrendertargetdim);
- numslots = 0;
- }
+ GPU_framebuffer_texture_attach(fx->gbuffer, fx->dof_near_coc_buffer, 0, NULL);
- /* fourth pass blur final coc once to eliminate discontinuities */
- {
- int near_coc_downsampled;
- int invrendertargetdim_uniform;
- float invrendertargetdim[2] = {1.0f / GPU_texture_opengl_width(fx->dof_near_coc_blurred_buffer),
- 1.0f / GPU_texture_opengl_height(fx->dof_near_coc_blurred_buffer)};
+ glDisable(GL_DEPTH_TEST);
+ glDrawArrays(GL_QUADS, 0, 4);
+ /* disable bindings */
+ GPU_texture_unbind(fx->dof_near_coc_final_buffer);
- near_coc_downsampled = GPU_shader_get_uniform(dof_shader_pass4, "colorbuffer");
- invrendertargetdim_uniform = GPU_shader_get_uniform(dof_shader_pass4, "invrendertargetdim");
+ /* unbinding here restores the size to the original */
+ GPU_framebuffer_texture_unbind(fx->gbuffer, fx->dof_near_coc_buffer);
+ GPU_framebuffer_texture_detach(fx->dof_near_coc_buffer);
- GPU_shader_bind(dof_shader_pass4);
+ numslots = 0;
+ }
- GPU_texture_bind(fx->dof_near_coc_final_buffer, numslots++);
- GPU_shader_uniform_texture(dof_shader_pass4, near_coc_downsampled, fx->dof_near_coc_final_buffer);
- GPU_shader_uniform_vector(dof_shader_pass4, invrendertargetdim_uniform, 2, 1, invrendertargetdim);
+ /* final pass, merge blurred layers according to final calculated coc */
+ {
+ int medium_blurred_uniform, high_blurred_uniform, original_uniform, depth_uniform, dof_uniform;
+ int invrendertargetdim_uniform, viewvecs_uniform;
+ float invrendertargetdim[2] = {1.0f / fx->gbuffer_dim[0], 1.0f / fx->gbuffer_dim[1]};
- GPU_framebuffer_texture_attach(fx->gbuffer, fx->dof_near_coc_buffer, 0, NULL);
+ medium_blurred_uniform = GPU_shader_get_uniform(dof_shader_pass5, "mblurredcolorbuffer");
+ high_blurred_uniform = GPU_shader_get_uniform(dof_shader_pass5, "blurredcolorbuffer");
+ dof_uniform = GPU_shader_get_uniform(dof_shader_pass5, "dof_params");
+ invrendertargetdim_uniform = GPU_shader_get_uniform(dof_shader_pass5, "invrendertargetdim");
+ original_uniform = GPU_shader_get_uniform(dof_shader_pass5, "colorbuffer");
+ depth_uniform = GPU_shader_get_uniform(dof_shader_pass5, "depthbuffer");
+ viewvecs_uniform = GPU_shader_get_uniform(dof_shader_pass5, "viewvecs");
- glDisable(GL_DEPTH_TEST);
- glDrawArrays(GL_QUADS, 0, 4);
- /* disable bindings */
- GPU_texture_unbind(fx->dof_near_coc_final_buffer);
+ GPU_shader_bind(dof_shader_pass5);
- /* unbinding here restores the size to the original */
- GPU_framebuffer_texture_unbind(fx->gbuffer, fx->dof_near_coc_buffer);
- GPU_framebuffer_texture_detach(fx->dof_near_coc_buffer);
+ GPU_shader_uniform_vector(dof_shader_pass5, dof_uniform, 4, 1, dof_params);
+ GPU_shader_uniform_vector(dof_shader_pass5, invrendertargetdim_uniform, 2, 1, invrendertargetdim);
+ GPU_shader_uniform_vector(dof_shader_pass5, viewvecs_uniform, 4, 3, viewvecs[0]);
- numslots = 0;
- }
+ GPU_texture_bind(src, numslots++);
+ GPU_shader_uniform_texture(dof_shader_pass5, original_uniform, src);
- /* final pass, merge blurred layers according to final calculated coc */
- {
- int medium_blurred_uniform, high_blurred_uniform, original_uniform, depth_uniform, dof_uniform;
- int invrendertargetdim_uniform, viewvecs_uniform;
- float invrendertargetdim[2] = {1.0f / fx->gbuffer_dim[0], 1.0f / fx->gbuffer_dim[1]};
-
- medium_blurred_uniform = GPU_shader_get_uniform(dof_shader_pass5, "mblurredcolorbuffer");
- high_blurred_uniform = GPU_shader_get_uniform(dof_shader_pass5, "blurredcolorbuffer");
- dof_uniform = GPU_shader_get_uniform(dof_shader_pass5, "dof_params");
- invrendertargetdim_uniform = GPU_shader_get_uniform(dof_shader_pass5, "invrendertargetdim");
- original_uniform = GPU_shader_get_uniform(dof_shader_pass5, "colorbuffer");
- depth_uniform = GPU_shader_get_uniform(dof_shader_pass5, "depthbuffer");
- viewvecs_uniform = GPU_shader_get_uniform(dof_shader_pass5, "viewvecs");
-
- GPU_shader_bind(dof_shader_pass5);
-
- GPU_shader_uniform_vector(dof_shader_pass5, dof_uniform, 4, 1, dof_params);
- GPU_shader_uniform_vector(dof_shader_pass5, invrendertargetdim_uniform, 2, 1, invrendertargetdim);
- GPU_shader_uniform_vector(dof_shader_pass5, viewvecs_uniform, 4, 3, viewvecs[0]);
-
- GPU_texture_bind(src, numslots++);
- GPU_shader_uniform_texture(dof_shader_pass5, original_uniform, src);
-
- GPU_texture_bind(fx->dof_near_coc_blurred_buffer, numslots++);
- GPU_shader_uniform_texture(dof_shader_pass5, high_blurred_uniform, fx->dof_near_coc_blurred_buffer);
-
- GPU_texture_bind(fx->dof_near_coc_buffer, numslots++);
- GPU_shader_uniform_texture(dof_shader_pass5, medium_blurred_uniform, fx->dof_near_coc_buffer);
-
- GPU_texture_bind(fx->depth_buffer, numslots++);
- GPU_depth_texture_mode(fx->depth_buffer, false, true);
- GPU_shader_uniform_texture(dof_shader_pass5, depth_uniform, fx->depth_buffer);
-
- /* if this is the last pass, prepare for rendering on the frambuffer */
- if (passes_left-- == 1) {
- GPU_framebuffer_texture_unbind(fx->gbuffer, NULL);
- if (ofs) {
- GPU_offscreen_bind(ofs, false);
- }
- else
- GPU_framebuffer_restore();
- }
- else {
- /* bind the ping buffer to the color buffer */
- GPU_framebuffer_texture_attach(fx->gbuffer, target, 0, NULL);
- }
- glDisable(GL_DEPTH_TEST);
- glDrawArrays(GL_QUADS, 0, 4);
- /* disable bindings */
- GPU_texture_unbind(fx->dof_near_coc_buffer);
- GPU_texture_unbind(fx->dof_near_coc_blurred_buffer);
- GPU_texture_unbind(src);
- GPU_depth_texture_mode(fx->depth_buffer, true, false);
- GPU_texture_unbind(fx->depth_buffer);
-
- /* may not be attached, in that case this just returns */
- if (target) {
- GPU_framebuffer_texture_detach(target);
- if (ofs) {
- GPU_offscreen_bind(ofs, false);
- }
- else {
- GPU_framebuffer_restore();
- }
- }
+ GPU_texture_bind(fx->dof_near_coc_blurred_buffer, numslots++);
+ GPU_shader_uniform_texture(dof_shader_pass5, high_blurred_uniform, fx->dof_near_coc_blurred_buffer);
- SWAP(GPUTexture *, target, src);
- numslots = 0;
- }
- }
- /* high quality */
- else {
- GPUShader *dof_shader_pass1, *dof_shader_pass2;//, *dof_shader_pass3, *dof_shader_pass4;
+ GPU_texture_bind(fx->dof_near_coc_buffer, numslots++);
+ GPU_shader_uniform_texture(dof_shader_pass5, medium_blurred_uniform, fx->dof_near_coc_buffer);
- dof_shader_pass1 = GPU_shader_get_builtin_fx_shader(GPU_SHADER_FX_DEPTH_OF_FIELD_DOWNSAMPLE_HALF, is_persp);
- dof_shader_pass2 = GPU_shader_get_builtin_fx_shader(GPU_SHADER_FX_DEPTH_OF_FIELD_DOWNSAMPLE_HALF_COC, is_persp);
- //dof_shader_pass3 = GPU_shader_get_builtin_fx_shader(GPU_SHADER_FX_DEPTH_OF_FIELD_BLUR, is_persp);
- //dof_shader_pass4 = GPU_shader_get_builtin_fx_shader(GPU_SHADER_FX_DEPTH_OF_FIELD_FINAL_COMBINE, is_persp);
+ GPU_texture_bind(fx->depth_buffer, numslots++);
+ GPU_depth_texture_mode(fx->depth_buffer, false, true);
+ GPU_shader_uniform_texture(dof_shader_pass5, depth_uniform, fx->depth_buffer);
- /* error occured, restore framebuffers and return */
- if (!(dof_shader_pass1 && dof_shader_pass2)) {
+ /* if this is the last pass, prepare for rendering on the frambuffer */
+ if (passes_left-- == 1) {
GPU_framebuffer_texture_unbind(fx->gbuffer, NULL);
- GPU_framebuffer_restore();
- return false;
+ if (ofs) {
+ GPU_offscreen_bind(ofs, false);
+ }
+ else
+ GPU_framebuffer_restore();
}
-
- /* downsample pass */
- {
- int invrendertargetdim_uniform, color_uniform, depth_uniform, dof_uniform;
- int viewvecs_uniform;
-
- float invrendertargetdim[2] = {1.0f / fx->gbuffer_dim[0], 1.0f / fx->gbuffer_dim[1]};
-
- dof_uniform = GPU_shader_get_uniform(dof_shader_pass1, "dof_params");
- invrendertargetdim_uniform = GPU_shader_get_uniform(dof_shader_pass1, "invrendertargetdim");
- color_uniform = GPU_shader_get_uniform(dof_shader_pass1, "colorbuffer");
- depth_uniform = GPU_shader_get_uniform(dof_shader_pass1, "depthbuffer");
- viewvecs_uniform = GPU_shader_get_uniform(dof_shader_pass1, "viewvecs");
-
- GPU_shader_bind(dof_shader_pass1);
-
- GPU_shader_uniform_vector(dof_shader_pass1, dof_uniform, 4, 1, dof_params);
- GPU_shader_uniform_vector(dof_shader_pass1, invrendertargetdim_uniform, 2, 1, invrendertargetdim);
- GPU_shader_uniform_vector(dof_shader_pass1, viewvecs_uniform, 4, 3, viewvecs[0]);
-
- GPU_texture_bind(src, numslots++);
- GPU_shader_uniform_texture(dof_shader_pass1, color_uniform, src);
-
- GPU_texture_bind(fx->depth_buffer, numslots++);
- GPU_depth_texture_mode(fx->depth_buffer, false, true);
- GPU_shader_uniform_texture(dof_shader_pass1, depth_uniform, fx->depth_buffer);
-
- /* 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_framebuffer_slots_bind(fx->gbuffer, 0);
- GPU_framebuffer_check_valid(fx->gbuffer, NULL);
-
- glDisable(GL_DEPTH_TEST);
- glDrawArrays(GL_QUADS, 0, 4);
- /* disable bindings */
- GPU_texture_unbind(src);
- GPU_depth_texture_mode(fx->depth_buffer, true, false);
- GPU_texture_unbind(fx->depth_buffer);
-
- 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;
-
+ else {
+ /* bind the ping buffer to the color buffer */
+ GPU_framebuffer_texture_attach(fx->gbuffer, target, 0, NULL);
}
+ glDisable(GL_DEPTH_TEST);
+ glDrawArrays(GL_QUADS, 0, 4);
+ /* disable bindings */
+ GPU_texture_unbind(fx->dof_near_coc_buffer);
+ GPU_texture_unbind(fx->dof_near_coc_blurred_buffer);
+ GPU_texture_unbind(src);
+ GPU_depth_texture_mode(fx->depth_buffer, true, false);
+ GPU_texture_unbind(fx->depth_buffer);
- /* final pass, merge blurred layers according to final calculated coc */
- {
- int half_downsampled_uniform, nearfar_uniform;
-
- GPU_shader_bind(dof_shader_pass2);
-
- //GPU_shader_uniform_vector(dof_shader_pass2, dof_uniform, 4, 1, dof_params);
- //GPU_shader_uniform_vector(dof_shader_pass2, invrendertargetdim_uniform, 2, 1, invrendertargetdim);
- //GPU_shader_uniform_vector(dof_shader_pass2, viewvecs_uniform, 4, 3, viewvecs[0]);
-
- //GPU_texture_bind(src, numslots++);
- //GPU_shader_uniform_texture(dof_shader_pass5, original_uniform, src);
-
- half_downsampled_uniform = GPU_shader_get_uniform(dof_shader_pass2, "colorbuffer");
- nearfar_uniform = GPU_shader_get_uniform(dof_shader_pass2, "cocbuffer");
-
- GPU_texture_bind(fx->dof_half_downsampled, numslots++);
- GPU_shader_uniform_texture(dof_shader_pass2, half_downsampled_uniform, fx->dof_half_downsampled);
-
- GPU_texture_bind(fx->dof_nearfar_coc[0], numslots++);
- GPU_shader_uniform_texture(dof_shader_pass2, nearfar_uniform, fx->dof_nearfar_coc[0]);
-
- /* if this is the last pass, prepare for rendering on the frambuffer */
- if (passes_left-- == 1) {
- GPU_framebuffer_texture_unbind(fx->gbuffer, NULL);
- if (ofs) {
- GPU_offscreen_bind(ofs, false);
- }
- else
- GPU_framebuffer_restore();
+ /* may not be attached, in that case this just returns */
+ if (target) {
+ GPU_framebuffer_texture_detach(target);
+ if (ofs) {
+ GPU_offscreen_bind(ofs, false);
}
else {
- /* bind the ping buffer to the color buffer */
- GPU_framebuffer_texture_attach(fx->gbuffer, target, 0, NULL);
- }
- glDisable(GL_DEPTH_TEST);
- glDrawArrays(GL_QUADS, 0, 4);
- /* disable bindings */
- GPU_texture_unbind(fx->dof_half_downsampled);
- GPU_texture_unbind(fx->dof_nearfar_coc[0]);
-
- /* may not be attached, in that case this just returns */
- if (target) {
- GPU_framebuffer_texture_detach(target);
- if (ofs) {
- GPU_offscreen_bind(ofs, false);
- }
- else {
- GPU_framebuffer_restore();
- }
+ GPU_framebuffer_restore();
}
-
- SWAP(GPUTexture *, target, src);
- numslots = 0;
}
+
+ SWAP(GPUTexture *, target, src);
+ numslots = 0;
}
}
diff --git a/source/blender/gpu/intern/gpu_extensions.c b/source/blender/gpu/intern/gpu_extensions.c
index 676b6158dea..de1c4c311fa 100644
--- a/source/blender/gpu/intern/gpu_extensions.c
+++ b/source/blender/gpu/intern/gpu_extensions.c
@@ -83,8 +83,6 @@ extern char datatoc_gpu_shader_fx_vert_glsl[];
extern char datatoc_gpu_shader_fx_ssao_frag_glsl[];
extern char datatoc_gpu_shader_fx_dof_frag_glsl[];
extern char datatoc_gpu_shader_fx_dof_vert_glsl[];
-extern char datatoc_gpu_shader_fx_dof_high_frag_glsl[];
-extern char datatoc_gpu_shader_fx_dof_high_vert_glsl[];
extern char datatoc_gpu_shader_fx_lib_glsl[];
typedef struct GPUShaders {
@@ -1776,16 +1774,6 @@ GPUShader *GPU_shader_get_builtin_fx_shader(int effects, bool persp)
strcat(defines, "#define FIFTH_PASS\n");
GG.shaders.fx_shaders[offset] = GPU_shader_create(datatoc_gpu_shader_fx_dof_vert_glsl, datatoc_gpu_shader_fx_dof_frag_glsl, datatoc_gpu_shader_fx_lib_glsl, defines);
break;
-
- case GPU_SHADER_FX_DEPTH_OF_FIELD_DOWNSAMPLE_HALF:
- strcat(defines, "#define HALF_DOWNSAMPLE_PASS\n");
- GG.shaders.fx_shaders[offset] = GPU_shader_create(datatoc_gpu_shader_fx_dof_high_vert_glsl, datatoc_gpu_shader_fx_dof_high_frag_glsl, datatoc_gpu_shader_fx_lib_glsl, defines);
- break;
-
- case GPU_SHADER_FX_DEPTH_OF_FIELD_DOWNSAMPLE_HALF_COC:
- strcat(defines, "#define HALF_DOWNSAMPLE_COC_PASS\n");
- GG.shaders.fx_shaders[offset] = GPU_shader_create(datatoc_gpu_shader_fx_dof_high_vert_glsl, datatoc_gpu_shader_fx_dof_high_frag_glsl, datatoc_gpu_shader_fx_lib_glsl, defines);
- break;
}
}
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
deleted file mode 100644
index 851dd3ef767..00000000000
--- a/source/blender/gpu/shaders/gpu_shader_fx_dof_high_frag.glsl
+++ /dev/null
@@ -1,81 +0,0 @@
-uniform vec2 invrendertargetdim;
-
-//texture coordinates for framebuffer read
-varying vec4 uvcoordsvar;
-varying vec2 uv1;
-varying vec2 uv2;
-varying vec2 uv3;
-varying vec2 uv4;
-
-// color buffer
-uniform sampler2D colorbuffer;
-// depth buffer
-uniform sampler2D depthbuffer;
-// circle of confusion buffer
-uniform sampler2D cocbuffer;
-
-// this includes focal distance in x and aperture size in y
-uniform vec4 dof_params;
-// viewvectors for reconstruction of world space
-uniform vec4 viewvecs[3];
-
-/* coc calculation, positive is far coc, negative is near */
-vec4 calculate_signed_coc(in vec4 zdepth)
-{
- vec4 coc = dof_params.x * (vec4(1.0) - vec4(dof_params.y) / zdepth);
-
- /* multiply by 1.0 / sensor size to get the normalized size */
- return coc * dof_params.z;
-}
-
-void half_downsample_frag(void)
-{
- vec4 depthv, coc;
-
- depthv.r = texture2D(depthbuffer, uv1).r;
- depthv.g = texture2D(depthbuffer, uv2).r;
- depthv.b = texture2D(depthbuffer, uv3).r;
- depthv.a = texture2D(depthbuffer, uv4).r;
-
- coc = calculate_signed_coc(get_view_space_z_from_depth(vec4(viewvecs[0].z), vec4(viewvecs[1].z), depthv));
-
- /* near coc, keep the min here */
- gl_FragData[1].r = max(-min(min(coc.r, coc.g), min(coc.b, coc.a)), 0.0);
- /* far coc keep the max */
- gl_FragData[1].g = max(max(max(coc.r, coc.g), max(coc.b, coc.a)), 0.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 downsample_coc(void)
-{
- /* basically here we just assemble all nearby values from the texture and use the maximum for near coc
- * this ensures the gathe as scatter technique at the end will work */
-
- vec4 coc;
- coc.r = texture2D(cocbuffer, uv1).r;
- coc.g = texture2D(cocbuffer, uv2).r;
- coc.b = texture2D(cocbuffer, uv3).r;
- coc.a = texture2D(cocbuffer, uv4).r;
-
- gl_FragColor.r = max(max(coc.r, coc.g), max(coc.b, coc.a));
-}
-
-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.g *= coc.g;
- gl_FragColor.r *= coc.r;
-}
-
-void main(void)
-{
-#ifdef HALF_DOWNSAMPLE_PASS
- half_downsample_frag();
-#elif defined(HALF_DOWNSAMPLE_COC_PASS)
- final_combine_frag();
-#endif
-}
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
deleted file mode 100644
index fef4541eb15..00000000000
--- a/source/blender/gpu/shaders/gpu_shader_fx_dof_high_vert.glsl
+++ /dev/null
@@ -1,35 +0,0 @@
-uniform vec2 invrendertargetdim;
-
-//texture coordinates for framebuffer read
-varying vec4 uvcoordsvar;
-varying vec2 uv1;
-varying vec2 uv2;
-varying vec2 uv3;
-varying vec2 uv4;
-
-
-void vert_half_downsample(void)
-{
- uvcoordsvar = gl_MultiTexCoord0;
- gl_Position = gl_Vertex;
-
- uv1 = gl_MultiTexCoord0.xy + vec2(-0.5, -0.5) * invrendertargetdim;
- uv2 = gl_MultiTexCoord0.xy + vec2(-0.5, 0.5) * invrendertargetdim;
- uv3 = gl_MultiTexCoord0.xy + vec2(0.5, -0.5) * invrendertargetdim;
- uv4 = gl_MultiTexCoord0.xy + vec2(0.5, 0.5) * invrendertargetdim;
-}
-
-void vert_final_combine(void)
-{
- uvcoordsvar = gl_MultiTexCoord0;
- gl_Position = gl_Vertex;
-}
-
-void main(void)
-{
-#ifdef HALF_DOWNSAMPLE_PASS
- vert_half_downsample();
-#elif defined(HALF_DOWNSAMPLE_COC_PASS)
- vert_final_combine();
-#endif
-}
diff --git a/source/blender/makesdna/DNA_gpu_types.h b/source/blender/makesdna/DNA_gpu_types.h
index a49daf0dbd9..21545b168cb 100644
--- a/source/blender/makesdna/DNA_gpu_types.h
+++ b/source/blender/makesdna/DNA_gpu_types.h
@@ -32,19 +32,12 @@
#ifndef __DNA_GPU_TYPES_H__
#define __DNA_GPU_TYPES_H__
-enum DOFMode {
- DOF_QUALITY_NORMAL = 0,
- DOF_QUALITY_HIGH = 1,
-};
-
/* properties for dof effect */
typedef struct GPUDOFOptions {
float dof_focus_distance; /* focal distance for depth of field */
float dof_fstop;
float dof_focal_length;
float dof_sensor;
- int dof_quality_mode;
- int dof_num_blades;
} GPUDOFOptions;
/* properties for SSAO effect */
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
index 772795ef855..7306d9779b6 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -3842,12 +3842,6 @@ static void rna_def_gpu_dof_fx(BlenderRNA *brna)
StructRNA *srna;
PropertyRNA *prop;
- static EnumPropertyItem dof_quality_items[] = {
- {DOF_QUALITY_NORMAL, "NORMAL", 0, "Normal", "Use normal quality depth of field"},
- {DOF_QUALITY_HIGH, "HIGH", 0, "High", "Use high quality blurring depth of field"},
- {0, NULL, 0, NULL, NULL}
- };
-
srna = RNA_def_struct(brna, "GPUDOFOptions", NULL);
RNA_def_struct_ui_text(srna, "GPU DOF", "Options for GPU based depth of field");
RNA_def_struct_ui_icon(srna, ICON_RENDERLAYERS);
@@ -3876,16 +3870,6 @@ static void rna_def_gpu_dof_fx(BlenderRNA *brna)
RNA_def_property_range(prop, 0.0f, FLT_MAX);
RNA_def_property_ui_range(prop, 0.1f, 64.0f, 10, 1);
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
-
- prop = RNA_def_property(srna, "dof_quality_mode", PROP_ENUM, PROP_NONE);
- RNA_def_property_ui_text(prop, "Quality", "Quality of the dof effect");
- RNA_def_property_enum_items(prop, dof_quality_items);
- RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
-
- prop = RNA_def_property(srna, "dof_num_blades", PROP_INT, PROP_NONE);
- RNA_def_property_ui_text(prop, "Blades", "Number of blades in camera");
- RNA_def_property_range(prop, 5, 8);
- RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
}
static void rna_def_gpu_ssao_fx(BlenderRNA *brna)