Improve Cycles OSL nodes interface #89741

Open
opened 2021-07-08 20:20:15 +02:00 by Pedro A. · 11 comments
Contributor

I have found that the interface of the OSL nodes has certain limitations. I think some of them could have a relatively easy solution. For example, change how vectors are displayed in the node. This simple change will improve the appearance of the larger nodes. Another aspect to improve is the interface for image files. Using a 'string' field allow to introducing typographical errors by the user. I think a PointerProperty to bpy.types.Image would be more convenient.
I hope these proposals make sense.
vectors.png

Main task list:

    • Add code to processing the parameter metadata if exist.
    • Define the correct node socket for a boolean case.
    • Expand the code to processing the boolean socket value.
    • Modify 'node_find_input_by_name' function code to use a 'identifier'.
    • Redefine the function that remove the node inputs when the type don't match.
      Sub tasks:
    • Add the properly metadata for booleans and maybe also for labels, into the OSL shaders included with Cycles.
I have found that the interface of the OSL nodes has certain limitations. I think some of them could have a relatively easy solution. For example, change how vectors are displayed in the node. This simple change will improve the appearance of the larger nodes. Another aspect to improve is the interface for image files. Using a 'string' field allow to introducing typographical errors by the user. I think a PointerProperty to bpy.types.Image would be more convenient. I hope these proposals make sense. ![vectors.png](https://archive.blender.org/developer/F10217283/vectors.png) Main task list: - - [x] Add code to processing the parameter metadata if exist. - - [x] Define the correct node socket for a boolean case. - - [x] Expand the code to processing the boolean socket value. - - [x] Modify 'node_find_input_by_name' function code to use a 'identifier'. - - [x] Redefine the function that remove the node inputs when the type don't match. Sub tasks: - - [ ] Add the properly metadata for booleans and maybe also for labels, into the OSL shaders included with Cycles.
Author
Contributor

Added subscriber: @povmaniac

Added subscriber: @povmaniac
Pedro A. self-assigned this 2021-07-08 20:52:08 +02:00

Added subscriber: @CreatorSiSo

Added subscriber: @CreatorSiSo
Author
Contributor

I think the first step to improve how some options are drawn in the interface is to add a suitable definition for each option within the OSL code.
For example, for Booleans.

int zup = 0 [[ string widget = "checkBox", string label = "Z-Up", int connectable = 0 ]],

Without this definition, it is quite difficult to deduce when an option is a Boolean or an integer.

I think the first step to improve how some options are drawn in the interface is to add a suitable definition for each option within the OSL code. For example, for Booleans. ``` int zup = 0 [[ string widget = "checkBox", string label = "Z-Up", int connectable = 0 ]], ``` Without this definition, it is quite difficult to deduce when an option is a Boolean or an integer.

Added subscriber: @brecht

Added subscriber: @brecht
  • Vector input: it's unclear how that relates to OSL metadata. With horizontal X/Y/Z values there is not enough space in typical node sizes, and it's unclear how this is different for OSL than any other type of node.
  • Image datablocks: these have more information than just a filepath string. The image may be packed, dynamically generated, and have additional parameters such as frame number or layer/pass. How that would map to OSL parameters (or not) would need to be defined. It also relates to this discussion: https://devtalk.blender.org/t/input-socket-for-image-texture-shader-node/19601
  • Boolean input: this is the easiest one, just needs minor changes to handle boolean sockets as integers in the Cycles/Eevee code
* Vector input: it's unclear how that relates to OSL metadata. With horizontal X/Y/Z values there is not enough space in typical node sizes, and it's unclear how this is different for OSL than any other type of node. * Image datablocks: these have more information than just a filepath string. The image may be packed, dynamically generated, and have additional parameters such as frame number or layer/pass. How that would map to OSL parameters (or not) would need to be defined. It also relates to this discussion: https://devtalk.blender.org/t/input-socket-for-image-texture-shader-node/19601 * Boolean input: this is the easiest one, just needs minor changes to handle boolean sockets as integers in the Cycles/Eevee code
Author
Contributor

Thanks for your tips, Brecht.
Vector input: the idea is save vertical space in the node, but yes, in the 'normal' node sizes the horizontal space maybe is not enough. But the user can extend the node size easily.
Image datablock: currently I use the typicall 'template_ID' image file interface for my nodes, that is not perfect but is very clossely to the used in the Blender texture node.
{F10231931, width=100%}

Thanks for your tips, Brecht. Vector input: the idea is save vertical space in the node, but yes, in the 'normal' node sizes the horizontal space maybe is not enough. But the user can extend the node size easily. Image datablock: currently I use the typicall 'template_ID' image file interface for my nodes, that is not perfect but is very clossely to the used in the Blender texture node. {[F10231931](https://archive.blender.org/developer/F10231931/image_data.png), width=100%}
Author
Contributor

After some testing, I have verified that the definition of each property added in the .osl file is processed and added in metadata format inside the .oso file

shader node_ies_light(int use_mapping = 0 [[ string label="Use Mapping", string widget="checkBox" ]],

This generates the following metadata:

param int use_mapping 0 %meta{string,label,"Use Mapping"} %meta{string,widget,"checkBox"}  %read{2,2} %write{2147483647,-1}

The next step is to add the property definition in some cases like booleans or image files.
Later, we can advise users to do the same when using their own OSL code.

After some testing, I have verified that the definition of each property added in the .osl file is processed and added in metadata format inside the .oso file ``` shader node_ies_light(int use_mapping = 0 [[ string label="Use Mapping", string widget="checkBox" ]], ``` This generates the following metadata: ``` param int use_mapping 0 %meta{string,label,"Use Mapping"} %meta{string,widget,"checkBox"} %read{2,2} %write{2147483647,-1} ``` The next step is to add the property definition in some cases like booleans or image files. Later, we can advise users to do the same when using their own OSL code.
Author
Contributor

I have created a first patch for review by the Blender developers. https://developer.blender.org/D12074

I have created a first patch for review by the Blender developers. https://developer.blender.org/D12074
Author
Contributor

@brecht I applied all the required changes and I added the blender_shader.cpp part that I think is necessary modify. https://developer.blender.org/D12074?id=40152
Thanks..

@brecht I applied all the required changes and I added the blender_shader.cpp part that I think is necessary modify. https://developer.blender.org/D12074?id=40152 Thanks..

This issue was referenced by e6bbbd965a

This issue was referenced by e6bbbd965a447249393a27f911a1b29595c439ab
Brecht Van Lommel added this to the Render & Cycles project 2023-02-07 19:08:35 +01:00
Philipp Oeser removed the
Interest
Render & Cycles
label 2023-02-09 14:02:25 +01:00

Something I noticed is that I ran into an assert, there's a bitmask on the amount of input plugs to a max of uint64_t (64 plugs) in Cycles.

Yes I have made an OSL node that uses just under 100 plugs and yes they are all needed... :)

Something I noticed is that I ran into an assert, there's a bitmask on the amount of input plugs to a max of uint64_t (64 plugs) in Cycles. Yes I have made an OSL node that uses just under 100 plugs and yes they are all needed... :)
Iliya Katushenock removed the
Status
Needs Triage
label 2023-07-02 12:43:55 +02:00
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
5 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#89741
No description provided.