[Bf-blender-cvs] [ffadff03560] cycles-x: Cycles X: add Position render pass
Brecht Van Lommel
noreply at git.blender.org
Wed Aug 11 14:57:13 CEST 2021
Commit: ffadff035601359210ab613c9c153fdcab7de510
Author: Brecht Van Lommel
Date: Tue Aug 10 19:07:43 2021 +0200
Branches: cycles-x
https://developer.blender.org/rBffadff035601359210ab613c9c153fdcab7de510
Cycles X: add Position render pass
===================================================================
M intern/cycles/blender/addon/engine.py
M intern/cycles/blender/addon/properties.py
M intern/cycles/blender/addon/ui.py
M intern/cycles/blender/blender_session.cpp
M intern/cycles/blender/blender_sync.cpp
M intern/cycles/kernel/kernel_passes.h
M intern/cycles/kernel/kernel_types.h
M intern/cycles/render/film.cpp
M intern/cycles/render/pass.cpp
M release/scripts/addons
M source/blender/editors/object/object_bake_api.c
M source/blender/makesdna/DNA_scene_types.h
M source/blender/makesrna/intern/rna_render.c
M source/blender/makesrna/intern/rna_scene.c
M source/blender/nodes/composite/nodes/node_composite_image.c
M source/blender/render/intern/bake.c
M source/blender/render/intern/render_result.c
===================================================================
diff --git a/intern/cycles/blender/addon/engine.py b/intern/cycles/blender/addon/engine.py
index 77fbcd1697e..33b36d09e84 100644
--- a/intern/cycles/blender/addon/engine.py
+++ b/intern/cycles/blender/addon/engine.py
@@ -192,6 +192,7 @@ def list_render_passes(scene, srl):
# Data passes.
if srl.use_pass_z: yield ("Depth", "Z", 'VALUE')
if srl.use_pass_mist: yield ("Mist", "Z", 'VALUE')
+ if srl.use_pass_position: yield ("Position", "XYZ", 'VECTOR')
if srl.use_pass_normal: yield ("Normal", "XYZ", 'VECTOR')
if srl.use_pass_vector: yield ("Vector", "XYZW", 'VECTOR')
if srl.use_pass_uv: yield ("UV", "UVA", 'VECTOR')
diff --git a/intern/cycles/blender/addon/properties.py b/intern/cycles/blender/addon/properties.py
index 1809744aae0..5cb7c990bda 100644
--- a/intern/cycles/blender/addon/properties.py
+++ b/intern/cycles/blender/addon/properties.py
@@ -156,6 +156,7 @@ enum_view3d_shading_render_pass = (
('', "Data", ""),
+ ('POSITION', "Position", "Show the Position render pass"),
('NORMAL', "Normal", "Show the Normal render pass"),
('UV', "UV", "Show the UV render pass"),
('MIST', "Mist", "Show the Mist render pass"),
@@ -598,17 +599,18 @@ class CyclesRenderSettings(bpy.types.PropertyGroup):
default='COMBINED',
description="Type of pass to bake",
items=(
- ('COMBINED', "Combined", ""),
- ('AO', "Ambient Occlusion", ""),
- ('SHADOW', "Shadow", ""),
- ('NORMAL', "Normal", ""),
- ('UV', "UV", ""),
- ('ROUGHNESS', "Roughness", ""),
- ('EMIT', "Emit", ""),
- ('ENVIRONMENT', "Environment", ""),
- ('DIFFUSE', "Diffuse", ""),
- ('GLOSSY', "Glossy", ""),
- ('TRANSMISSION', "Transmission", ""),
+ ('COMBINED', "Combined", "", 0),
+ ('AO', "Ambient Occlusion", "", 1),
+ ('SHADOW', "Shadow", "", 2),
+ ('POSITION', "Position", "", 11),
+ ('NORMAL', "Normal", "", 3),
+ ('UV', "UV", "", 4),
+ ('ROUGHNESS', "Roughness", "", 5),
+ ('EMIT', "Emit", "", 6),
+ ('ENVIRONMENT', "Environment", "", 7),
+ ('DIFFUSE', "Diffuse", "", 8),
+ ('GLOSSY', "Glossy", "", 9),
+ ('TRANSMISSION', "Transmission", "", 10),
),
)
diff --git a/intern/cycles/blender/addon/ui.py b/intern/cycles/blender/addon/ui.py
index a175b444b23..c0e8c769a2e 100644
--- a/intern/cycles/blender/addon/ui.py
+++ b/intern/cycles/blender/addon/ui.py
@@ -739,6 +739,7 @@ class CYCLES_RENDER_PT_passes_data(CyclesButtonsPanel, Panel):
col.prop(view_layer, "use_pass_combined")
col.prop(view_layer, "use_pass_z")
col.prop(view_layer, "use_pass_mist")
+ col.prop(view_layer, "use_pass_position")
col.prop(view_layer, "use_pass_normal")
sub = col.column()
sub.active = not rd.use_motion_blur
diff --git a/intern/cycles/blender/blender_session.cpp b/intern/cycles/blender/blender_session.cpp
index 6fffcf1ccfe..80c56ffff4f 100644
--- a/intern/cycles/blender/blender_session.cpp
+++ b/intern/cycles/blender/blender_session.cpp
@@ -550,7 +550,10 @@ static PassType bake_type_to_pass(const string &bake_type_str, const int bake_fi
const char *bake_type = bake_type_str.c_str();
/* data passes */
- if (strcmp(bake_type, "NORMAL") == 0) {
+ if (strcmp(bake_type, "POSITION") == 0) {
+ return PASS_POSITION;
+ }
+ else if (strcmp(bake_type, "NORMAL") == 0) {
return PASS_NORMAL;
}
else if (strcmp(bake_type, "UV") == 0) {
diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp
index fb04ac79358..80b3045e506 100644
--- a/intern/cycles/blender/blender_sync.cpp
+++ b/intern/cycles/blender/blender_sync.cpp
@@ -510,6 +510,7 @@ static PassType get_blender_pass_type(BL::RenderPass &b_pass)
MAP_PASS("Depth", PASS_DEPTH);
MAP_PASS("Mist", PASS_MIST);
+ MAP_PASS("Position", PASS_POSITION);
MAP_PASS("Normal", PASS_NORMAL);
MAP_PASS("IndexOB", PASS_OBJECT_ID);
MAP_PASS("UV", PASS_UV);
diff --git a/intern/cycles/kernel/kernel_passes.h b/intern/cycles/kernel/kernel_passes.h
index c3ccadccbcd..3c302387b4d 100644
--- a/intern/cycles/kernel/kernel_passes.h
+++ b/intern/cycles/kernel/kernel_passes.h
@@ -213,6 +213,10 @@ ccl_device_inline void kernel_write_data_passes(INTEGRATOR_STATE_ARGS,
}
}
+ if (flag & PASSMASK(POSITION)) {
+ const float3 position = sd->P;
+ kernel_write_pass_float3(buffer + kernel_data.film.pass_position, position);
+ }
if (flag & PASSMASK(NORMAL)) {
const float3 normal = shader_bsdf_average_normal(kg, sd);
kernel_write_pass_float3(buffer + kernel_data.film.pass_normal, normal);
diff --git a/intern/cycles/kernel/kernel_types.h b/intern/cycles/kernel/kernel_types.h
index 50c496c8f08..b73e6edfde9 100644
--- a/intern/cycles/kernel/kernel_types.h
+++ b/intern/cycles/kernel/kernel_types.h
@@ -352,6 +352,7 @@ typedef enum PassType {
/* Data passes */
PASS_DEPTH = 32,
+ PASS_POSITION,
PASS_NORMAL,
PASS_ROUGHNESS,
PASS_UV,
@@ -962,6 +963,7 @@ typedef struct KernelFilm {
int pass_combined;
int pass_depth;
+ int pass_position;
int pass_normal;
int pass_roughness;
int pass_motion;
@@ -1033,9 +1035,6 @@ typedef struct KernelFilm {
int display_pass_denoised_offset;
int show_active_pixels;
int use_approximate_shadow_catcher;
-
- /* padding */
- int pad1;
} KernelFilm;
static_assert_align(KernelFilm, 16);
diff --git a/intern/cycles/render/film.cpp b/intern/cycles/render/film.cpp
index 8ed746efa5d..91f1cba0908 100644
--- a/intern/cycles/render/film.cpp
+++ b/intern/cycles/render/film.cpp
@@ -259,6 +259,9 @@ void Film::device_update(Device *device, DeviceScene *dscene, Scene *scene)
case PASS_NORMAL:
kfilm->pass_normal = kfilm->pass_stride;
break;
+ case PASS_POSITION:
+ kfilm->pass_position = kfilm->pass_stride;
+ break;
case PASS_ROUGHNESS:
kfilm->pass_roughness = kfilm->pass_stride;
break;
diff --git a/intern/cycles/render/pass.cpp b/intern/cycles/render/pass.cpp
index 023cae47eaf..799cd6c5cec 100644
--- a/intern/cycles/render/pass.cpp
+++ b/intern/cycles/render/pass.cpp
@@ -81,6 +81,7 @@ const NodeEnum *Pass::get_type_enum()
/* Data passes. */
pass_type_enum.insert("depth", PASS_DEPTH);
+ pass_type_enum.insert("position", PASS_POSITION);
pass_type_enum.insert("normal", PASS_NORMAL);
pass_type_enum.insert("roughness", PASS_ROUGHNESS);
pass_type_enum.insert("uv", PASS_UV);
@@ -179,6 +180,9 @@ PassInfo Pass::get_info(const PassType type, const bool include_albedo)
case PASS_MIST:
pass_info.num_components = 1;
break;
+ case PASS_POSITION:
+ pass_info.num_components = 3;
+ break;
case PASS_NORMAL:
pass_info.num_components = 3;
break;
diff --git a/release/scripts/addons b/release/scripts/addons
index 1adb56d8b01..4475cbd11a6 160000
--- a/release/scripts/addons
+++ b/release/scripts/addons
@@ -1 +1 @@
-Subproject commit 1adb56d8b01cf1327f58c6fb8b1ccc8b7efd76ad
+Subproject commit 4475cbd11a636382d57571e0f5dfeff1f90bd6b7
diff --git a/source/blender/editors/object/object_bake_api.c b/source/blender/editors/object/object_bake_api.c
index 511878c5462..26f5b21a311 100644
--- a/source/blender/editors/object/object_bake_api.c
+++ b/source/blender/editors/object/object_bake_api.c
@@ -412,6 +412,7 @@ static bool is_noncolor_pass(eScenePassType pass_type)
{
return ELEM(pass_type,
SCE_PASS_Z,
+ SCE_PASS_POSITION,
SCE_PASS_NORMAL,
SCE_PASS_VECTOR,
SCE_PASS_INDEXOB,
diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h
index 0efadbbc695..9e68422d1d9 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -261,7 +261,7 @@ typedef enum eScenePassType {
SCE_PASS_UNUSED_3 = (1 << 4), /* SPEC */
SCE_PASS_SHADOW = (1 << 5),
SCE_PASS_AO = (1 << 6),
- SCE_PASS_UNUSED_4 = (1 << 7), /* REFLECT */
+ SCE_PASS_POSITION = (1 << 7),
SCE_PASS_NORMAL = (1 << 8),
SCE_PASS_VECTOR = (1 << 9),
SCE_PASS_UNUSED_5 = (1 << 10), /* REFRACT */
@@ -293,6 +293,7 @@ typedef enum eScenePassType {
#define RE_PASSNAME_COMBINED "Combined"
#define RE_PASSNAME_Z "Depth"
#define RE_PASSNAME_VECTOR "Vector"
+#define RE_PASSNAME_POSITION "Position"
#define RE_PASSNAME_NORMAL "Normal"
#define RE_PASSNAME_UV "UV"
#define RE_PASSNAME_EMIT "Emit"
diff --git a/source/blender/makesrna/intern/rna_render.c b/source/blender/makesrna/intern/rna_render.c
index 73924c45d52..598c5f7697e 100644
--- a/source/blender/makesrna/intern/rna_render.c
+++ b/source/blender/makesrna/intern/rna_render.c
@@ -52,6 +52,7 @@ const EnumPropertyItem rna_enum_render_pass_type_items[] = {
{SCE_PASS_Z, "Z", 0, "Z", ""},
{SCE_PASS_SHADOW, "SHADOW", 0, "Shadow", ""},
{SCE_PASS_AO, "AO", 0, "Ambient Occlusion", ""},
+ {SCE_PASS_POSITION, "POSITION", 0, "Position", ""},
{SCE_PASS_NORMAL, "NORMAL", 0, "Normal", ""},
{SCE_PASS_VECTOR, "VECTOR", 0, "Vector", ""},
{SCE_PASS_INDEXOB, "OBJECT_INDEX", 0, "Object Index", ""},
@@ -79,6 +80,7 @@ const EnumPropertyItem rna_enum_bake_pass_type_items[] = {
{SCE_PASS_COMBINED, "COMBINED", 0, "Combined", ""},
{SCE_PASS_AO, "AO", 0, "Ambient Occlusion", ""},
{SCE_PASS_SHADOW, "SHADOW", 0, "Shadow", ""},
+ {SCE_PASS_POSITION, "POSITION", 0, "Position", ""},
{SCE_PASS_NORMAL, "NORMAL", 0, "Normal", ""},
{SCE_PASS_UV, "UV", 0, "UV", ""},
{SCE_PASS_ROUGHNESS, "ROUGHNESS", 0, "ROUGHNESS", ""},
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
index f9ffd303a20..85960fcf528 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -4210,6 +4210,16 @@ void rna_de
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list