diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2021-06-06 15:14:19 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2021-06-06 17:36:02 +0300 |
commit | 6c1e7868c7a88bbd7038519599298f27faa430f8 (patch) | |
tree | f9af9763584ad090a33fbd467479a5718f71ed60 /source/blender/draw/engines/eevee | |
parent | 9b153666e70ef8b89a257b76040da27455c55e50 (diff) |
EEVEE: LookDev: Move rendering to view render.
This makes is possible to have AA and correct blending of the
forward rendered spheres.
However, to avoid distorded spheres we need to not support Lookdev
in panoramic projection mode.
Also remove support for LookDev when using render border for now.
Diffstat (limited to 'source/blender/draw/engines/eevee')
4 files changed, 20 insertions, 9 deletions
diff --git a/source/blender/draw/engines/eevee/eevee_instance.cc b/source/blender/draw/engines/eevee/eevee_instance.cc index faeecb50d04..5d820e3c1fd 100644 --- a/source/blender/draw/engines/eevee/eevee_instance.cc +++ b/source/blender/draw/engines/eevee/eevee_instance.cc @@ -76,7 +76,7 @@ void Instance::init(const ivec2 &output_res, velocity.init(); shadows.init(); lightprobes.init(); - lookdev.init(output_res); + lookdev.init(output_res, &render_border); } rcti Instance::output_crop(const int res[2], const rcti *crop) @@ -285,8 +285,6 @@ void Instance::draw_viewport(DefaultFramebufferList *dfbl) render_passes.resolve_viewport(dfbl); - lookdev.render_overlay(dfbl->default_fb); - if (!sampling.finished_viewport()) { DRW_viewport_request_redraw(); } diff --git a/source/blender/draw/engines/eevee/eevee_lookdev.cc b/source/blender/draw/engines/eevee/eevee_lookdev.cc index ba1b8fde094..1c6baa02d5d 100644 --- a/source/blender/draw/engines/eevee/eevee_lookdev.cc +++ b/source/blender/draw/engines/eevee/eevee_lookdev.cc @@ -86,7 +86,7 @@ bNodeTree *LookDevWorldNodeTree::nodetree_get(float strength) * use custom shader to draw the background. * \{ */ -void LookDev::init(const ivec2 &output_res) +void LookDev::init(const ivec2 &output_res, const rcti *render_border) { StudioLight *studiolight = nullptr; if (inst_.v3d) { @@ -128,7 +128,7 @@ void LookDev::init(const ivec2 &output_res) GPU_material_free(&material); } - if (do_overlay()) { + if (do_overlay(output_res, render_border)) { rcti rect; if (DRW_state_is_opengl_render()) { BLI_rcti_init(&rect, 0, output_res.x, 0, output_res.y); @@ -167,7 +167,7 @@ void LookDev::init(const ivec2 &output_res) } } -bool LookDev::do_overlay(void) +bool LookDev::do_overlay(const ivec2 &output_res, const rcti *render_border) { const View3D *v3d = inst_.v3d; /* Only show the HDRI Preview in Shading Preview in the Viewport. */ @@ -184,6 +184,13 @@ bool LookDev::do_overlay(void) if ((v3d->overlay.flag & V3D_OVERLAY_LOOK_DEV) == 0) { return false; } + if (inst_.camera.is_panoramic()) { + return false; + } + if (output_res != ivec2(BLI_rcti_size_x(render_border), BLI_rcti_size_y(render_border))) { + /* TODO(fclem) support this case. */ + return false; + } return true; } @@ -277,6 +284,10 @@ void LookDev::sync_overlay(void) LightModule &lights = inst_.lights; LightProbeModule &lightprobes = inst_.lightprobes; + /* Jitter for AA. */ + vec2 jitter = -0.5f + vec2(inst_.sampling.rng_get(SAMPLING_FILTER_U), + inst_.sampling.rng_get(SAMPLING_FILTER_V)); + /* Matrix used to position the spheres in viewport space. */ mat4 sphere_mat; copy_m4_m4(sphere_mat, cam.viewmat); @@ -308,7 +319,7 @@ void LookDev::sync_overlay(void) /* Pass 2D scale and bias factor in the last column. */ vec2 scale = sphere_size_ / vec2(viewport_size); - vec2 bias = -1.0f + scale + 2.0f * (anchor_ + offset) / vec2(viewport_size); + vec2 bias = -1.0f + scale + 2.0f * (anchor_ + offset + jitter) / vec2(viewport_size); copy_v4_fl4(sphere_mat[3], UNPACK2(scale), UNPACK2(bias)); DRW_shgroup_call_obmat(grp, sphere, sphere_mat); diff --git a/source/blender/draw/engines/eevee/eevee_lookdev.hh b/source/blender/draw/engines/eevee/eevee_lookdev.hh index 3c98be7018f..092c33ed98c 100644 --- a/source/blender/draw/engines/eevee/eevee_lookdev.hh +++ b/source/blender/draw/engines/eevee/eevee_lookdev.hh @@ -92,7 +92,7 @@ class LookDev { GPU_material_free(&material); }; - void init(const ivec2 &output_res); + void init(const ivec2 &output_res, const rcti *render_border); void sync_background(void); bool sync_world(void); @@ -104,7 +104,7 @@ class LookDev { void rotation_get(mat4 r_mat); private: - bool do_overlay(void); + bool do_overlay(const ivec2 &output_res, const rcti *render_border); }; /** \} */ diff --git a/source/blender/draw/engines/eevee/eevee_view.cc b/source/blender/draw/engines/eevee/eevee_view.cc index 8fe496acf49..72e2baa6815 100644 --- a/source/blender/draw/engines/eevee/eevee_view.cc +++ b/source/blender/draw/engines/eevee/eevee_view.cc @@ -138,6 +138,8 @@ void ShadingView::render(void) inst_.lightprobes.draw_cache_display(); + inst_.lookdev.render_overlay(view_fb_); + inst_.shading_passes.forward.render(); velocity_.render(depth_tx_); |