Page MenuHome

EEVEE-Next: Cryptomatte render passes.
ClosedPublic

Authored by Jeroen Bakker (jbakker) on Aug 22 2022, 3:51 PM.
Tokens
"Like" token, awarded by GeorgiaPacific."Burninate" token, awarded by EmiMartinez."Pterodactyl" token, awarded by Gavriel5578."Burninate" token, awarded by Kickflipkid687."Burninate" token, awarded by ncotrb."Burninate" token, awarded by shader."Party Time" token, awarded by Bit."Love" token, awarded by 295032."Love" token, awarded by shubhampatilart."Love" token, awarded by Crumbled."Love" token, awarded by lopoIsaac."Love" token, awarded by Draise."Love" token, awarded by AndyCuccaro."Love" token, awarded by fclem."Love" token, awarded by silex.

Details

Summary

This change adds cryptomatte render passes to EEVEE-Next. Due to the upcoming viewport
compositor we also improved cryptomatte so it will be real-time. This also allows viewing
the cryptomatte passes in the viewport directly.

A surface shader would store any active cryptomatte layer to a texture. Object hash is stored
as R, Asset hash as G and Material hash as B. Hashes are only calculated when the cryptomatte
layer is active to reduce any unneeded work.

During film accumulation the hashes are separated and stored in a texture array that matches
the cryptomatte standard. For the real-time use case sorting is skipped. For final rendering
the samples are sorted and normalized.

NOTE: Eventually we should also do sample normalization in the viewport in order to extract the correct mask when using the viewport compositor.

Diff Detail

Repository
rB Blender

Event Timeline

There are a very large number of changes, so older changes are hidden. Show Older Changes
Jeroen Bakker (jbakker) edited the summary of this revision. (Show Details)Aug 24 2022, 3:43 PM

I know it is still WIP, but giving a round of feedback nonetheless.

source/blender/draw/engines/eevee_next/eevee_cryptomatte.cc
97

left over printf

source/blender/draw/engines/eevee_next/eevee_cryptomatte.hh
11–14
41–43

seems to be unused

45–46
48

I think I would prefer if it was inside the Film structure instead. Avoiding fragmentation. Leaving this Cryptomatte struct for object data.

source/blender/draw/engines/eevee_next/eevee_film.hh
104–108

Make the Cryptomatte a friend of the Film class. But maybe better to merge the sorting to the Film struct.

source/blender/draw/engines/eevee_next/eevee_renderbuffers.cc
82

Another idea, is to use GPU_R32F with multiple layer to avoid the unnecessary 4th comp.

source/blender/draw/engines/eevee_next/shaders/eevee_cryptomatte_lib.glsl
4

Codestyle: use cryptomatte_ prefix for all functions in this file.

22–26

I would avoid the define that can polute other file. Either use const uint uint_max = 4294967295u (always use lower case suffix), or here, you can simply replace by 0xFFFFFFFFu. This is widely done in other places and I think it is acceptable.

34

This is the issue! dst refers to what is stored in the film. But incoming hash is src. Use FilmSample src = film_sample_get(0, texel_film); to get the center sample (location and weight). You can try using a constant weight for now.

37

Add comment that this is for animated / non static viewport. And that you clear the buffer.

IMO, we should avoid clearing every frame.

48

is that for testing? can't we choose what layer we want to visualize in viewport?

56–57

Comment style. use /**/

64–66

???

