Fix: Overlay-Next: Images #130345

Merged
Miguel Pozo merged 8 commits from pragma37/blender:fix-overlay-images into main 2024-11-20 19:05:40 +01:00
Member

Several fixes for Camera and Empty images.

Several fixes for Camera and Empty images.
Miguel Pozo added the
Module
Viewport & EEVEE
Interest
Overlay
labels 2024-11-15 19:45:34 +01:00
Miguel Pozo added 6 commits 2024-11-15 19:45:46 +01:00
Fix view_reference_images
Add depth_bias_winmat
Some checks failed
buildbot/vexp-code-patch-lint Build done.
buildbot/vexp-code-patch-darwin-arm64 Build done.
buildbot/vexp-code-patch-linux-x86_64 Build done.
buildbot/vexp-code-patch-darwin-x86_64 Build done.
buildbot/vexp-code-patch-windows-amd64 Build done.
buildbot/vexp-code-patch-coordinator Build done.
3bf9e7bd86
Miguel Pozo added a new dependency 2024-11-15 19:46:24 +01:00
Miguel Pozo force-pushed fix-overlay-images from 3ce933e936 to 75166034ee 2024-11-15 19:58:31 +01:00 Compare
Miguel Pozo force-pushed fix-overlay-images from 75166034ee to 69598ce5ea 2024-11-15 20:04:40 +01:00 Compare
Miguel Pozo requested review from Clément Foucault 2024-11-15 20:07:28 +01:00
Miguel Pozo force-pushed fix-overlay-images from 69598ce5ea to f5029a5649 2024-11-18 17:24:42 +01:00 Compare
Miguel Pozo force-pushed fix-overlay-images from f5029a5649 to 66262d3d91 2024-11-18 19:59:53 +01:00 Compare
Miguel Pozo force-pushed fix-overlay-images from 66262d3d91 to 72b6214125 2024-11-18 20:03:28 +01:00 Compare
Clément Foucault reviewed 2024-11-19 18:21:13 +01:00
@ -401,3 +401,3 @@
init_pass(background_ps_, draw_state);
draw_state = DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_ALPHA_UNDER_PREMUL;
draw_state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_LESS | DRW_STATE_BLEND_ALPHA_UNDER_PREMUL;

Can you explain these states changes? As the original values are the ones from the legacy code. So I imagined that they would work?

Can you explain these states changes? As the original values are the ones from the legacy code. So I imagined that they would work?
Author
Member

I'm not sure, maybe Legacy rendered the background on a separate texture?
But without this in Next the background images are rendered on top of the main render.

imagen

I'm not sure, maybe Legacy rendered the background on a separate texture? But without this in Next the background images are rendered on top of the main render. ![imagen](/attachments/4cde34d0-d793-4803-8428-7147575057c4)

Camera Background images used to be rendered on the default framebuffer, so not on the overlay framebuffer.

void OVERLAY_image_scene_background_draw(OVERLAY_Data *vedata)
{
  OVERLAY_PassList *psl = vedata->psl;

  if (DRW_state_is_fbo() && (!DRW_pass_is_empty(psl->image_background_scene_ps) ||
                             !DRW_pass_is_empty(psl->image_foreground_scene_ps)))
  {
    const DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get();
    GPU_framebuffer_bind(dfbl->default_fb);

    DRW_draw_pass(psl->image_background_scene_ps);
    DRW_draw_pass(psl->image_foreground_scene_ps);
  }
}

So in overlay next term, this correspond to resources.render(_in_front)_fb. Add a draw_on_render method to Cameras.

Camera Background images used to be rendered on the default framebuffer, so not on the overlay framebuffer. ``` void OVERLAY_image_scene_background_draw(OVERLAY_Data *vedata) { OVERLAY_PassList *psl = vedata->psl; if (DRW_state_is_fbo() && (!DRW_pass_is_empty(psl->image_background_scene_ps) || !DRW_pass_is_empty(psl->image_foreground_scene_ps))) { const DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get(); GPU_framebuffer_bind(dfbl->default_fb); DRW_draw_pass(psl->image_background_scene_ps); DRW_draw_pass(psl->image_foreground_scene_ps); } } ``` So in overlay next term, this correspond to `resources.render(_in_front)_fb`. Add a `draw_on_render` method to `Cameras`.

Also don't forget to group the draw_on_render together to avoid framebuffer switching.

Also don't forget to group the `draw_on_render` together to avoid framebuffer switching.
Author
Member

It has been a bit confusing but I think I managed to mimic 100% the Legacy behavior.

"View as render" background images were rendered to the default framebuffer.
Non "View as render" background images were rendered to the overlay framebuffer.
Next Background cleared the overlay framebuffer as part of its pass. The clear had to be moved before the background image passes.
That DRW_STATE_DEPTH_GREATER did nothing in Legacy, it draws to a framebuffer without a depth attachment.

It has been a bit confusing but I think I managed to mimic 100% the Legacy behavior. "View as render" background images were rendered to the default framebuffer. Non "View as render" background images were rendered to the overlay framebuffer. Next Background cleared the overlay framebuffer as part of its pass. The clear had to be moved before the background image passes. That `DRW_STATE_DEPTH_GREATER` did nothing in Legacy, it draws to a framebuffer without a depth attachment.
fclem marked this conversation as resolved
@ -510,6 +510,7 @@ void Instance::draw(Manager &manager)
draw_layer_color_only(regular, resources.overlay_color_only_fb);
draw_layer_color_only(infront, resources.overlay_color_only_fb);
regular.empties.draw_in_front_images(resources.overlay_color_only_fb, manager, view);

If I remember, there is no regular because they are all in front. But I guess that makes sense to have both.

If I remember, there is no regular because they are all in front. But I guess that makes sense to have both.
Author
Member

Nope, that could be the case if we moved the In Front detection to Instance::object_is_in_front as I suggested in the chat.
Without this change, empties with OB_EMPTY_IMAGE_DEPTH_FRONT (that's the Depth setting in the Empty Data panel) but without "Object > Viewport Display > In Front" enabled won't be rendered.

Nope, that could be the case if we moved the In Front detection to `Instance::object_is_in_front` as I suggested in the chat. Without this change, empties with `OB_EMPTY_IMAGE_DEPTH_FRONT` (that's the Depth setting in the Empty Data panel) but without "Object > Viewport Display > In Front" enabled won't be rendered.
fclem marked this conversation as resolved
Miguel Pozo added 3 commits 2024-11-20 18:06:20 +01:00
Miguel Pozo added 1 commit 2024-11-20 18:10:31 +01:00
Miguel Pozo added 1 commit 2024-11-20 18:25:45 +01:00
Clément Foucault approved these changes 2024-11-20 18:50:22 +01:00
Miguel Pozo merged commit 03909f2691 into main 2024-11-20 19:05:40 +01:00
Miguel Pozo deleted branch fix-overlay-images 2024-11-20 19:05:43 +01:00
Sign in to join this conversation.
No reviewers
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Code Documentation
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Viewport & EEVEE
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Asset Browser Project
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Module
Viewport & EEVEE
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Severity
High
Severity
Low
Severity
Normal
Severity
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Depends on
Reference: blender/blender#130345
No description provided.