inverted GL_DEPTH_TEST behavior depending on object selection or presence of non-geo object #82843

Closed
opened 2 years ago by MACHIN3 · 9 comments

System Information
Operating system: Linux-4.15.0-117-generic-x86_64-with-debian-buster-sid 64 Bits
Graphics card: GeForce GTX 1050/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 435.21

Blender Version
Broken: version: 2.91.0 Beta, branch: master, commit date: 2020-11-18 18:54, hash: ad58999b0d
Worked: 2.90.1

Short description of error
Drawing anything using the GPU shader module and using bgl.GL_DEPTH_TEST produces odd behavior in 2.91.
In the example below bgl.GL_DEPTH_TEST is enabled to have geometry occlude what is drawn. This worked fine in the past.

In 2.91, this only works if geometry is selected(and so the selection outline overlay is drawn). With the object not selected, the depth test occlusion will behave inverted: Drawing when occluded and not drawing when revealed.

In addition to selecting, having an empty or other non-geo objects present will also correct this behavior.

import bpy
from mathutils import Vector
import gpu
from gpu_extras.batch import batch_for_shader
import bgl

def draw():
    shader = gpu.shader.from_builtin('3D_UNIFORM_COLOR')
    shader.bind()
    shader.uniform_float("color", (1, 0, 0, 0.5))

    bgl.glEnable(bgl.GL_DEPTH_TEST)

    bgl.glPointSize(10)

    batch = batch_for_shader(shader, 'POINTS', {"pos": [Vector((0, 0, 1))]})
    batch.draw(shader)
    

bpy.types.SpaceView3D.draw_handler_add(draw, (), 'WINDOW', 'POST_VIEW')
bpy.context.area.tag_redraw()

demo video
inverted GL_DEPTH_TEST behavior depending on object selection or non-geo object presence.blend

Exact steps for others to reproduce the error

  • open the blend file in a recent 2.91 beta build
  • run the script, a red dot will be drawn in the 3d view (move the viewport to force the area to redraw)
  • the dot should be occluded, but isn't
  • select the cube and it will be occluded, move it to reveal the dot
  • deselect the cube and the dot will be hidden, even though its outside the cube now
  • create an empty and the dot will again be drawn when outside the cube, and hidden when occluded by it, no matter what your selection is, as you'd expect
