Grease Pencil Ignores 'Stroke Placement: Stroke' #81950

Closed
opened 2020-10-22 10:02:12 +02:00 by Dong-Hyun Kim · 24 comments
Member

System Information
Operating system: Windows 10 64-bit 2004
Graphics card: NVIDIA Geforce 2070 Super
CPU: AMD Ryzen 7 3700X (8-core)

Blender Version
Broken: example: 2.90.1, master
Broken: 2.83.0
Worked: 2.82a
Caused by 29f3af9527

Short description of error
Grease Pencil Ignores Stroke Placement: Stroke
It Just behaves like Stroke Placement: 3D Cursor (When 3D cursor is closer to the viewpoint than the base stroke)
or partially behaves like Stoke Placement: 3D Cursor (When 3D cursor is farther from the viewpoint than the base stroke).

Exact steps for others to reproduce the error
I tried my best to describe it clearly in the video.
To summarize, You only have to draw strokes in the 3D space and try Stroke Placement: Stroke.

This is from 2.80
GP Stroke Placement on 2.80.mp4

And This is from 2.90.1
GP Stroke Placement on 2.90.1.mp4

**System Information** Operating system: Windows 10 64-bit 2004 Graphics card: NVIDIA Geforce 2070 Super CPU: AMD Ryzen 7 3700X (8-core) **Blender Version** Broken: example: 2.90.1, master Broken: 2.83.0 Worked: 2.82a Caused by 29f3af9527 **Short description of error** Grease Pencil Ignores **Stroke Placement: Stroke** It Just behaves like **Stroke Placement: 3D Cursor** (When 3D cursor is closer to the viewpoint than the base stroke) or partially behaves like **Stoke Placement: 3D Cursor** (When 3D cursor is farther from the viewpoint than the base stroke). **Exact steps for others to reproduce the error** I tried my best to describe it clearly in the video. To summarize, You only have to draw strokes in the 3D space and try **Stroke Placement: Stroke**. This is from 2.80 [GP Stroke Placement on 2.80.mp4](https://archive.blender.org/developer/F9033314/GP_Stroke_Placement_on_2.80.mp4) And This is from 2.90.1 [GP Stroke Placement on 2.90.1.mp4](https://archive.blender.org/developer/F9033315/GP_Stroke_Placement_on_2.90.1.mp4)

#81927 was marked as duplicate of this issue

#81927 was marked as duplicate of this issue
Author
Member

Added subscriber: @temeddix

Added subscriber: @temeddix
Dong-Hyun Kim changed title from Grease Pencil Ignores 'Stroke Placement as Stroke' to Grease Pencil Ignores 'Stroke Placement: Stroke' 2020-10-22 11:04:54 +02:00
Member

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

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

Added subscribers: @Lovely_Bigga, @lichtwerk

Added subscribers: @Lovely_Bigga, @lichtwerk

Added subscribers: @fclem, @antoniov

Added subscribers: @fclem, @antoniov

@lichtwerk The code is using ED_view3d_autodist_depth()and ED_view3d_autodist_depth_seg() and this was not changed in the refactor (this is old code). I don't know if these functions are working as expected. @fclem any clue?

@lichtwerk The code is using `ED_view3d_autodist_depth()`and `ED_view3d_autodist_depth_seg()` and this was not changed in the refactor (this is old code). I don't know if these functions are working as expected. @fclem any clue?

Added subscriber: @GabrielMontagne

Added subscriber: @GabrielMontagne

Has this issue been fixed? I need to work with grease pencil every day and every day I face this issue.

Has this issue been fixed? I need to work with grease pencil every day and every day I face this issue.
Member

Dare setting this to High (since the feature is basically broken)

Dare setting this to High (since the feature is basically broken)

In #81950#1056356, @lichtwerk wrote:
Dare setting this to High (since the feature is basically broken)

... and it invalidates, for example, all the training anyone is using about how to use GP.

> In #81950#1056356, @lichtwerk wrote: > Dare setting this to High (since the feature is basically broken) ... and it invalidates, for example, all the training anyone is using about how to use GP.

I'm going to bisect to find the bad commit.

I'm going to bisect to find the bad commit.
Member

Broke between eed1beff88 and fa823f0af8 probably 29f3af9527

Broke between eed1beff88 and fa823f0af8 probably 29f3af9527
Member

Maybe #78574 (GPencil: Z pass combine not work ) is related?

Maybe #78574 (GPencil: Z pass combine not work ) is related?

Yes i can confirm the bad commit is 29f3af9527.

Yes i can confirm the bad commit is 29f3af9527.

Added subscriber: @dfelinto

Added subscriber: @dfelinto

Since this is broken since March I'm tagging as 2.92 to free 2.91 to move to bcon4 regardless of this. That said a fix for this would still be welcome in 2.91 if done in time.

Since this is broken since March I'm tagging as 2.92 to free 2.91 to move to bcon4 regardless of this. That said a fix for this would still be welcome in 2.91 if done in time.

Added subscriber: @JamellMoore

Added subscriber: @JamellMoore

Hi all. Thanks for working so hard on a fantastic tool. I'm a new developer here. I've been dabbling with programming and computer graphics for years now as a hobbyist but now have realized graphics programming is what I really want to do as a career. The fact that Blender is open source gives me a good opportunity to gain some experience and develop my skills.

I was reviewing the GPencil code to try to improve on how the brush size could be presented to the user and handled internally but I thought it would be better to help fix bugs first, where I can.

My findings regarding this bug

  1. When drawing a stroke with the gpencil draw tool and the greasepencil_stroke_placement_view3d setting set to 'surface' or 'stroke', a new stroke is made that interpolates between the points that hit a surface/stroke.
  2. When drawing a stroke, a check is made around each buffer point to see if it is over existing strokes by reading the depth values within the depth buffer. If depth isn't found around the point the point isn't over an existing stroke. It is then invalidated. The draw tool with stroke placement set to stroke only wants to interpolate between points that hit existing strokes.
  3. When checking for depth around the stroke area by indirectly calling view3d_opengl_read_Z_pixels some of the depths have values of approx 0.99 (Near the far plane) if stroke placement is 'stroke'. This is NOT THE EXPECTED RESULT. All points that projected into the background should have a depth value of 1.0 in the z-buffer.
  4. I ran a test by setting the depth values to 0.5 (arbitrary) in the gpencil_frag.glsl shader and recorded the values around a single point: when view3d_opengl_read_Z_pixels is called. Values around the point were 0.5. This indicated that the drawn stroke was drawn to the depth buffer before depth tests can be carried out.
  5. I looked at the previous implementation and found that when do_fast_drawing is enabled, in the gpencil engine, the current view is frozen and the paint stroke is drawn in a different pass without recording depth. This is possible because the view is stationary whilst a stroke is drawn.
  6. In the new implementation do_fast_drawing is never enabled. On Line 262: gpencil_engine.c it reads pd->do_fast_drawing = false; /* TODO option */. If this is set to true the stroke placement feature works. See video.

Fix-#81950-GPencil-Stroke-Placement-Solution-VID-01.mp4

So my question now is - is fast_drawing feature fully implemented in its current state, so that we can test and commit this change?

Hi all. Thanks for working so hard on a fantastic tool. I'm a new developer here. I've been dabbling with programming and computer graphics for years now as a hobbyist but now have realized graphics programming is what I really want to do as a career. The fact that Blender is open source gives me a good opportunity to gain some experience and develop my skills. I was reviewing the GPencil code to try to improve on how the brush size could be presented to the user and handled internally but I thought it would be better to help fix bugs first, where I can. **My findings regarding this bug** 1. When drawing a stroke with the gpencil draw tool and the greasepencil_stroke_placement_view3d setting set to 'surface' or 'stroke', a new stroke is made that interpolates between the points that hit a surface/stroke. 2. When drawing a stroke, a check is made around each buffer point to see if it is over existing strokes by reading the depth values within the depth buffer. If depth isn't found around the point the point isn't over an existing stroke. It is then invalidated. The draw tool with stroke placement set to stroke only wants to interpolate between points that hit existing strokes. 3. When checking for depth around the stroke area by indirectly calling view3d_opengl_read_Z_pixels some of the depths have values of approx 0.99 (Near the far plane) if stroke placement is 'stroke'. This is NOT THE EXPECTED RESULT. All points that projected into the background should have a depth value of 1.0 in the z-buffer. 4. I ran a test by setting the depth values to 0.5 (arbitrary) in the gpencil_frag.glsl shader and recorded the values around a single point: when view3d_opengl_read_Z_pixels is called. Values around the point were 0.5. This indicated that the drawn stroke was drawn to the depth buffer before depth tests can be carried out. 5. I looked at the previous implementation and found that when do_fast_drawing is enabled, in the gpencil engine, the current view is frozen and the paint stroke is drawn in a different pass without recording depth. This is possible because the view is stationary whilst a stroke is drawn. 6. In the new implementation do_fast_drawing is never enabled. On Line 262: gpencil_engine.c it reads `pd->do_fast_drawing = false; /* TODO option */`. If this is set to true the stroke placement feature works. See video. [Fix-#81950-GPencil-Stroke-Placement-Solution-VID-01.mp4](https://archive.blender.org/developer/F9409508/Fix-#81950-GPencil-Stroke-Placement-Solution-VID-01.mp4) So my question now is - is fast_drawing feature fully implemented in its current state, so that we can test and commit this change?

Fast Drawing was developed as Plan B, but never was enabled. Our plan is to remove this feature if it's not required, so enable this is not the solution. Anyway, @fclem can give you a better answer than me.

Fast Drawing was developed as `Plan B`, but never was enabled. Our plan is to remove this feature if it's not required, so enable this is not the solution. Anyway, @fclem can give you a better answer than me.

Thanks Antonio. I will look into this further and wait for more information from Clement.

Sorry about the diff. I had just pushed it as you responded.

Thanks Antonio. I will look into this further and wait for more information from Clement. Sorry about the diff. I had just pushed it as you responded.

I just wanted to clarify my original findings so that I don't cause confusion for anyone else who is looking into this. There was a small mistake.

I have tested this in 2.82.7 where the feature is working correctly. In this version I have followed the execution path and fast drawing is definitely enabled with the GP_DRW_PAINT_PAINTING flag. The do_fast_drawing flag doesn't exist in this version.

That being said I have since found that the in 2.82.7 the following is used in gpencil_engine.c to check whether the draw call is for depth.

/* if the draw is for select, do a basic drawing and return */
  if (DRW_state_is_select() || DRW_state_is_depth()) {
    drw_gpencil_select_render(stl, psl);
    return;
  }

With this commented out the feature breaks so I believe this needs to be reimplemented in some way. Despite the name drw_gpencil_select_render handles the drawing for depth test passes also.

I just wanted to clarify my original findings so that I don't cause confusion for anyone else who is looking into this. There was a small mistake. I have tested this in 2.82.7 where the feature is working correctly. In this version I have followed the execution path and fast drawing is definitely enabled with the GP_DRW_PAINT_PAINTING flag. The do_fast_drawing flag doesn't exist in this version. That being said I have since found that the in 2.82.7 the following is used in gpencil_engine.c to check whether the draw call is for depth. ``` /* if the draw is for select, do a basic drawing and return */ if (DRW_state_is_select() || DRW_state_is_depth()) { drw_gpencil_select_render(stl, psl); return; } ``` With this commented out the feature breaks so I believe this needs to be reimplemented in some way. Despite the name drw_gpencil_select_render handles the drawing for depth test passes also.

I was a bit hasty with my previous diagnosis but I believe my current diff has solved the problem without introducing any other problems. I believe the depth_only_fb is intended for doing partial depth tests so the stroke buffers just needed to be excluded from the depth only draw calls.

Question: Have there been any thoughts about caching the results of the depths whilst drawing each stroke? If so how would you go about it?

I was a bit hasty with my previous diagnosis but I believe my current diff has solved the problem without introducing any other problems. I believe the depth_only_fb is intended for doing partial depth tests so the stroke buffers just needed to be excluded from the depth only draw calls. Question: Have there been any thoughts about caching the results of the depths whilst drawing each stroke? If so how would you go about it?

This issue was referenced by 5b73083d4f

This issue was referenced by 5b73083d4f207690e89f3a8863480de2bb4df24d

Changed status from 'Confirmed' to: 'Resolved'

Changed status from 'Confirmed' to: 'Resolved'
Antonio Vazquez self-assigned this 2020-12-08 16:50:30 +01:00
Thomas Dinges added this to the 2.92 milestone 2023-02-08 16:16:03 +01:00
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
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
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
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
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
EEVEE & Viewport
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
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 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
9 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#81950
No description provided.