Cycles: Merge Anisotropic BSDF node into Glossy BSDF node #104445

Merged
Lukas Stockner merged 3 commits from LukasStockner/blender:remove-anisotropic-bsdf-node into main 2023-05-18 23:12:28 +02:00
Member

Used to be https://archive.blender.org/developer/D17123.

Internally these are already using the same code path anyways, there's no point in maintaining two distinct nodes.

The obvious approach would be to add Anisotropy controls to the Glossy BSDF node and remove the Anisotropic BSDF node. However, that would break forward compability, since older Blender versions don't know how to handle the Anisotropy input on the Glossy BSDF node.

Therefore, this commit technically removes the Glossy BSDF node, uses versioning to replace them with an Anisotropic BSDF node, and renames that node to "Glossy BSDF".

That way, when you open a new file in an older version, all the nodes show up as Anisotropic BSDF nodes and render correctly.

This is a bit ugly internally since we need to preserve the old idname which now no longer matches the UI name, but that's not too bad.

Also removes the "Sharp" distribution option and replaces it with GGX, sets Roughness to zero and disconnects any input to the Roughness socket.

Used to be https://archive.blender.org/developer/D17123. Internally these are already using the same code path anyways, there's no point in maintaining two distinct nodes. The obvious approach would be to add Anisotropy controls to the Glossy BSDF node and remove the Anisotropic BSDF node. However, that would break forward compability, since older Blender versions don't know how to handle the Anisotropy input on the Glossy BSDF node. Therefore, this commit technically removes the Glossy BSDF node, uses versioning to replace them with an Anisotropic BSDF node, and renames that node to "Glossy BSDF". That way, when you open a new file in an older version, all the nodes show up as Anisotropic BSDF nodes and render correctly. This is a bit ugly internally since we need to preserve the old `idname` which now no longer matches the UI name, but that's not too bad. Also removes the "Sharp" distribution option and replaces it with GGX, sets Roughness to zero and disconnects any input to the Roughness socket.
Lukas Stockner requested review from Brecht Van Lommel 2023-02-08 00:33:30 +01:00
Brecht Van Lommel added this to the Render & Cycles project 2023-02-08 03:11:05 +01:00
Lukas Stockner changed title from Merge Anisotropic BSDF node into Glossy BSDF node to Cycles: Merge Anisotropic BSDF node into Glossy BSDF node 2023-02-08 13:16:32 +01:00

@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) for details.
Lukas Stockner force-pushed remove-anisotropic-bsdf-node from fe049753ac to 4426121a07 2023-02-11 21:28:53 +01:00 Compare
Lukas Stockner requested review from Weizhen Huang 2023-02-11 21:32:49 +01:00

The one place where this is still breaking compatibility is the Python API. We could provide most of the compatibility like this:

/* For backwards compatibility. */
void nodeRegisterTypeAlias(bNodeType *nt, const char *alias_idname)
{
  BLI_ghash_insert(nodetypes_hash, alias_idname, nt);
}
  nodeRegisterTypeAlias(&ntype, "ShaderNodeBsdfGlossy");

Not great but still worth doing I think.

The one place where this is still breaking compatibility is the Python API. We could provide most of the compatibility like this: ```C /* For backwards compatibility. */ void nodeRegisterTypeAlias(bNodeType *nt, const char *alias_idname) { BLI_ghash_insert(nodetypes_hash, alias_idname, nt); } ``` ```C nodeRegisterTypeAlias(&ntype, "ShaderNodeBsdfGlossy"); ``` Not great but still worth doing I think.
Brecht Van Lommel requested changes 2023-02-17 15:07:55 +01:00
Brecht Van Lommel left a comment
Owner

LGTM except for the note about API compatibility.

LGTM except for the note about API compatibility.
Author
Member

The one place where this is still breaking compatibility is the Python API. We could provide most of the compatibility like this:

/* For backwards compatibility. */
void nodeRegisterTypeAlias(bNodeType *nt, const char *alias_idname)
{
  BLI_ghash_insert(nodetypes_hash, alias_idname, nt);
}
  nodeRegisterTypeAlias(&ntype, "ShaderNodeBsdfGlossy");

Not great but still worth doing I think.

From what I can tell the node type list is used by NODE_TYPES_BEGIN, which would then iterate over the same node type twice, which would cause some double-free etc. issues.
Also, the new node would end up with the alias in idname, which would probably also cause issues?
It might be easier to apply the alias at the RNA level.

> The one place where this is still breaking compatibility is the Python API. We could provide most of the compatibility like this: > ```C > /* For backwards compatibility. */ > void nodeRegisterTypeAlias(bNodeType *nt, const char *alias_idname) > { > BLI_ghash_insert(nodetypes_hash, alias_idname, nt); > } > ``` > > ```C > nodeRegisterTypeAlias(&ntype, "ShaderNodeBsdfGlossy"); > ``` > > Not great but still worth doing I think. From what I can tell the node type list is used by `NODE_TYPES_BEGIN`, which would then iterate over the same node type twice, which would cause some double-free etc. issues. Also, the new node would end up with the alias in `idname`, which would probably also cause issues? It might be easier to apply the alias at the RNA level.
Lukas Stockner force-pushed remove-anisotropic-bsdf-node from 4426121a07 to 34792de366 2023-05-08 01:10:34 +02:00 Compare

Let's not worry about API compatibility then, and just land this in 4.0 where we can make such breaking changes. We will likely rename a bunch of nodes and sockets anyway.

We just need to remember to add it to the release notes.

Let's not worry about API compatibility then, and just land this in 4.0 where we can make such breaking changes. We will likely rename a bunch of nodes and sockets anyway. We just need to remember to add it to the release notes.
Brecht Van Lommel approved these changes 2023-05-10 21:09:36 +02:00
Lukas Stockner added the
Module
Render & Cycles
label 2023-05-16 02:16:58 +02:00
Lukas Stockner added this to the 4.0 milestone 2023-05-16 02:17:01 +02:00
Lukas Stockner force-pushed remove-anisotropic-bsdf-node from 34792de366 to 7ed90ebd90 2023-05-18 23:09:54 +02:00 Compare
Lukas Stockner merged commit 8cde7d8f8a into main 2023-05-18 23:12:28 +02:00
Lukas Stockner deleted branch remove-anisotropic-bsdf-node 2023-05-18 23:12:29 +02:00
Brecht Van Lommel removed this from the Render & Cycles project 2023-05-24 19:05:20 +02:00
Howard Trickey referenced this issue from a commit 2023-05-29 02:51:38 +02:00

Commit 8cde7d8f8a adds versioning code to versioning_300.cc, when it only exists in 4.0 and not 3.6. Think it should rather be moved to versioning_400.cc?

    /* Convert anisotropic BSDF node to glossy BSDF. */
    FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
      versioning_replace_legacy_glossy_node(ntree);
      versioning_remove_microfacet_sharp_distribution(ntree);
    }
    FOREACH_NODETREE_END;
Commit 8cde7d8f8a5a07 adds versioning code to `versioning_300.cc`, when it only exists in 4.0 and not 3.6. Think it should rather be moved to `versioning_400.cc`? ``` /* Convert anisotropic BSDF node to glossy BSDF. */ FOREACH_NODETREE_BEGIN (bmain, ntree, id) { versioning_replace_legacy_glossy_node(ntree); versioning_remove_microfacet_sharp_distribution(ntree); } FOREACH_NODETREE_END; ```

I fixed it now, since these were failing after this was made to only run for 3.x files.

I fixed it now, since these were failing after this was made to only run for 3.x files.
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 project
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#104445
No description provided.