**System Information** Operating system: Linux-4.15.0-117-generic-x86_64-with-debian-buster-sid 64 Bits Graphics card: GeForce GTX 1050/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 435.21 **Blender Version** Broken: version: 2.91.0 Beta, branch: master, commit date: 2020-11-18 18:54, hash: `ad58999b0d` Worked: 2.90.1 **Short description of error** Drawing anything using the GPU shader module and using `bgl.GL_DEPTH_TEST` produces odd behavior in 2.91. In the example below `bgl.GL_DEPTH_TEST` is enabled to have geometry occlude what is drawn. This worked fine in the past. In 2.91, this only works if geometry is selected(and so the selection outline overlay is drawn). With the object not selected, the depth test occlusion will behave inverted: Drawing when occluded and not drawing when revealed. In addition to selecting, having an empty or other non-geo objects present will also correct this behavior. ``` import bpy from mathutils import Vector import gpu from gpu_extras.batch import batch_for_shader import bgl def draw(): shader = gpu.shader.from_builtin('3D_UNIFORM_COLOR') shader.bind() shader.uniform_float("color", (1, 0, 0, 0.5)) bgl.glEnable(bgl.GL_DEPTH_TEST) bgl.glPointSize(10) batch = batch_for_shader(shader, 'POINTS', {"pos": [Vector((0, 0, 1))]}) batch.draw(shader) bpy.types.SpaceView3D.draw_handler_add(draw, (), 'WINDOW', 'POST_VIEW') bpy.context.area.tag_redraw() ``` [demo video ](https://www.youtube.com/watch?v=oy3PDDSdSdY) [inverted GL_DEPTH_TEST behavior depending on object selection or non-geo object presence.blend](https://archive.blender.org/developer/F9325495/inverted_GL_DEPTH_TEST_behavior_depending_on_object_selection_or_non-geo_object_presence.blend) **Exact steps for others to reproduce the error** * open the blend file in a recent 2.91 beta build * run the script, a red dot will be drawn in the 3d view (move the viewport to force the area to redraw) * the dot should be occluded, but isn't * select the cube and it will be occluded, move it to reveal the dot * deselect the cube and the dot will be hidden, even though its outside the cube now * create an empty and the dot will again be drawn when outside the cube, and hidden when occluded by it, no matter what your selection is, as you'd expect
Poster

Added subscriber: @MACHIN3

Added subscriber: @MACHIN3

Added subscriber: @Pinnhead

Added subscriber: @Pinnhead

version: 2.91.0 Beta, branch: master, commit date: 2020-11-18 18:54, hash: ad58999b0d, type: Release
build date: 2020-11-19, 00:04:58
platform: Windows

Exactly the same behavior as described.

version: 2.91.0 Beta, branch: master, commit date: 2020-11-18 18:54, hash: ad58999b0d46, type: Release build date: 2020-11-19, 00:04:58 platform: Windows Exactly the same behavior as described.
Collaborator

Added subscriber: @mano-wii

Added subscriber: @mano-wii
Collaborator

Changed status from 'Needs Triage' to: 'Confirmed'

Changed status from 'Needs Triage' to: 'Confirmed'
Collaborator

Apparently the default status has changed and now you have to put a bgl.glDepthFunc(bgl.GL_LEQUAL) before :
This change is inconvenient as it can break some addons and GL_LEQUAL is certainly more suitable as the default.
However, it is good to keep in mind that some addon callbacks can change the drawing status without warning.

Perhaps this is another problem to be considered in blender/blender-addons#80730 (BGL deprecation).

Apparently the default status has changed and now you have to put a `bgl.glDepthFunc(bgl.GL_LEQUAL)` before :\ This change is inconvenient as it can break some addons and `GL_LEQUAL` is certainly more suitable as the default. However, it is good to keep in mind that some addon callbacks can change the drawing status without warning. Perhaps this is another problem to be considered in blender/blender-addons#80730 (BGL deprecation).
Poster

Thanks for pointing that out, much appreciated!

Thanks for pointing that out, much appreciated!
Owner

Closed as duplicate of #81334

Closed as duplicate of #81334
ideasman42 closed this issue 2 years ago
Owner

Changed status from 'Duplicate' to: 'Resolved'

Changed status from 'Duplicate' to: 'Resolved'
Sign in to join this conversation.
No Label
Interest/Alembic
Interest/Animation & Rigging
Interest/Asset Browser
Interest/Asset Browser Project Overview
Interest/Audio
Interest/Automated Testing
Interest/Blender Asset Bundle
Interest/Collada
Interest/Compositing
Interest/Core
Interest/Cycles
Interest/Datablocks and Libraries
Interest/Dependency Graph
Interest/Overrides
Interest/Performance
Interest/Pipeline, Assets & I/O
Interest/Translations
Interest/Undo
Interest/USD
Interest/Video Sequencer
legacy module/Animation & Rigging
legacy module/Core
legacy module/Development Management
legacy module/Eevee & Viewport
legacy module/Grease Pencil
legacy module/Modeling
legacy module/Nodes & Physics
legacy module/Pipeline, Assets & IO
legacy module/Platforms, Builds, Tests & Devices
legacy module/Python API
legacy module/Rendering & Cycles
legacy module/Sculpt, Paint & Texture
legacy module/Triaging
legacy module/User Interface
legacy module/VFX & Video
legacy project/1.0.0-beta.2
legacy project/Asset Browser (Archived)
legacy project/BF Blender: 2.8
legacy project/BF Blender: After Release
legacy project/BF Blender: Next
legacy project/BF Blender: Regressions
legacy project/BF Blender: Unconfirmed
legacy project/Blender 2.70
legacy project/Code Quest
legacy project/Development Management
legacy project/Eevee
legacy project/Eevee & Viewport
legacy project/Freestyle
legacy project/Game Animation
legacy project/Game Audio
legacy project/Game Data Conversion
legacy project/Game Engine
legacy project/Game Logic
legacy project/Game Physics
legacy project/Game Python
legacy project/Game Rendering
legacy project/Game UI
legacy project/Geometry Nodes
legacy project/GPU / Viewport
legacy project/Grease Pencil
legacy project/GSoC
legacy project/Images & Movies
legacy project/Import/Export
legacy project/Infrastructure: Websites
legacy project/LibOverrides - Usability and UX
legacy project/Line Art
legacy project/Masking
legacy project/Milestone 1: Basic, Local Asset Browser
legacy project/Modeling
legacy project/Modifiers
legacy project/Motion Tracking
legacy project/Nodes
legacy project/Nodes & Physics
legacy project/OpenGL Error
legacy project/Papercut
legacy project/Performance
legacy project/Physics
legacy project/Platforms, Builds, Tests & Devices
legacy project/Pose Library Basics
legacy project/Python API
legacy project/Render & Cycles
legacy project/Render Pipeline
legacy project/Retrospective
legacy project/Sculpt, Paint & Texture
legacy project/Text Editor
legacy project/Tracker Curfew
legacy project/Triaging
legacy project/User Interface
legacy project/UV Editing
legacy project/VFX & Video
legacy project/Virtual Reality
legacy project/Wintab High Frequency
Meta/Good First Issue
Meta/Papercut
migration/requires-manual-verification
Module › Animation & Rigging
Module › Core
Module › Development Management
Module › Eevee & Viewport
Module › Grease Pencil
Module › Modeling
Module › Nodes & Physics
Module › Pipeline, Assets & IO
Module › Platforms, Builds, Tests & Devices
Module › Python API
Module › Render & Cycles
Module › Sculpt, Paint & Texture
Module › Triaging
Module › User Interface
Module › VFX & Video
Platform/FreeBSD
Platform/Linux
Platform/macOS
Platform/Windows
Priority › High
Priority › Low
Priority › Normal
Priority › Unbreak Now!
Status › Archived
Status › Confirmed
Status › Duplicate
Status › Needs Information 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
4 Participants
Notifications
Due Date

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#82843
Loading…
There is no content yet.