source/blender/draw/engines/eevee_next/shaders/eevee_cryptomatte_post_comp.glsl
45 ↗(On Diff #54949)

Use divide_ceil_i to show the intent. I would rename cryptomatte_levels to cryptomatte_samples_per_layer.

source/blender/draw/engines/eevee_next/shaders/infos/eevee_cryptomatte_info.hh
6 ↗(On Diff #54949)

I would merge this with the film info file. No need for many different files concerning infos.

source/blender/draw/engines/eevee_next/shaders/infos/eevee_material_info.hh
95–100

merge into one (keep eevee_cryptomatte_out). even if this causes more unused binds for the world.

Jeroen Bakker (jbakker) edited the summary of this revision. (Show Details)Aug 29 2022, 9:32 AM
Jeroen Bakker (jbakker) marked 7 inline comments as done.
  • Merge branch 'master' into temp-eevee-next-cryptomatte
  • Removed left in debug code.
  • Added better comment.
  • Use cryptomatte_ prefix.
  • Cleanup cryptomatte_false_color.
  • Use divide_ceil.
  • Use cryptomatte_samples_per_layer.
  • Use C-style comments.
  • Remove unused code.
Jeroen Bakker (jbakker) marked an inline comment as done.Aug 29 2022, 2:50 PM
Jeroen Bakker (jbakker) added inline comments.
source/blender/draw/engines/eevee_next/eevee_cryptomatte.hh
41–43

Will use a different way to store the data. This isn't how it is actually used anymore.

48

Yes, was already thinking of doing that. The current code separation is not clean.

source/blender/draw/engines/eevee_next/eevee_film.hh
104–108

Y

source/blender/draw/engines/eevee_next/eevee_renderbuffers.cc
82

That would become 3 store operations when drawing materials and 3 read operations during film accumulation. Haven't tested what the performance implications are think they should be negligible on modern hardware, but still...

Jeroen Bakker (jbakker) marked an inline comment as done.
  • Move sample sorting to film.
Jeroen Bakker (jbakker) marked 3 inline comments as done.
  • Improved documentation.
  • Remove unused attributes from Cryptomatte.
  • Removed solved TODO.
  • Add comment which cryptomatte sample is displayed.
  • Improved documentation about conflicting bits.
source/blender/draw/engines/eevee_next/eevee_shader_shared.hh
197

DisplayMode is incorrect name; it is not only used for display, also for readback of render layers. Basically there are 3 places where the results can be read from, value array, half color array, or cryptomatte (full color). ePassStorageType?

source/blender/draw/engines/eevee_next/shaders/eevee_cryptomatte_lib.glsl
48

Will add a note, that in the viewport only one layer is active and that only the first sample of that layer is shown to the user.

Jeroen Bakker (jbakker) edited the summary of this revision. (Show Details)Aug 30 2022, 9:46 AM
Jeroen Bakker (jbakker) edited the summary of this revision. (Show Details)Aug 30 2022, 3:30 PM
  • Merge branch 'master' into temp-eevee-next-cryptomatte
  • Store cryptomatte meta data.
Jeroen Bakker (jbakker) marked 2 inline comments as done.
  • Merge branch 'master' into temp-eevee-next-cryptomatte
  • Port back D15834 to eevee-next.
  • Remove unneeded access to instance attribute.
  • Renamed DISPLAY_MODE_ to PASS_STORAGE_
  • Add support of sample filtering. Keep track of 4 most weighted hashes.
  • Normalize cryptomatte weights.
  • Merge branch 'master' into temp-eevee-next-cryptomatte
  • Include shader shared in cryptomatte post.
Jeroen Bakker (jbakker) marked 2 inline comments as done.Sep 2 2022, 11:49 AM
Jeroen Bakker (jbakker) edited the summary of this revision. (Show Details)
Jeroen Bakker (jbakker) edited the summary of this revision. (Show Details)Sep 2 2022, 11:52 AM
Jeroen Bakker (jbakker) edited the summary of this revision. (Show Details)Sep 2 2022, 11:55 AM
source/blender/draw/engines/eevee_next/shaders/eevee_film_lib.glsl
191

This is not a correct GLSL array declaration.

Jeroen Bakker (jbakker) marked an inline comment as done.
Jeroen Bakker (jbakker) edited the summary of this revision. (Show Details)
  • Fix incorrect GLSL syntax.

Small nitpick but otherwise, good to go.

source/blender/draw/engines/eevee_next/eevee_shader_shared.hh
265

use ePassStorageType as type. Our GLSL source preprocessor replaces it by uint. This allows strongly typed enum in C++ and better readability.

Also I would rename it to display_type or display_storage_type.

source/blender/draw/engines/eevee_next/shaders/eevee_film_lib.glsl
743
This revision is now accepted and ready to land.Sep 9 2022, 11:49 AM
Jeroen Bakker (jbakker) edited the summary of this revision. (Show Details)Sep 12 2022, 8:50 AM
Jeroen Bakker (jbakker) edited the summary of this revision. (Show Details)
Jeroen Bakker (jbakker) marked 2 inline comments as done.
  • EEVEE-Next: Move weight layer indexes to shader shared.
  • Include shader shared in cryptomatte post.
  • Fix incorrect GLSL syntax.
  • Fix spelling mistake in comment.
  • renamed storage_type to display_storage_type nad use full enum name.
  • Merge branch 'master' into temp-eevee-next-cryptomatte
  • Merge branch 'master' into temp-eevee-next-cryptomatte
  • Fixes issue with selecting incorrect meta-data.
  • Store cryptomatte hash inside material node_tree.
  • Calculate the correct material hash.
  • Store material hashes in meta data.
  • Use correct resource_id to store object hashes.
  • Merge branch 'master' into temp-eevee-next-cryptomatte
Clément Foucault (fclem) added inline comments.
source/blender/draw/engines/eevee_next/eevee_engine.cc
167–172

This is kind-of weird. I would like a comment explaining why we need that.

source/blender/gpu/intern/gpu_codegen.cc
408
  • Fix viewport denoising.
  • Remove commented out code.
This revision was automatically updated to reflect the committed changes.