EEVEE: Cryptomatte #81058

Closed
opened 2020-09-22 16:41:56 +02:00 by Jeroen Bakker · 8 comments
Member

Research how to get Cryptomatte inside EEVEE

Cycles

This section explains the current implementation in Cycles.

Cryptomatte Layers
Cycles supports 3 different kind of cryptomatte layers:

  • Material
  • Object
  • Asset (in Blender this maps to a collection)

The names of the render passes are Crypto[Object/Material/Asset]{99}

Weights and Hashes

The bsdf transparency is used as weight.
For hashes the name of the object, material or asset is hashed using util_murmur_hash3 and converted to a float using util_hash_to_float.

Coverage

When using Cycles CPU the cryptomatte result is sorted and flattened coverage.cpp. The flattening makes sure that samples that points to the same hash only occupying a single slot. The sorting process sorts the items based on its weight. This could be an optimization so highest coverage are first in the list.

EEVEE

In EEVEE transparency is done as a pre-pass this updates the depth buffer to the objects we want to get the data from. This allows to output a single float per sample/layer as we don't need the weight. Every number of samples we can download the texture to CPU RAM and update the Coverage (number of occurances / number of samples). After the final sample has completed we can store the hashes with the highest coverage in the RenderResult.

Pros:

  • No need to do material evaluations a simple depth test would be sufficient.
  • Needs up to 3 floats per object+material combination
  • We could use gl_Layer in the geometry shader to store the result in a 3d texture
    Texture depth is (number of render samples * number of layers). When render samples are large, we could download the texture to CPU and start processing it in the background. A different texture will be bound to the GPU so the rendering can continue.
  • Shading groups only need to be setup once and can be reused between the different samples.
  • Feature complete (and compatible) with Cycles.
    Cons:
  • Not possible to support Viewport previews of the cryptomatte render pass as it needs CPU processing.
  • Rendering overhead as downloading the textures floods the PCI bus. This can slow down final rendering.
  • Blend Alpha isn't supported.

NOTE: Eventually we didn't use a 3d texture due to the OpenGL Pipeline performance penalty. It was faster to do it in a 2d texture and download the texture for every sample.

Additional

There was a request to access the asset, material and object cryptomatte hash from bpy. When implementing this project it can be one of the first patches. BKE will have a method to find the asset/object and material cryptomatte hash (BKE_cryptomatte). RNA read only properties are added to the object/material to calculate the hashes for the specific object/material.

Research how to get Cryptomatte inside EEVEE # Cycles This section explains the current implementation in Cycles. **Cryptomatte Layers** Cycles supports 3 different kind of cryptomatte layers: * Material * Object * Asset (in Blender this maps to a collection) The names of the render passes are `Crypto[Object/Material/Asset]{99}` **Weights and Hashes** The bsdf transparency is used as weight. For hashes the name of the object, material or asset is hashed using `util_murmur_hash3` and converted to a float using `util_hash_to_float`. **Coverage** When using Cycles CPU the cryptomatte result is sorted and flattened `coverage.cpp`. The flattening makes sure that samples that points to the same hash only occupying a single slot. The sorting process sorts the items based on its weight. This could be an optimization so highest coverage are first in the list. # EEVEE In EEVEE transparency is done as a pre-pass this updates the depth buffer to the objects we want to get the data from. This allows to output a single float per sample/layer as we don't need the weight. Every number of samples we can download the texture to CPU RAM and update the Coverage (`number of occurances / number of samples`). After the final sample has completed we can store the hashes with the highest coverage in the RenderResult. Pros: * No need to do material evaluations a simple depth test would be sufficient. * Needs up to 3 floats per object+material combination * We could use `gl_Layer` in the geometry shader to store the result in a 3d texture **Texture depth is (number of render samples * number of layers).** When render samples are large, we could download the texture to CPU and start processing it in the background. A different texture will be bound to the GPU so the rendering can continue. * Shading groups only need to be setup once and can be reused between the different samples. * Feature complete (and compatible) with Cycles. Cons: * Not possible to support Viewport previews of the cryptomatte render pass as it needs CPU processing. * Rendering overhead as downloading the textures floods the PCI bus. This can slow down final rendering. * Blend Alpha isn't supported. NOTE: Eventually we didn't use a 3d texture due to the OpenGL Pipeline performance penalty. It was faster to do it in a 2d texture and download the texture for every sample. # Additional There was a request to access the asset, material and object cryptomatte hash from `bpy`. When implementing this project it can be one of the first patches. BKE will have a method to find the asset/object and material cryptomatte hash (`BKE_cryptomatte`). RNA read only properties are added to the object/material to calculate the hashes for the specific object/material.
Author
Member

Added subscriber: @Jeroen-Bakker

Added subscriber: @Jeroen-Bakker
Member

Added subscriber: @EAW

Added subscriber: @EAW
Jeroen Bakker self-assigned this 2020-10-20 14:44:27 +02:00

This issue was referenced by e60bc528f0

This issue was referenced by e60bc528f0f936d64abdc261df961f60e919facb

Added subscriber: @KINjO

Added subscriber: @KINjO
Author
Member

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

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

Added subscriber: @csouls

Added subscriber: @csouls

This issue was referenced by 76a0b322e4

This issue was referenced by 76a0b322e4d3244e59a154c8255b84a4fbc33117
Author
Member

Changed status from 'Confirmed' to: 'Resolved'

Changed status from 'Confirmed' 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
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
5 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#81058
No description provided.