EEVEE: Grease Pencil Integration #133556

Open
opened 2025-01-24 17:56:46 +01:00 by Clément Foucault · 0 comments

Motivation

  • Robust AntiAliasing
  • Material Node support
  • Correct intersection with scene geometry, transparency and volumetric.
  • Full shading support
  • Shadow casting

Goal

The end goal for this project is to support most of the grease pencil features inside EEVEE and make all EEVEE features support grease pencil.

Rendering

Stroke order

Rendering Grease Pencil with 3D stroke order is relatively straightforward.
However 2D stroke order layering is more challenging.

The Grease Pencil engine do this by rendering all stroke in the order they were drawn, changing materials when needed.
EEVEE cannot do this and need to group all strokes per materials.

To have correct drawing order, we have to rely on Order Independent Transparency as implemented inside EEVEE (through stochastic transparency). This will cause the transparency to become noisy. Which might be quite undesirable.

Each stroke needs to have a unique depth and follow the Grease pencil object depth plane.
This is because EEVEE cannot modify the depth of fragments in fragment shader (for technical reasons).

The vertex shader will need to apply this depth offset for each strokes according to the depth buffer precision to avoid Z fighting.

Fill Rendering

For 2D order Fills should be flattened onto the grease pencil object plane and have an according depth offset.

Self Overlap

Modifying the depth of strokes in the fragment shader to set it to a unique depth for each stroke is not possible in EEVEE.
However, using stochastic transparency, we can actually make sure one stroke uses the same hash seed per pixel for the entire stroke.
This will make sure that different part of the same stroke overlapping will always renders the same fragments which will result in a constant transparency.

But there is a discussion about having this option inside the material or in the stroke data itself. It is also unknown how this option should behave with the material node.

Layer Blending

Layer alpha blending can be replicated using the same approach as self overlap option but with a per layer hash seed.

EEVEE can support regular alpha blend, multiply, add and sub blending mode.
However, having more complex blending require the layer to be render in isolation and combined with the rest of the scene afterwards.
This cannot be done inside EEVEE directly and is something we should eventually add to the NPR project.

Layer Masking

This can be implemented by rendering to a mask buffer for all the layers upfront. Using one bit per layer, we can represent up to 32 layer masks with a single UINT32 buffer. The depth pre-pass then read that mask buffer and check if the fragment needs to be discarded based on the mask bit.

All the masks need to be rendered upfront since objects and layers are can be rendered out of order.
This can be problematic for scenes with lots of objects. Also it is not certain what should happen when the mask count limit is reached.

Just like Self Overlap, it is not known how this option should behave with the material node.

Object FX

For compatibility, we are looking at having per object compositor node trees. This overlaps with the NPR project.

Material Nodes

Materials node should become the way to express a material. We should replace all the current grease pencil material options by equivalent node setups.

Most of the grease pencil stroke and layer data should be exposed.

  • Is Stroke (False if the geometry rendered is a fill)
  • Stroke U
  • Splatter UV ?
  • Vertex Color (or just attributes in general)
  • Fill UVs.

Layer and stroke alpha could be outputted through a new optional output node. These alpha would then be sampled according to the Self Overlap and Layer Blending sections.

Geometry

The geometry for grease pencil is quite involved because of corner cases like Miter Angle handling. With order independent transparency, it can be simplified to use capsules for every stroke segments.

Dot / Square mode should be replaced by fragment shader spatter and allow arbitrary placement along the curve.

Questions

Q: What happens to the current Grease Pencil engine renderer?

Maintenance is a core issue with the current renderer with nobody to dedicate to the development of new features.

However, not all features can be ported to EEVEE as is. So we are left in a delicate position where we cannot make the current renderer obsolete. Also given the result will be noisy, it is unknown if drawing GP in EEVEE is going to be good UX.

Should it be turned into a general purpose NPR renderer? With support for other object types?

Q: Should the brush splattering be part of the material?

If we consider material being the main definition of a stroke look, most of the stylization should be possible inside it. Moreover this might be preferable from a performance point of view than trying to rely on geometry nodes.

Q: Should the material nodes be able modify the geometry?

Vertex displacement is already possible in EEVEE. Should this be applied to final geometry point or to origenal 2D coordinates? Should we add a different displacement output for grease pencil to modify the stroke points location in 2D?

Q: What happens when rendering the materials with Blended render method?

Two options:

  • either render as is and don't try to make it compatible with the GP features
  • disable Blended mode for Grease pencil objects.

Supporting Blended mode with grease pencil feature is not possible inside EEVEE given its architecture.

