Page MenuHome

Support for native render capabilities in custom render engines through Python API. (version 2)
AbandonedPublic

Authored by Campbell Barton (campbellbarton) on Mar 17 2015, 1:16 PM.

Details

Summary

This patch was created as a more simple alternative to D1175.
This patch makes it possible to use native shader nodetree from custom render engine. It makes no serious changes that can break down current design compared to D1175: there is no engine ID replacement with a bit flag. This patch enables one simple thing: the possibility to edit the native shader nodetree in custom render engine.

Alexander (Blend4Web Team)

Diff Detail

Event Timeline

That's quite better already, but I would be still interested to know how it's possible for an engine to use the native node tree..Does it sit on top, does it pass data after rendering? This is not a big change but it's best to make sure this is defined well before allowing engines to assume they can do this.

That's quite better already, but I would be still interested to know how it's possible for an engine to use the native node tree. Does it sit on top, does it pass data after rendering? This is not a big change but it's best to make sure this is defined well before allowing engines to assume they can do this.

Actually, we simply need to edit native node structure, this is much better than inventing custom node system incompatible with Blender's Viewort/BI.

With this patch, external engines receive the opportunity to use a complete node tree and to draw the scene in their own way. For example, BI and Viewport use the same node tree now, but actually they are separate render engines. Our engine uses the same nodes and tries to draw the material in browser similarly to the Viewport material, and this is why our users like to use Blend4Web :)

Sergey Sharybin (sergey) edited edge metadata.EditedMar 18 2015, 1:55 PM

I'm kind of skeptical about such change, it's kinda conflicts with existing bl_use_shading_nodes. Instead of hacking some quick stuff supporting particular render engine i would like to see more clear definition of what existing flags should do and maybe just behavior of existing flags is to be changed/fixed.

EDIT: Or ideally it should be possible to subclass existing node trees and use them as custom ones.

There is some confusion here:

  • bl_use_shading_nodes exists already (RE_USE_SHADING_NODES), however this is switching between [Cycles/BlenderInternal] node trees. On face value I would imagine enabling this flag would allow an external engine to use Blender's nodes.
  • A new option will enable any engine using shading nodes, but bl_use_shading_nodes will still take effect to switch between either shading system.

This is kludgy but would be good to attempt to be clear with whats going on.

Perhaps have a flag, bl_use_shading_nodes_custom / RE_USE_SHADING_NODES_CUSTOM so engines can explicitly set this to False if they want to use Blenders existing node-tree's.
Enabled by default so existing engines don't break.

There is some confusion here:

  • bl_use_shading_nodes exists already (RE_USE_SHADING_NODES), however this is switching between [Cycles/BlenderInternal] node trees. On face value I would imagine enabling this flag would allow an external engine to use Blender's nodes.
  • A new option will enable any engine using shading nodes, but bl_use_shading_nodes will still take effect to switch between either shading system.

Indeed this option is confusing one and if we are going to rename it, we also should change cycles addon. However it is out of the scope of this review. Still, if you prefer, I will make a corresponding update here.

This is kludgy but would be good to attempt to be clear with whats going on.
Perhaps have a flag, bl_use_shading_nodes_custom / RE_USE_SHADING_NODES_CUSTOM so engines can explicitly set this to False if they want to use Blenders existing node-tree's.
Enabled by default so existing engines don't break.

It would be great! It looks like all we need to do here is just to rename our bitflag. Also, this new name has more generic usage context.

I don't really agree with @Campbell Barton (campbellbarton)'s idea about bl_use_shading_nodes_custom. It's just inverted name of what this patch suggests and supporting it will break existing render engines.

it should be more carefully thought about semantics and naming of flags, making them clear and preferably without compatibility breakeges.

I don't really agree with @Campbell Barton (campbellbarton)'s idea about bl_use_shading_nodes_custom. It's just inverted name of what this patch suggests and supporting it will break existing render engines.
it should be more carefully thought about semantics and naming of flags, making them clear and preferably without compatibility breakeges.

Actually, I don't see any incompatibilities here, because USE_SHADING_NODES_CUSTOM will be set by default.
For now all external engines don't have the possibility to work with the native nodetree. With this patch the situation remains the same. Also, I think this is not just a simple invertion because USE_NATIVE_NODE_TREE has one disadvantage: It has no effect on BI, BGE, CYCLES in context of the nodetree poll function. Maybe, better name would be bl_use_custom_shading_nodes; not custom flag, but custom nodes.

Alexander Romanov (a.romanov) updated this revision to Diff 3836.

Update: how the patch would be look like after changing RE_USE_NATIVE_NODE_TREE to RE_USE_SHADING_NODES_CUSTOM:

Updated for the actual master.

Helper blend file is attached.

  1. Run the script
  2. Choose "test" as render engine
  3. Now you can edit shader node tree. This is a new feature for external engines.
  1. Make "bl_use_shading_nodes_custom = False" commented
  2. Run the script
  3. The icon of material is disappeared now and you can't add new shader nodes. This is an old behavior.
Campbell Barton (campbellbarton) accepted this revision.
source/blender/makesrna/intern/rna_render.c
635

Should include RNA_def_property_boolean_default(... true);

This revision is now accepted and ready to land.May 6 2015, 3:55 PM
This revision now requires review to proceed.May 6 2015, 3:55 PM

Thanks for this review and approval. This code is very important because it allows us to continue our work on Blend4Web addon interface.