PyDrivers in Cycles node value fields do not evaluate automatically #35863

Closed
opened 2013-06-25 04:59:20 +02:00 by Tom Telos · 10 comments

%%%Mac OS 10.6.8 2.16 GHz Intel Core 2 Duo Radeon X1600

blender-2.67-r57600-OSX-10.6-i386 (and r57661); 32-bit.

For motivation and intent, please see http://www.minimaexpresion.es/?p=1070&lang=en#comment-571

For bug itself, please see attached .png screenshot.

Summary:

1.- I have only one scene, and to it I have attached a Custom Property
    with name=ArchiDraft and value=1.0

2.- In a Cycles Value node, I have the PyDriver expression

bpy.data.scenes- [x].ArchiDraft
3.- I have Run the lines
import bpy
bpy.types.Scene.ArchiDraft = bpy.props.FloatProperty()
    Thanks to that,
    the Graph Editor acknowledges the aforementioned expression as valid.

4.- Even though the Properties panel has ArchiDraft set to 1.0
    the Graph Editor evaluates it to 0.000

5.- The Cycles Value node, which holds the bpy.data.scenes- [x].ArchiDraft
    expression, apparently evaluates it to 0.500 ;
    in reality, that number is just the initial default,
    which has not been updated.

6.- My intent is to drop the PyDriver expression into a Fac field of a Mix node;
    thus far, however, if I do that, the Node editor accepts it,
    but the Graph Editor does not acknowledge it at all.

7.- I can drop the exact same expression into e.g.
    an object’s Z rotation field, and then everything works as expected:
    thank you, gurus, and congratulations!
%%%

%%%Mac OS 10.6.8 2.16 GHz Intel Core 2 Duo Radeon X1600 blender-2.67-r57600-OSX-10.6-i386 (and r57661); 32-bit. For motivation and intent, please see http://www.minimaexpresion.es/?p=1070&amp;lang=en#comment-571 For bug itself, please see attached .png screenshot. Summary: 1.- I have only one scene, and to it I have attached a Custom Property &#x2003; &#x2003; with name=ArchiDraft and value=1.0 2.- In a Cycles Value node, I have the PyDriver expression <blockquote><i>bpy.data.scenes- [x].ArchiDraft </i></blockquote>3.- I have Run the lines<blockquote><i>import bpy bpy.types.Scene.ArchiDraft = bpy.props.FloatProperty()</i></blockquote>&#x2003; &#x2003; Thanks to that, &#x2003; &#x2003; the Graph Editor acknowledges the aforementioned expression as valid. 4.- Even though the Properties panel has ArchiDraft set to 1.0 &#x2003; &#x2003; the Graph Editor evaluates it to 0.000 5.- The Cycles Value node, which holds the <i>bpy.data.scenes- [x].ArchiDraft</i> &#x2003; &#x2003; expression, apparently evaluates it to 0.500 ; &#x2003; &#x2003; in reality, that number is just the initial default, &#x2003; &#x2003; which has not been updated. 6.- My intent is to drop the PyDriver expression into a Fac field of a Mix node; &#x2003; &#x2003; thus far, however, if I do that, the Node editor accepts it, &#x2003; &#x2003; but the Graph Editor does not acknowledge it at all. 7.- I can drop the exact same expression into e.g. &#x2003; &#x2003; an object’s Z rotation field, and then everything works as expected: &#x2003; &#x2003; thank you, gurus, and congratulations! %%%
Author

Changed status to: 'Open'

Changed status to: 'Open'

%%%Regarding 1) and 2), there's a difference between properties like bpy.props.FloatProperty that you can declare to exist on all Scenes, or just properties created on a single scene. Your driver expression can work without bpy.props.FloatProperty like this: bpy.data.scenes- [x]['ArchiDraft']
http://wiki.blender.org/index.php/Doc:2.6/Manual/Extensions/Python/Properties

%%%

%%%Regarding 1) and 2), there's a difference between properties like bpy.props.FloatProperty that you can declare to exist on all Scenes, or just properties created on a single scene. Your driver expression can work without bpy.props.FloatProperty like this: bpy.data.scenes- [x]['ArchiDraft'] http://wiki.blender.org/index.php/Doc:2.6/Manual/Extensions/Python/Properties %%%
Author

%%%bpy.data.scenes- [x]['ArchiDraft']

Interesting; thank you!

But, doesn't that mean that Cycles will trigger a character string search
for every sample of every pixel it is trying to render?%%%

%%%bpy.data.scenes- [x]['ArchiDraft'] Interesting; thank you! But, doesn't that mean that Cycles will trigger a character string search for every sample of every pixel it is trying to render?%%%
Author

%%%OK, having the Custom Property ArchiDraft=1.0 in the Properties panel,
linked to the scene, but without first executing

 import bpy
 bpy.types.Scene.ArchiDraft = bpy.props.FloatProperty()