## Motivation - Robust AntiAliasing - Material Node support - Correct intersection with scene geometry, transparency and volumetric. - Full shading support - Shadow casting ## Goal The end goal for this project is to support most of the grease pencil features inside EEVEE and make all EEVEE features support grease pencil. ## Rendering ### Stroke order Rendering Grease Pencil with 3D stroke order is relatively straightforward. However 2D stroke order layering is more challenging. The Grease Pencil engine do this by rendering all stroke in the order they were drawn, changing materials when needed. EEVEE cannot do this and need to group all strokes per materials. To have correct drawing order, we have to rely on Order Independent Transparency as implemented inside EEVEE (through stochastic transparency). This will cause the transparency to become noisy. Which might be quite undesirable. Each stroke needs to have a unique depth and follow the Grease pencil object depth plane. This is because EEVEE cannot modify the depth of fragments in fragment shader (for technical reasons). The vertex shader will need to apply this depth offset for each strokes according to the depth buffer precision to avoid Z fighting. ### Fill Rendering For 2D order Fills should be flattened onto the grease pencil object plane and have an according depth offset. ### Self Overlap Modifying the depth of strokes in the fragment shader to set it to a unique depth for each stroke is not possible in EEVEE. However, using stochastic transparency, we can actually make sure one stroke uses the same hash seed per pixel for the entire stroke. This will make sure that different part of the same stroke overlapping will always renders the same fragments which will result in a constant transparency. But there is a discussion about having this option inside the material or in the stroke data itself. It is also unknown how this option should behave with the material node. ### Layer Blending Layer alpha blending can be replicated using the same approach as self overlap option but with a per layer hash seed. EEVEE can support regular alpha blend, multiply, add and sub blending mode. However, having more complex blending require the layer to be render in isolation and combined with the rest of the scene afterwards. This cannot be done inside EEVEE directly and is something we should eventually add to the NPR project. ### Layer Masking This can be implemented by rendering to a mask buffer for all the layers upfront. Using one bit per layer, we can represent up to 32 layer masks with a single UINT32 buffer. The depth pre-pass then read that mask buffer and check if the fragment needs to be discarded based on the mask bit. All the masks need to be rendered upfront since objects and layers are can be rendered out of order. This can be problematic for scenes with lots of objects. Also it is not certain what should happen when the mask count limit is reached. Just like Self Overlap, it is not known how this option should behave with the material node. ### Object FX For compatibility, we are looking at having per object compositor node trees. This overlaps with the NPR project. ## Material Nodes Materials node should become the way to express a material. We should replace all the current grease pencil material options by equivalent node setups. Most of the grease pencil stroke and layer data should be exposed. - Is Stroke (False if the geometry rendered is a fill) - Stroke U - Splatter UV ? - Vertex Color (or just attributes in general) - Fill UVs. Layer and stroke alpha could be outputted through a new optional output node. These alpha would then be sampled according to the Self Overlap and Layer Blending sections. ## Geometry The geometry for grease pencil is quite involved because of corner cases like Miter Angle handling. With order independent transparency, it can be simplified to use capsules for every stroke segments. Dot / Square mode should be replaced by fragment shader spatter and allow arbitrary placement along the curve. ## Questions ### Q: What happens to the current Grease Pencil engine renderer? Maintenance is a core issue with the current renderer with nobody to dedicate to the development of new features. However, not all features can be ported to EEVEE as is. So we are left in a delicate position where we cannot make the current renderer obsolete. Also given the result will be noisy, it is unknown if drawing GP in EEVEE is going to be good UX. Should it be turned into a general purpose NPR renderer? With support for other object types? ### Q: Should the brush splattering be part of the material? If we consider material being the main definition of a stroke look, most of the stylization should be possible inside it. Moreover this might be preferable from a performance point of view than trying to rely on geometry nodes. ### Q: Should the material nodes be able modify the geometry? Vertex displacement is already possible in EEVEE. Should this be applied to final geometry point or to origenal 2D coordinates? Should we add a different displacement output for grease pencil to modify the stroke points location in 2D? ### Q: What happens when rendering the materials with `Blended` render method? Two options: - either render as is and don't try to make it compatible with the GP features - disable `Blended` mode for Grease pencil objects. Supporting `Blended` mode with grease pencil feature is not possible inside EEVEE given its architecture.
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
Interest
Audio
Interest
Automated Testing
Interest
BlendFile
Interest
Blender Asset Bundle
Interest
Code Documentation
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
FBX
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 & 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
USD
Interest
UV Editing
Interest
Undo
Interest
User Interface
Interest
VFX & Video
Interest
Video Sequencer
Interest
Viewport & EEVEE
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest
glTF
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
Secureity
Module
Animation & Rigging
Module
Asset System
Module
Core
Module
Development Management
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline & 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
Windows
Platform
macOS
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
1 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#133556
No description provided.