WIP: Refractor: Compositor: Render layer node to dynamic declaration #114629

Draft
Amine Bensalem wants to merge 18 commits from HamilcarR/blender:nodes-108728-cmp_node_r_layers into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
Contributor

Implemented dynamic declarations for CMP_NODE_R_LAYERS .

Also CMP_NODE_R_LAYERS and CMP_NODE_IMAGE no longer share functions for socket creation and update .

See: #108728

Implemented dynamic declarations for `CMP_NODE_R_LAYERS` . Also `CMP_NODE_R_LAYERS` and `CMP_NODE_IMAGE` no longer share functions for socket creation and update . See: #108728
Iliya Katushenock added this to the Nodes & Physics project 2023-11-08 14:06:10 +01:00
Iliya Katushenock added the
Interest
Compositing
label 2023-11-08 14:06:18 +01:00
Iliya Katushenock requested review from Iliya Katushenock 2023-11-08 14:06:25 +01:00
Iliya Katushenock reviewed 2023-11-08 15:10:15 +01:00
Iliya Katushenock left a comment
Member

Thanks for working on that. Just to simplify next reviews and be ready to send this into the main, please always keep the code in correct format (See: https://wiki.blender.org/wiki/Style_Guide/C_Cpp#Clang_Format).
This will be simple by always call make format in your root blender folder before commit changes.

Sorry that i didn't noticed that. This file is mixing of two node with different functionality!
It's good to split this nodes after all changes for me. Since dynamic declaration will let us to delete a lot of legacy code related with editing and updating of sockets, there is will not so many shared code i hope.

For now, i clearly see that right now any storage is doesn't make any sense (due to the fact what that is done to reuse Image node code of sockets update what is actually use this socket storage structure) for this node.

I'll have to ask @OmarEmaraDev to be sure (i am not the best one in the compositor computing).

I also wrote few comments about general things and format.

Thanks for working on that. Just to simplify next reviews and be ready to send this into the main, please always keep the code in correct format (See: https://wiki.blender.org/wiki/Style_Guide/C_Cpp#Clang_Format). This will be simple by always call `make format` in your root blender folder before commit changes. Sorry that i didn't noticed that. This file is mixing of two node with different functionality! It's good to split this nodes after all changes for me. Since dynamic declaration will let us to delete a lot of legacy code related with editing and updating of sockets, there is will not so many shared code i hope. For now, i clearly see that right now any storage is doesn't make any sense (due to the fact what that is done to reuse `Image` node code of sockets update what is actually use this socket storage structure) for this node. I'll have to ask @OmarEmaraDev to be sure (i am not the best one in the compositor computing). I also wrote few comments about general things and format.
@ -688,0 +695,4 @@
eNodeSocketDatatype type)
{
NodeDeclarationBuilder *builder = static_cast<NodeDeclarationBuilder*>(userdata);
if(std::string(name) != std::string(RE_PASSNAME_COMBINED)){

StringRefNull instead of std::string

`StringRefNull` instead of `std::string`
HamilcarR marked this conversation as resolved
@ -688,0 +698,4 @@
if(std::string(name) != std::string(RE_PASSNAME_COMBINED)){
switch(type){
case SOCK_FLOAT:
builder->add_output<decl::Float>(name);

builder->add_output(type, name);

`builder->add_output(type, name);`

Now this might works too.

Now this might works too.
HamilcarR marked this conversation as resolved
@ -688,0 +717,4 @@
NodeDeclarationBuilder builder(r_declaration);
builder.add_output<decl::Color>("Image");
builder.add_output<decl::Float>("Alpha");
if(scene){
Better to always use early return pattern. See: - https://devtalk.blender.org/t/some-anti-patterns/26490#mixing-precondition-checks-with-core-functionality-2 - https://softwareengineering.stackexchange.com/a/18473
HamilcarR marked this conversation as resolved
@ -788,3 +831,3 @@
row = uiLayoutRow(col, true);
uiItemR(row, ptr, "layer", UI_ITEM_R_SPLIT_EMPTY_NAME, "", ICON_NONE);

Unrelated change.

Unrelated change.
Author
Contributor

Thanks for working on that. Just to simplify next reviews and be ready to send this into the main, please always keep the code in correct format (See: https://wiki.blender.org/wiki/Style_Guide/C_Cpp#Clang_Format).
This will be simple by always call make format in your root blender folder before commit changes.

Sorry that i didn't noticed that. This file is mixing of two node with different functionality!
It's good to split this nodes after all changes for me. Since dynamic declaration will let us to delete a lot of legacy code related with editing and updating of sockets, there is will not so many shared code i hope.

For now, i clearly see that right now any storage is doesn't make any sense (due to the fact what that is done to reuse Image node code of sockets update what is actually use this socket storage structure) for this node.

I'll have to ask @OmarEmaraDev to be sure (i am not the best one in the compositor computing).

I also wrote few comments about general things and format.

@mod_moder Hi , yes it's not ready for a merge yet , I just needed to check if this was going the right direction .
indeed , there's also the CMP_NODE_IMAGE that used to share functions with the render layer node ,but I think I can manage just splitting them apart each in their own respective files.
Although , last question , I tried playing around with node.storage ... is this structure's content writen on disk ? Maybe on a temp file , or a blend file after saving the session ?

> Thanks for working on that. Just to simplify next reviews and be ready to send this into the main, please always keep the code in correct format (See: https://wiki.blender.org/wiki/Style_Guide/C_Cpp#Clang_Format). > This will be simple by always call `make format` in your root blender folder before commit changes. > > Sorry that i didn't noticed that. This file is mixing of two node with different functionality! > It's good to split this nodes after all changes for me. Since dynamic declaration will let us to delete a lot of legacy code related with editing and updating of sockets, there is will not so many shared code i hope. > > For now, i clearly see that right now any storage is doesn't make any sense (due to the fact what that is done to reuse `Image` node code of sockets update what is actually use this socket storage structure) for this node. > > I'll have to ask @OmarEmaraDev to be sure (i am not the best one in the compositor computing). > > I also wrote few comments about general things and format. > @mod_moder Hi , yes it's not ready for a merge yet , I just needed to check if this was going the right direction . indeed , there's also the CMP_NODE_IMAGE that used to share functions with the render layer node ,but I think I can manage just splitting them apart each in their own respective files. Although , last question , I tried playing around with node.storage ... is this structure's content writen on disk ? Maybe on a temp file , or a blend file after saving the session ?

Although , last question , I tried playing around with node.storage ... is this structure's content writen on disk ? Maybe on a temp file , or a blend file after saving the session ?

DNA structures is C structs that is stored as binary image in undo copy of blend file and in real blend file on the disk, right.
If that is not pointer to other structure, everything should be happedn automaticly. You can find manuall processing of that structures in ntreeBlendWrite and ntreeBlendReadData functions.
But now i pretty sure that new storage is not necessary.
Everything that should happen here is call of render engine to build sockets for layers. Previously shared code can be keep in places if other one node still use this. I just have to edit #108728 to ensure other one node to refactoring.

> Although , last question , I tried playing around with node.storage ... is this structure's content writen on disk ? Maybe on a temp file , or a blend file after saving the session ? DNA structures is C structs that is stored as binary image in undo copy of blend file and in real blend file on the disk, right. If that is not pointer to other structure, everything should be happedn automaticly. You can find manuall processing of that structures in `ntreeBlendWrite` and `ntreeBlendReadData` functions. But now i pretty sure that new storage is not necessary. Everything that should happen here is call of render engine to build sockets for layers. Previously shared code can be keep in places if other one node still use this. I just have to edit #108728 to ensure other one node to refactoring.
Amine Bensalem force-pushed nodes-108728-cmp_node_r_layers from f2c7e34462 to 87d5b54584 2023-11-13 09:18:36 +01:00 Compare
Amine Bensalem changed title from WIP: Refractor render layer node to dynamic declaration to Refractor render layer node to dynamic declaration 2023-11-16 16:40:05 +01:00
Amine Bensalem changed title from Refractor render layer node to dynamic declaration to Compositor #108728 : Refractor render layer node to dynamic declaration 2023-11-17 10:27:45 +01:00
Author
Contributor

@blender-bot build

@blender-bot build
Member

Only blender organization members with write access can start builds. See documentation for details.

Only blender organization members with write access can start builds. See [documentation](https://projects.blender.org/infrastructure/blender-bot/src/branch/main/README.md) for details.
Iliya Katushenock reviewed 2023-11-18 13:18:29 +01:00
@ -61,1 +61,3 @@
NodeImageLayer *storage = (NodeImageLayer *)output->get_bnode_socket()->storage;
const char *socket_identifier = output->get_bnode_socket()->identifier;
if (strstr(socket_identifier, "Combined")) {
socket_identifier = "Combined";

Not sure what is the point of doing this?

Not sure what is the point of doing this?
Author
Contributor
  1. NodeImageLayer is no longer needed for socket storages as far as I understand , so I just removed it .
  2. The socket identifier part is to check if that socket can be used for the "RE_PASSNAME_COMBINED" (sorry , forgot this define existed) ... the earlier version was doing roughly the same thing , using a NodeImageLayer as socket storage.
    There's probably a better way of doing this now that you point it out.
    I gave identifiers to image and alpha sockets that are "Combined_i" and "Combined_a" ...
1) NodeImageLayer is no longer needed for socket storages as far as I understand , so I just removed it . 2) The socket identifier part is to check if that socket can be used for the "RE_PASSNAME_COMBINED" (sorry , forgot this define existed) ... the earlier version was doing roughly the same thing , using a NodeImageLayer as socket storage. There's probably a better way of doing this now that you point it out. I gave identifiers to image and alpha sockets that are "Combined_i" and "Combined_a" ...
Author
Contributor

In this case , what do you think would be the best way of doing things ?
Maybe :

const char *socket_name = output->get_bnode_socket()->name ; 

const char *pass_name = socket_name ; 

if(STREQ(socket_name , "Alpha") || STREQ(socket_name , "Image")){
   
     pass_name = RE_PASSNAME_COMBINED ; 
}
RenderPass *rpass = (RenderPass *)BLI_findstring(
  &rl->passes, pass_name, offsetof(RenderPass, name));
In this case , what do you think would be the best way of doing things ? Maybe : ```Cpp const char *socket_name = output->get_bnode_socket()->name ; const char *pass_name = socket_name ; if(STREQ(socket_name , "Alpha") || STREQ(socket_name , "Image")){ pass_name = RE_PASSNAME_COMBINED ; } RenderPass *rpass = (RenderPass *)BLI_findstring( &rl->passes, pass_name, offsetof(RenderPass, name)); ```
HamilcarR marked this conversation as resolved
@ -70,2 +73,3 @@
if (STREQ(rpass->name, RE_PASSNAME_COMBINED) &&
STREQ(output->get_bnode_socket()->name, "Alpha")) {
STREQ(output->get_bnode_socket()->name, "Alpha"))
{

Unrelated format change?

Unrelated format change?
Author
Contributor

this was clang-format ... I don't know why it corrected this line , and if I should let it do it's thing ... it's weird , because I use the exact same .clang-format as the official repo.

this was clang-format ... I don't know why it corrected this line , and if I should let it do it's thing ... it's weird , because I use the exact same .clang-format as the official repo.

Can you try just make format instead?

Can you try just `make format` instead?
Author
Contributor

make format raises an exception in the python wrapper :
NotADirectoryError: [Errno 20] Not a directory: 'clang-format-8.0'
I'm currently trying to fix this

`make format` raises an exception in the python wrapper : `NotADirectoryError: [Errno 20] Not a directory: 'clang-format-8.0' ` I'm currently trying to fix this
Author
Contributor

I have no idea why the script doesn't detect the clang-format binary in lib/ , I had to hard code the path into the script.
I'll fix that later .
I ran make format , added new commit for it.
Branch can be merged on my side

I have no idea why the script doesn't detect the clang-format binary in lib/ , I had to hard code the path into the script. I'll fix that later . I ran make format , added new commit for it. Branch can be merged on my side
HamilcarR marked this conversation as resolved
@ -913,3 +812,3 @@
cmp_node_type_base(&ntype, CMP_NODE_R_LAYERS, "Render Layers", NODE_CLASS_INPUT);
blender::bke::node_type_socket_templates(&ntype, nullptr, cmp_node_rlayers_out);
ntype.declare_dynamic = file_ns::node_rlayer_declare_dynamic;

Can you merge this with main? There was some refactor of this callback #113742 .

Can you merge this with main? There was some refactor of this callback https://projects.blender.org/blender/blender/pulls/113742 .
Author
Contributor

yep , it merges for me.

yep , it merges for me.

Have you merge this with latest main? Can you push it in to pr?

Have you merge this with latest main? Can you push it in to pr?
Author
Contributor

Hi @mod_moder , I just pushed the merged updated main.
Edit : you are right , there's a conflict because of the callback refractor , I'm gonna put a WIP back on the PR in the meantime.

Hi @mod_moder , I just pushed the merged updated main. Edit : you are right , there's a conflict because of the callback refractor , I'm gonna put a WIP back on the PR in the meantime.
Author
Contributor

Now it should be working . I updated the callback and renamed some stuff , should I re-merge main on the branch ?

Now it should be working . I updated the callback and renamed some stuff , should I re-merge main on the branch ?
HamilcarR marked this conversation as resolved
Iliya Katushenock changed title from Compositor #108728 : Refractor render layer node to dynamic declaration to Refractor: Compositor: Render layer node to dynamic declaration 2023-11-18 13:56:21 +01:00
Amine Bensalem changed title from Refractor: Compositor: Render layer node to dynamic declaration to WIP: Refractor: Compositor: Render layer node to dynamic declaration 2023-11-20 18:22:14 +01:00
Amine Bensalem changed title from WIP: Refractor: Compositor: Render layer node to dynamic declaration to WIP: Refractor: Compositor: Render layer node to dynamic declaration 2023-11-20 18:22:16 +01:00
Amine Bensalem changed title from WIP: Refractor: Compositor: Render layer node to dynamic declaration to Refractor: Compositor: Render layer node to dynamic declaration 2023-11-20 20:12:43 +01:00
Author
Contributor

@mod_moder Hi , I think this is finally ready . I tested it with most nodes it seems to be working as intended .
Do you want to test it on your side as well ?
Maybe should I add some unit testing ? if so , do you have advises on potential test cases ?

@mod_moder Hi , I think this is finally ready . I tested it with most nodes it seems to be working as intended . Do you want to test it on your side as well ? Maybe should I add some unit testing ? if so , do you have advises on potential test cases ?

I'll just have to check this one this week, and we can move forward with this.

I'll just have to check this one this week, and we can move forward with this.
Author
Contributor

I'll just have to check this one this week, and we can move forward with this.

ok , let me know if you have questions

> I'll just have to check this one this week, and we can move forward with this. ok , let me know if you have questions

Thanks for await.
Just first first crash (that ocure only with this patch):

  1. Eevee render.
  2. Enable Viewport render.
  3. Enable Viewport realtime compositor in Viewport Settings.
  4. Open compositor editor.
  5. Press Use Nodes button.
    Stack trace file is attached.
Thanks for await. Just first first crash (that ocure only with this patch): 1. Eevee render. 2. Enable Viewport render. 3. Enable Viewport realtime compositor in Viewport Settings. 4. Open compositor editor. 5. Press `Use Nodes` button. Stack trace file is attached.
Amine Bensalem added 9 commits 2023-11-26 10:34:27 +01:00
6da1a1e0fa Refractor #108728: Removed now unused socket creation code.
1) Removed socket storage allocation in initfunc_api function.

2) Replaced manual free and copy functions for rlayer node , with
   node_free_standard_storage() and node_copy_standard_storage().

3) Removed the socket creation code that was shared with the Image node.

4) RenderLayersNode::test_render_link() now uses socket identifiers
   instead of socket storage to check socket types.

5) NodeImageLayer structure is no longer used as socket storage data.
Author
Contributor

Thanks for await.
Just first first crash (that ocure only with this patch):

  1. Eevee render.
  2. Enable Viewport render.
  3. Enable Viewport realtime compositor in Viewport Settings.
  4. Open compositor editor.
  5. Press Use Nodes button.
    Stack trace file is attached.

Hi , it seems there was a problem with the socket identifiers . Crash should be fixed now , according to my tests.
Also :

image

"Render passes not supported in the viewport compositor" , this isn't unexpected , right ?

> Thanks for await. > Just first first crash (that ocure only with this patch): > 1. Eevee render. > 2. Enable Viewport render. > 3. Enable Viewport realtime compositor in Viewport Settings. > 4. Open compositor editor. > 5. Press `Use Nodes` button. > Stack trace file is attached. > > Hi , it seems there was a problem with the socket identifiers . Crash should be fixed now , according to my tests. Also : ![image](/attachments/bdb38c52-abf1-4aed-8823-454bb316db65) "Render passes not supported in the viewport compositor" , this isn't unexpected , right ?
661 KiB

"Render passes not supported in the viewport compositor" , this isn't unexpected , right ?

Yeah, realtime compositor limitation.

> "Render passes not supported in the viewport compositor" , this isn't unexpected , right ? Yeah, realtime compositor limitation.
Amine Bensalem force-pushed nodes-108728-cmp_node_r_layers from fea3696a99 to 5313e82181 2023-11-26 13:25:20 +01:00 Compare
Iliya Katushenock reviewed 2023-12-13 14:05:49 +01:00
Iliya Katushenock left a comment
Member

My course work still require me to not relax and come back to blender, but i finally find the time to look in to this!
Sorry for necromancy, i just tested this as it seems this works good. Just few comments about general thing in a code add. I'll have to ask someone to check this in vfx side, but generally this is ready. Will check this again, before approve, after this will be approved in other side.

My course work still require me to not relax and come back to blender, but i finally find the time to look in to this! Sorry for necromancy, i just tested this as it seems this works good. Just few comments about general thing in a code add. I'll have to ask someone to check this in vfx side, but generally this is ready. Will check this again, before approve, after this will be approved in other side.
@ -701,7 +576,7 @@ void register_node_type_cmp_image()
void node_cmp_rlayers_outputs(bNodeTree *ntree, bNode *node)

I am wondering if that is possible to delete this function at all and replace all it's calls as declaration update directly.

I am wondering if that is possible to delete this function at all and replace all it's calls as declaration update directly.
Author
Contributor

Hey @mod_moder sorry for the (big) delay , had a bit on my plate lately...
I brought most modifications you requested , except this one ... this one is a tough cookie to crack :
I can't manage to find a proper and clean way to update the sockets declarations when checking render passes after deleting this function .
what happens is that after enabling a render pass , it isn't displayed on the node , but if I trigger other events like creating a link to a node , or launching a render , the node gets updated on the UI , and it displays the enabled render passes.

You say there's a way to do a declaration update ? should I deal with the bNodeSockets themselves in the declare function or would that be a hack ?

Hey @mod_moder sorry for the (big) delay , had a bit on my plate lately... I brought most modifications you requested , except this one ... this one is a tough cookie to crack : I can't manage to find a proper and clean way to update the sockets declarations when checking render passes after deleting this function . what happens is that after enabling a render pass , it isn't displayed on the node , but if I trigger other events like creating a link to a node , or launching a render , the node gets updated on the UI , and it displays the enabled render passes. You say there's a way to do a declaration update ? should I deal with the `bNodeSockets` themselves in the declare function or would that be a hack ?

I means, you can replace node_cmp_rlayers_outputs by update_node_declaration_and_sockets in other files.
Although it will probably be easier to do this as a separate cleanup.

I means, you can replace `node_cmp_rlayers_outputs` by `update_node_declaration_and_sockets` in other files. Although it will probably be easier to do this as a separate cleanup.
Author
Contributor

I put the call to update_node_declaration_and_sockets in ntreeCompositUpdateRLayers

I put the call to `update_node_declaration_and_sockets` in `ntreeCompositUpdateRLayers`

What about declaration of node_cmp_rlayers_outputs?

What about declaration of `node_cmp_rlayers_outputs`?
Author
Contributor

ah yes , good catch ...
I'll remove node_cmp_rlayers_register_pass as well since it's not needed anymore ?

ah yes , good catch ... I'll remove `node_cmp_rlayers_register_pass` as well since it's not needed anymore ?

If there is no any other usage, then yeah

If there is no any other usage, then yeah
Author
Contributor

it's done

it's done
@ -719,0 +603,4 @@
if (!STREQ(name, RE_PASSNAME_COMBINED)) {
switch (type) {
case SOCK_FLOAT:
builder->add_output<decl::Float>(name);

After f3a1dd1eb5, it's possible to pass type of value as another runtime argument in to add_output method directly.

After f3a1dd1eb5bd39925df746703fee9b6cd9cbc08f, it's possible to pass type of value as another runtime argument in to `add_output` method directly.
HamilcarR marked this conversation as resolved
@ -953,8 +851,6 @@ void register_node_type_cmp_rlayers()
ntype.flag |= NODE_PREVIEW;
node_type_storage(
&ntype, nullptr, file_ns::node_composit_free_rlayers, file_ns::node_composit_copy_rlayers);

Is both static functions is still necessary?

node_type_storage(&ntype, nullptr, node_free_standard_storage, node_copy_standard_storage);
Is both static functions is still necessary? ```Cpp node_type_storage(&ntype, nullptr, node_free_standard_storage, node_copy_standard_storage); ```

Stoop, why this function is still needed at all, there is no custom storage for now. Actually, this might cause memory leak right now?

Stoop, why this function is still needed at all, there is no custom storage for now. Actually, this might cause memory leak right now?
HamilcarR marked this conversation as resolved
Author
Contributor

My course work still require me to not relax and come back to blender, but i finally find the time to look in to this!
Sorry for necromancy, i just tested this as it seems this works good. Just few comments about general thing in a code add. I'll have to ask someone to check this in vfx side, but generally this is ready. Will check this again, before approve, after this will be approved in other side.

Hello , no worries !
I'm currently having issues with my computer , the disk has it's FS corrupted for some reason , and I lost everything, I see you made some additional notes , I'll bring fixes for them this week.

> My course work still require me to not relax and come back to blender, but i finally find the time to look in to this! > Sorry for necromancy, i just tested this as it seems this works good. Just few comments about general thing in a code add. I'll have to ask someone to check this in vfx side, but generally this is ready. Will check this again, before approve, after this will be approved in other side. Hello , no worries ! I'm currently having issues with my computer , the disk has it's FS corrupted for some reason , and I lost everything, I see you made some additional notes , I'll bring fixes for them this week.
Amine Bensalem changed title from Refractor: Compositor: Render layer node to dynamic declaration to WIP: Refractor: Compositor: Render layer node to dynamic declaration 2024-02-09 22:26:01 +01:00
Amine Bensalem force-pushed nodes-108728-cmp_node_r_layers from 3a8196fc23 to 2c97fc1669 2024-02-10 10:53:40 +01:00 Compare
Amine Bensalem force-pushed nodes-108728-cmp_node_r_layers from 2c97fc1669 to 5313e82181 2024-02-10 11:20:04 +01:00 Compare
Amine Bensalem added 1 commit 2024-02-10 11:34:49 +01:00
9f553ec86d Merge branch 'main' into nodes-108728-cmp_node_r_layers
# Conflicts:
#	source/blender/nodes/composite/nodes/node_composite_image.cc
Amine Bensalem added 1 commit 2024-02-10 21:06:33 +01:00
Amine Bensalem added 2 commits 2024-02-11 11:14:41 +01:00
f30447ad0f Refractor : Removed call to node_cmp_rlayers_outputs
Moved update_node_declaration_and_sockets to ntreeCompositUpdateLayers
Amine Bensalem changed title from WIP: Refractor: Compositor: Render layer node to dynamic declaration to Refractor: Compositor: Render layer node to dynamic declaration 2024-02-11 11:16:44 +01:00
Amine Bensalem added 1 commit 2024-02-11 11:47:47 +01:00
Iliya Katushenock approved these changes 2024-02-11 13:24:30 +01:00
@ -338,3 +218,2 @@
/* XXX make this into a generic socket verification function for dynamic socket replacement
* (multi-layer, groups, static templates). */
static void cmp_node_image_verify_outputs(bNodeTree *ntree, bNode *node, bool rlayer)
* (multi-layer, groups, static templates) */

Unrelated change of comment (.).

Unrelated change of comment (`.`).
Author
Contributor

sorry I didn't see the update , this one slipped through indeed

sorry I didn't see the update , this one slipped through indeed
Iliya Katushenock added the
Module
VFX & Video
label 2024-02-11 13:26:50 +01:00
Description of PR now can be changed (see: https://developer.blender.org/docs/handbook/guidelines/commit_messages/).
Iliya Katushenock requested review from Sergey Sharybin 2024-02-27 15:16:24 +01:00
Omar Emara requested review from Omar Emara 2024-02-27 15:47:51 +01:00
Sergey Sharybin requested changes 2024-02-28 18:06:36 +01:00
Dismissed
@ -342,4 +222,4 @@
bNodeSocket *sock, *sock_next;
LinkNodePair available_sockets = {nullptr, nullptr};
/* XXX make callback */

The comment can be removed now as resolved?

The comment can be removed now as resolved?
@ -558,0 +444,4 @@
static void node_rlayer_declare(NodeDeclarationBuilder &builder)
{
builder.add_output<decl::Color>("Image");

The logic here seems to be relying on the fact that render engine always has Combined pass, and adds Image socket here, and Alpha later on when cmp_node_create_sockets is called with pass name RE_PASSNAME_COMBINED.

It is not really always the case that render engine has to have Combined pass. It is un-conditional for the current default render engines, as this pass is always required internally, but some external render engine can respect the enabled state of the Combined pass in the View Layer settings.

So to match the old code the patch needs to inly add Image and Alpha if there is Combined pass in the render engine.

The logic here seems to be relying on the fact that render engine always has Combined pass, and adds Image socket here, and Alpha later on when `cmp_node_create_sockets` is called with pass name `RE_PASSNAME_COMBINED`. It is not really always the case that render engine has to have Combined pass. It is un-conditional for the current default render engines, as this pass is always required internally, but some external render engine can respect the enabled state of the Combined pass in the View Layer settings. So to match the old code the patch needs to inly add Image and Alpha if there is Combined pass in the render engine.
Author
Contributor

So to match the old code the patch needs to inly add Image and Alpha if there is Combined pass in the render engine.

Thank you for the feedback .
By this , do you mean checking the presence of the Combined pass as functionality , or just checking it's on/off state ?

Edit : So , I tested for a bit , by only adding image and alpha sockets when RE_PASSNAME_COMBINED is present , this causes the void ED_node_composit_default(const bContext *C, Scene *sce) function to try retrieving sockets that are null because they haven't yet been created.
I didn't see this have any other effect than not creating the default links between the render layer node and composite node ... yet.
If you have any advice on how to test this more thoroughly , I'd be interested.

> So to match the old code the patch needs to inly add Image and Alpha if there is Combined pass in the render engine. Thank you for the feedback . By this , do you mean checking the presence of the Combined pass as functionality , or just checking it's on/off state ? Edit : So , I tested for a bit , by only adding image and alpha sockets when `RE_PASSNAME_COMBINED` is present , this causes the `void ED_node_composit_default(const bContext *C, Scene *sce)` function to try retrieving sockets that are `null` because they haven't yet been created. I didn't see this have any other effect than not creating the default links between the render layer node and composite node ... yet. If you have any advice on how to test this more thoroughly , I'd be interested.
Amine Bensalem added 3 commits 2024-03-01 12:30:30 +01:00
Amine Bensalem requested review from Sergey Sharybin 2024-03-01 13:50:14 +01:00
Sergey Sharybin requested changes 2024-03-06 15:44:48 +01:00
Sergey Sharybin left a comment
Owner

Unfortunately, the default compositor setup is now invalid: the link between render layers node and the output is missing. This seems to be caused by the fact that in the old system the render layers node had init callback, which was verifying output sockets. Now there is no such callback, so sockets are not verified until BKE_ntree_update_main_tree is called.

Unfortunately, the default compositor setup is now invalid: the link between render layers node and the output is missing. This seems to be caused by the fact that in the old system the render layers node had init callback, which was verifying output sockets. Now there is no such callback, so sockets are not verified until `BKE_ntree_update_main_tree` is called.

@HamilcarR Can you check if names and identifiers of sockets is the same in blender with and without this changes? (this can be done via python) If no, we probably need to add versioning to replace old identifiers of sockets in files from older versions by new convention. Node declaration update are treated different identifiers as different sockets and does not keep the links.

@HamilcarR Can you check if names and identifiers of sockets is the same in blender with and without this changes? (this can be done via python) If no, we probably need to add versioning to replace old identifiers of sockets in files from older versions by new convention. Node declaration update are treated different identifiers as different sockets and does not keep the links.
Author
Contributor

Unfortunately, the default compositor setup is now invalid: the link between render layers node and the output is missing. This seems to be caused by the fact that in the old system the render layers node had init callback, which was verifying output sockets. Now there is no such callback, so sockets are not verified until BKE_ntree_update_main_tree is called.

By pure curiosity , does the default link between the r layers node and the composite node sockets only for UI and user experience ( meaning you open the compositor , you have basic nodes ready) , or is there non obvious mechanisms and features , relying on the fact those two nodes are automatically linked by default ?

> Unfortunately, the default compositor setup is now invalid: the link between render layers node and the output is missing. This seems to be caused by the fact that in the old system the render layers node had init callback, which was verifying output sockets. Now there is no such callback, so sockets are not verified until `BKE_ntree_update_main_tree` is called. By pure curiosity , does the default link between the r layers node and the composite node sockets only for UI and user experience ( meaning you open the compositor , you have basic nodes ready) , or is there non obvious mechanisms and features , relying on the fact those two nodes are automatically linked by default ?

@HamilcarR On the behavior level it is more of an UX thing: if such a link was not added automatically it could lead to a confusing situation then enabling compositing nodes makes your render result black.

On the actual code side it might go deeper. I think currently when adding nodes from Python it is possible to add Render Layer node and add links to all passes immediately after. With feels like this change might affect of this behavior. Didn't have time to verify it myself yet, but is definitely something to keep in mind and not introduce breaking changes.

@HamilcarR On the behavior level it is more of an UX thing: if such a link was not added automatically it could lead to a confusing situation then enabling compositing nodes makes your render result black. On the actual code side it might go deeper. I think currently when adding nodes from Python it is possible to add Render Layer node and add links to all passes immediately after. With feels like this change might affect of this behavior. Didn't have time to verify it myself yet, but is definitely something to keep in mind and not introduce breaking changes.
Amine Bensalem changed title from Refractor: Compositor: Render layer node to dynamic declaration to WIP: Refractor: Compositor: Render layer node to dynamic declaration 2024-04-25 17:53:42 +02:00
This pull request has changes conflicting with the target branch.
  • source/blender/nodes/composite/nodes/node_composite_image.cc

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u nodes-108728-cmp_node_r_layers:HamilcarR-nodes-108728-cmp_node_r_layers
git checkout HamilcarR-nodes-108728-cmp_node_r_layers
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 Assignees
4 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#114629
No description provided.