Nodes: add int and bool to shader nodegroups #115026

Merged
Brecht Van Lommel merged 3 commits from Diana-G/blender:shader-ints-bools into main 2024-01-10 20:09:46 +01:00
Contributor

Ints and Bools work as expected in shader nodegroups. I've known users in the past used the python api to add sockets of these types to shader nodegroups as they could not be selected via the dropdown, but that no longer works in 4.0. So I was wondering if there was a reason it was not included in the dropdown (maybe some sorta technical reason or something).

Also, I'm not sure if I'm following the correct protocol for making a PR

Ints and [Bools](https://projects.blender.org/blender/blender/pulls/109576) work as expected in shader nodegroups. I've known users in the past used the python api to add sockets of these types to shader nodegroups as they could not be selected via the dropdown, but that no longer works in 4.0. So I was wondering if there was a reason it was not included in the dropdown (maybe some sorta technical reason or something). Also, I'm not sure if I'm following the correct protocol for making a PR
Diana G added 1 commit 2023-11-17 05:50:01 +01:00
buildbot/vexp-code-patch-coordinator Build done. Details
a6f9cf906f
add int and bool to shader nodegroups
Iliya Katushenock added this to the Nodes & Physics project 2023-11-17 08:36:45 +01:00
Iliya Katushenock added the
Module
Render & Cycles
Interest
EEVEE & Viewport
labels 2023-11-17 08:36:54 +01:00
First-time contributor

Also the fact their not supported any more isn't in the release notes

Also the fact their not supported any more isn't in the release notes
Contributor

I think you need to tag reviewers. You can ask on Nodes & Physics module chat

I think you need to tag reviewers. You can ask on [Nodes & Physics module chat](https://blender.chat/channel/nodes-physics-module)
Author
Contributor

I think you need to tag reviewers. You can ask on Nodes & Physics module chat

I'm not sure how to do that, this is my first time really doing anything with blender development/etc

> I think you need to tag reviewers. You can ask on [Nodes & Physics module chat](https://blender.chat/channel/nodes-physics-module) I'm not sure how to do that, this is my first time really doing anything with blender development/etc
Hans Goudey requested review from Brecht Van Lommel 2023-11-20 19:55:51 +01:00
Member

Seems reasonable to me, I guess this was already possible in the past through Python. It's a bit weird though, since they aren't really passed as integers or booleans at all. Brecht would probably know best whether this is the right way to go.

Seems reasonable to me, I guess this was already possible in the past through Python. It's a bit weird though, since they aren't really passed as integers or booleans at all. Brecht would probably know best whether this is the right way to go.
Contributor

Seems reasonable to me, I guess this was already possible in the past through Python. It's a bit weird though, since they aren't really passed as integers or booleans at all. Brecht would probably know best whether this is the right way to go.

It's much needed UX tool, OSL shaders already have them, so they are present in Shader Nodes. It allows asset creators to restrict value to either 0 or 1 (or for example 0-1-2 for when choosing axis) and avoid anything in the middle. Currently we have to do math nodes for that behavior, but on user level it still looks like they can set value to 0.5 and get other result, so the property isn't communicated correctly to the user.

> Seems reasonable to me, I guess this was already possible in the past through Python. It's a bit weird though, since they aren't really passed as integers or booleans at all. Brecht would probably know best whether this is the right way to go. It's much needed UX tool, OSL shaders already have them, so they are present in Shader Nodes. It allows asset creators to restrict value to either 0 or 1 (or for example 0-1-2 for when choosing axis) and avoid anything in the middle. Currently we have to do math nodes for that behavior, but on user level it still looks like they can set value to 0.5 and get other result, so the property isn't communicated correctly to the user.
First-time contributor

I've used ints extensively in my nodegroups ever since i found the python command i could run to add them to my groups. Was really bummed out when i couldn't add them anymore with 4.0, hoping this gets accepted especially now that bools work as well, previously i just used an int between 0 and 1 for switches so having an actual checkbox would be fantastic

I've used ints extensively in my nodegroups ever since i found the python command i could run to add them to my groups. Was really bummed out when i couldn't add them anymore with 4.0, hoping this gets accepted especially now that bools work as well, previously i just used an int between 0 and 1 for switches so having an actual checkbox would be fantastic
First-time contributor

Seems reasonable to me, I guess this was already possible in the past through Python. It's a bit weird though, since they aren't really passed as integers or booleans at all. Brecht would probably know best whether this is the right way to go.

they are passed as ints, just the UI doesnt show it. had to switch things to floats and add extra round nodes to unbreak some nodetrees we had.

> Seems reasonable to me, I guess this was already possible in the past through Python. It's a bit weird though, since they aren't really passed as integers or booleans at all. Brecht would probably know best whether this is the right way to go. they are passed as ints, just the UI doesnt show it. had to switch things to floats and add extra round nodes to unbreak some nodetrees we had.
Author
Contributor

Seems reasonable to me, I guess this was already possible in the past through Python. It's a bit weird though, since they aren't really passed as integers or booleans at all. Brecht would probably know best whether this is the right way to go.

they are passed as ints, just the UI doesnt show it. had to switch things to floats and add extra round nodes to unbreak some nodetrees we had.

actually afaik theyre casted to floats and passed around as such, since shader nodes only accept floats, etc. the functionality for ints to floats have existed for years afaik while bools being casted is a new thing with 4.0

> > Seems reasonable to me, I guess this was already possible in the past through Python. It's a bit weird though, since they aren't really passed as integers or booleans at all. Brecht would probably know best whether this is the right way to go. > > they are passed as ints, just the UI doesnt show it. had to switch things to floats and add extra round nodes to unbreak some nodetrees we had. actually afaik theyre casted to floats and passed around as such, since shader nodes only accept floats, etc. the functionality for ints to floats have existed for years afaik while bools being casted is a [new thing with 4.0](https://projects.blender.org/blender/blender/pulls/109576)
First-time contributor

Seems reasonable to me, I guess this was already possible in the past through Python. It's a bit weird though, since they aren't really passed as integers or booleans at all. Brecht would probably know best whether this is the right way to go.

they are passed as ints, just the UI doesnt show it. had to switch things to floats and add extra round nodes to unbreak some nodetrees we had.

actually afaik theyre casted to floats and passed around as such, since shader nodes only accept floats, etc. the functionality for ints to floats have existed for years afaik while bools being casted is a new thing with 4.0

Right, but that 'cast to floats' effectively does a round on them, so you get an integer value, which if you just set the socket to float you loose, which then breaks the shaders that were using them.

> > > Seems reasonable to me, I guess this was already possible in the past through Python. It's a bit weird though, since they aren't really passed as integers or booleans at all. Brecht would probably know best whether this is the right way to go. > > > > they are passed as ints, just the UI doesnt show it. had to switch things to floats and add extra round nodes to unbreak some nodetrees we had. > > actually afaik theyre casted to floats and passed around as such, since shader nodes only accept floats, etc. the functionality for ints to floats have existed for years afaik while bools being casted is a [new thing with 4.0](https://projects.blender.org/blender/blender/pulls/109576) Right, but that 'cast to floats' effectively does a round on them, so you get an integer value, which if you just set the socket to float you loose, which then breaks the shaders that were using them.
Author
Contributor

Seems reasonable to me, I guess this was already possible in the past through Python. It's a bit weird though, since they aren't really passed as integers or booleans at all. Brecht would probably know best whether this is the right way to go.

they are passed as ints, just the UI doesnt show it. had to switch things to floats and add extra round nodes to unbreak some nodetrees we had.

actually afaik theyre casted to floats and passed around as such, since shader nodes only accept floats, etc. the functionality for ints to floats have existed for years afaik while bools being casted is a new thing with 4.0

Right, but that 'cast to floats' effectively does a round on them, so you get an integer value, which if you just set the socket to float you loose, which then breaks the shaders that were using them.

well yea, it displays to the user as an int (and therefore is locked to ints/whole numbers only) while technically internally its a float, preventing a user from entering in non whole values

> > > > Seems reasonable to me, I guess this was already possible in the past through Python. It's a bit weird though, since they aren't really passed as integers or booleans at all. Brecht would probably know best whether this is the right way to go. > > > > > > they are passed as ints, just the UI doesnt show it. had to switch things to floats and add extra round nodes to unbreak some nodetrees we had. > > > > actually afaik theyre casted to floats and passed around as such, since shader nodes only accept floats, etc. the functionality for ints to floats have existed for years afaik while bools being casted is a [new thing with 4.0](https://projects.blender.org/blender/blender/pulls/109576) > > Right, but that 'cast to floats' effectively does a round on them, so you get an integer value, which if you just set the socket to float you loose, which then breaks the shaders that were using them. well yea, it displays to the user as an int (and therefore is locked to ints/whole numbers only) while technically internally its a float, preventing a user from entering in non whole values

The main weakness I think is that there for larger integer values, floats can't represent them exactly so they will be off by a bit. But they end will end up in a float precision render buffer anyway, so it seems acceptable until there is native support.

@blender-bot build

The main weakness I think is that there for larger integer values, floats can't represent them exactly so they will be off by a bit. But they end will end up in a float precision render buffer anyway, so it seems acceptable until there is native support. @blender-bot build
Brecht Van Lommel approved these changes 2023-11-21 20:04:00 +01:00
Brecht Van Lommel requested changes 2023-11-22 17:41:08 +01:00
Brecht Van Lommel left a comment
Owner

One of the test is failing, as can be seen in the buildbot logs:
https://builder.blender.org/admin/#/builders/132/builds/2881/steps/6/logs/stdio

 89/317 Test  #90: bl_node_group_interface ..............................................***Failed    2.28 sec
======================================================================
FAIL: test_all_socket_types (__main__.ShaderNodeGroupInterfaceTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/blender/git/blender-vexp/blender.git/tests/python/bl_node_group_interface.py", line 404, in test_all_socket_types
    self.do_test_invalid_socket_type("NodeSocketBool")
  File "/home/blender/git/blender-vexp/blender.git/tests/python/bl_node_group_interface.py", line 115, in do_test_invalid_socket_type
    self.assertIsNone(in0, f"Socket created for invalid type {socket_type}")
AssertionError: bpy.data.node_groups['test'].interface.items_tree[0] is not None : Socket created for invalid type NodeSocketBool
----------------------------------------------------------------------
One of the test is failing, as can be seen in the buildbot logs: https://builder.blender.org/admin/#/builders/132/builds/2881/steps/6/logs/stdio ``` 89/317 Test #90: bl_node_group_interface ..............................................***Failed 2.28 sec ``` ``` ====================================================================== FAIL: test_all_socket_types (__main__.ShaderNodeGroupInterfaceTest) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/blender/git/blender-vexp/blender.git/tests/python/bl_node_group_interface.py", line 404, in test_all_socket_types self.do_test_invalid_socket_type("NodeSocketBool") File "/home/blender/git/blender-vexp/blender.git/tests/python/bl_node_group_interface.py", line 115, in do_test_invalid_socket_type self.assertIsNone(in0, f"Socket created for invalid type {socket_type}") AssertionError: bpy.data.node_groups['test'].interface.items_tree[0] is not None : Socket created for invalid type NodeSocketBool ---------------------------------------------------------------------- ```
Diana G added 1 commit 2023-11-27 20:41:38 +01:00
buildbot/vexp-code-patch-coordinator Build done. Details
cb11d913f5
update the failing test
Author
Contributor

I'm not sure if this is what I was supposed to do

I'm not sure if this is what I was supposed to do
Diana G requested review from Brecht Van Lommel 2023-11-27 20:42:30 +01:00
Brecht Van Lommel approved these changes 2023-11-27 22:33:03 +01:00

@blender-bot build

@blender-bot build
Author
Contributor

how would i go about fixing the failed tests?

how would i go about fixing the failed tests?

Merging latest main into this pull request should fix it.

Merging latest main into this pull request should fix it.
Brecht Van Lommel added 1 commit 2024-01-10 20:00:21 +01:00
Author
Contributor

Oh thank you, I forgot I made this PR

Oh thank you, I forgot I made this PR
Brecht Van Lommel merged commit eca14d5b40 into main 2024-01-10 20:09:46 +01:00
Brecht Van Lommel deleted branch shader-ints-bools 2024-01-10 20:09:48 +01:00
Sign in to join this conversation.
No reviewers
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
6 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#115026
No description provided.