[Bf-blender-cvs] [f4371a6b89a] temp-eevee-next-cryptomatte: Eevee-next: Cryptomatte WIP shader.
Jeroen Bakker
noreply at git.blender.org
Mon Aug 22 15:49:47 CEST 2022
Commit: f4371a6b89ae3bcdc6624c4040b5c6bc59424c5c
Author: Jeroen Bakker
Date: Tue Aug 9 14:35:58 2022 +0200
Branches: temp-eevee-next-cryptomatte
https://developer.blender.org/rBf4371a6b89ae3bcdc6624c4040b5c6bc59424c5c
Eevee-next: Cryptomatte WIP shader.
===================================================================
M source/blender/draw/CMakeLists.txt
A source/blender/draw/engines/eevee_next/shaders/eevee_cryptomatte_lib.glsl
M source/blender/draw/engines/eevee_next/shaders/eevee_film_lib.glsl
===================================================================
diff --git a/source/blender/draw/CMakeLists.txt b/source/blender/draw/CMakeLists.txt
index 81dfb5b8f91..27809c1c4d1 100644
--- a/source/blender/draw/CMakeLists.txt
+++ b/source/blender/draw/CMakeLists.txt
@@ -366,6 +366,7 @@ set(GLSL_SRC
engines/eevee_next/shaders/eevee_camera_lib.glsl
engines/eevee_next/shaders/eevee_colorspace_lib.glsl
engines/eevee_next/shaders/eevee_cryptomatte_frag.glsl
+ engines/eevee_next/shaders/eevee_cryptomatte_lib.glsl
engines/eevee_next/shaders/eevee_depth_of_field_accumulator_lib.glsl
engines/eevee_next/shaders/eevee_depth_of_field_bokeh_lut_comp.glsl
engines/eevee_next/shaders/eevee_depth_of_field_downsample_comp.glsl
diff --git a/source/blender/draw/engines/eevee_next/shaders/eevee_cryptomatte_lib.glsl b/source/blender/draw/engines/eevee_next/shaders/eevee_cryptomatte_lib.glsl
new file mode 100644
index 00000000000..2f2a9b2ee74
--- /dev/null
+++ b/source/blender/draw/engines/eevee_next/shaders/eevee_cryptomatte_lib.glsl
@@ -0,0 +1,14 @@
+/** Storing/merging and sorting cryptomatte samples. */
+
+void film_store_cryptomatte_sample(FilmSample dst, int cryptomatte_layer_id, float hash){
+ float weight = dst.weight;
+ /*
+ first need to detect the operation.
+ - when hash exists it should be updated and can optionally be moved to a new position.
+ - when hash doesn't exist we should find an insertion point. only samples to a null sample (hash 0, weight 0) should be moved. When no null sample exist it will remove the lowest weight.
+
+ */
+ int operation = 0;
+
+
+}
diff --git a/source/blender/draw/engines/eevee_next/shaders/eevee_film_lib.glsl b/source/blender/draw/engines/eevee_next/shaders/eevee_film_lib.glsl
index bf6293d5561..bd802eb62ab 100644
--- a/source/blender/draw/engines/eevee_next/shaders/eevee_film_lib.glsl
+++ b/source/blender/draw/engines/eevee_next/shaders/eevee_film_lib.glsl
@@ -8,6 +8,7 @@
#pragma BLENDER_REQUIRE(eevee_camera_lib.glsl)
#pragma BLENDER_REQUIRE(eevee_velocity_lib.glsl)
#pragma BLENDER_REQUIRE(eevee_colorspace_lib.glsl)
+#pragma BLENDER_REQUIRE(eevee_cryptomatte_lib.glsl)
/* Return scene linear Z depth from the camera or radial depth for panoramic cameras. */
float film_depth_convert_to_scene(float depth)
@@ -687,4 +688,23 @@ void film_process_data(ivec2 texel_film, out vec4 out_color, out float out_depth
}
film_store_value(dst, film_buf.aov_value_id + aov, aov_accum, out_color);
}
+
+ if (film_buf.cryptomatte_samples_len != 0) {
+ vec4 hashes = texelFetch(cryptomatte_tx, dst.texel, 0);
+ if (film_buf.cryptomatte_object_id != -1) {
+ float hash = hashes.x;
+ hashes = hashes.yzww;
+ film_store_cryptomatte_sample(dst, film_buf.cryptomatte_object_id, hash);
+ }
+ if (film_buf.cryptomatte_asset_id != -1) {
+ float hash = hashes.x;
+ hashes = hashes.yzww;
+ film_store_cryptomatte_sample(dst, film_buf.cryptomatte_asset_id, hash);
+ }
+ if (film_buf.cryptomatte_material_id != -1) {
+ float hash = hashes.x;
+ hashes = hashes.yzww;
+ film_store_cryptomatte_sample(dst, film_buf.cryptomatte_material_id, hash);
+ }
+ }
}
More information about the Bf-blender-cvs
mailing list