I entered bpy.data.scenes- [x]['ArchiDraft']
as PyDriver into the Fac field of a Mix node, and found that

(a) The Graph Editor acknowledges it and does not complain. However:

(b) The Graph Editor evaluates the expression to 0.000 and the Node Editor to 0.500 (i.e. the default),

    even though the Properties panel acknowledges 1.000

(c) The same occurs if I drop the expression into a Value node.

Thank you for your patience!%%%

%%%OK, having the Custom Property ArchiDraft=1.0 in the Properties panel, linked to the scene, but without first executing ``` import bpy bpy.types.Scene.ArchiDraft = bpy.props.FloatProperty() ``` I entered bpy.data.scenes- [x]['ArchiDraft'] as PyDriver into the Fac field of a Mix node, and found that (a) The Graph Editor acknowledges it and does not complain. However: (b) The Graph Editor evaluates the expression to 0.000 and the Node Editor to 0.500 (i.e. the default), ``` even though the Properties panel acknowledges 1.000 ``` (c) The same occurs if I drop the expression into a Value node. Thank you for your patience!%%%

%%%Drivers are not evaluated per pixel or sample, they are evaluated once before rendering. So performance overhead is negligible. Also Python will do a character string search in both cases anyway (well actually accelerated with hash table).

I didn't check on the other issues yet.%%%

%%%Drivers are not evaluated per pixel or sample, they are evaluated once before rendering. So performance overhead is negligible. Also Python will do a character string search in both cases anyway (well actually accelerated with hash table). I didn't check on the other issues yet.%%%
Author

%%%...Drivers are not evaluated per pixel or sample, they are evaluated once before rendering...

Is that true even for noise.random() ?

I once used noise.random() to select shapekeys on a curl
that was duplifaced over a scalp, and one could see
that neighboring duplis were not identical.%%%

%%%...Drivers are not evaluated per pixel or sample, they are evaluated once before rendering... Is that true even for noise.random() ? I once used noise.random() to select shapekeys on a curl that was duplifaced over a scalp, and one could see that neighboring duplis were not identical.%%%
Author

%%%By the way, congratulations on that Toon BSDF, and THANK you for the Size and Smooth parameters!
I think I'm falling in love, as in, going to use it even for realistic renders, e.g. hair.

As for speed, 100% CPU, it just blows my hat off!%%%

%%%By the way, congratulations on that Toon BSDF, and THANK you for the Size and Smooth parameters! I think I'm falling in love, as in, going to use it even for realistic renders, e.g. hair. As for speed, 100% CPU, it just blows my hat off!%%%
Member

%%%I'm sad to say: the problem here is the depgraph :(

In theory, what you should do is:

  1. make a driver variable "var"
  2. link it to the Scene
  3. set ArchiDraft or ['ArchiDraft'] as the path (depending on RNA or custom property)
  4. use "var" as the driver expression

This does not work because of the limited depgraph, which does not evaluate drivers based on scene dependencies. The only reliable driver target atm are Objects - so if this is feasible, use an Object instead of Scene for the property!

Another option is to make an update callback for your property, then you don't need drivers in the first place.
http://www.blender.org/documentation/blender_python_api_2_68_2/bpy.props.html#update-example

In any case, it's a known ToDo, sorry. Hopefully the depgraph overhaul will fix it.%%%

%%%I'm sad to say: the problem here is the depgraph :( In theory, what you should do is: 1) make a driver variable "var" 2) link it to the Scene 3) set ArchiDraft or ['ArchiDraft'] as the path (depending on RNA or custom property) 4) use "var" as the driver expression This does not work because of the limited depgraph, which does not evaluate drivers based on scene dependencies. The only reliable driver target atm are Objects - so if this is feasible, use an Object instead of Scene for the property! Another option is to make an update callback for your property, then you don't need drivers in the first place. http://www.blender.org/documentation/blender_python_api_2_68_2/bpy.props.html#update-example In any case, it's a known ToDo, sorry. Hopefully the depgraph overhaul will fix it.%%%
Member

Changed status from 'Open' to: 'Archived'

Changed status from 'Open' to: 'Archived'
Author

%%%Wonderful to “hear” from you!

There’s a lot of buzz on wiki.blender.org regarding Dependency Graph improvements,
including a GSoC13 project: http://wiki.blender.org/index.php/User:Aligorith/GSoC2013_Depsgraph
so I’ll try to internalize what you are suggesting to me for now, and—

may the Force be with you!%%%
%%%Wonderful to “hear” from you! There’s a lot of buzz on wiki.blender.org regarding Dependency Graph improvements, including a GSoC13 project: http://wiki.blender.org/index.php/User:Aligorith/GSoC2013_Depsgraph so I’ll try to internalize what you are suggesting to me for now, and— ``` may the Force be with you!%%%
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
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 project
No Assignees
3 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#35863
No description provided.