Author Topic: Bitmap shader conversion scripts  (Read 9121 times)

2023-12-22, 17:10:56

John_Do

  • Active Users
  • **
  • Posts: 195
    • View Profile
Hey guys,

Here are some custom scripts for you, just in time for Christmas !

- C4D Bitmap to Corona Bitmap
- Corona Bitmap to C4D Bitmap
- Update normals filtering
- Sort Corona Materials by Type
- Select Corona Materials by Type


I wrote them a quite some time ago but with the perspective of releasing more scripts next year, I've improved them in many ways and while they're not perfect (details here), I hope they will be useful to some of you.

INSTALLATION, USAGE AND LIMITATIONS
Read the docs

WHAT IT DOES
Convert Bitmaps Scripts


Pretty self explanatory, convert all the bitmaps shaders in the material in one way or another ( C4D Bitmap >< Corona Bitmap )

Update Normals Filtering


Change the normals filtering method to Roughness Modulation over the selected materials.
Note that Roughness modulation comes with some limitations, mainly when mixing Corona shaders with Cinema ones. More info here : https://support.chaos.com/hc/en-us/articles/19161682524305

Sort Corona Materials by Type


Sort all Corona Materials in the scene by type using dedicated layers

Select Corona Materials by Type


Select all the Corona Materials of the chosen type

---
Updates
2024.01.17 : Original scripts updated, two new scripts
« Last Edit: 2024-01-17, 19:34:54 by John_Do »

2023-12-22, 18:16:22
Reply #1

John_Do

  • Active Users
  • **
  • Posts: 195
    • View Profile
Some moving pictures to get a better feel of the script


2023-12-22, 18:45:43
Reply #2

Beanzvision

  • Former Corona Team Member
  • Active Users
  • **
  • Posts: 3881
  • Bengamin
    • View Profile
    • Cormats
Thanks for sharing John, looks very handy indeed :)
Bengamin Jerrems:
Portfolio l Click me!

2023-12-22, 20:05:29
Reply #3

BatRM

  • Active Users
  • **
  • Posts: 16
    • View Profile
Thank you very much John_Do, the bitmap converter is really a time saver!

2023-12-25, 12:07:08
Reply #4

Evolist_ua

  • Active Users
  • **
  • Posts: 43
    • View Profile
Wow, thanks a lot!

Now we need to wait for the developers to fix the bug with bitmap+ transformation in layer shader

2024-01-17, 19:49:15
Reply #5

John_Do

  • Active Users
  • **
  • Posts: 195
    • View Profile
I've just update the archive with the latest version of the scripts, and wrote somewhat of a documentation.

For the bitmap conversion scripts the Layer Shader is now supported ( even when nested inside another Layer Shader ) BUT the undo is broken in this specific case, something on the Python SDK side which could be investigated. So be careful and use the other conversion script to go back.

Updated the Normals Filtering script with a dialog box to choose the filtering method. Also new icon.



And I've added two scripts to sort Corona Materials in your scenes. Not the most exciting thing but it has been useful for me once or twice, so maybe for you too.





2024-02-06, 20:19:32
Reply #6

katzenwaffe

  • Active Users
  • **
  • Posts: 43
    • View Profile
Theese scripts are totally awesome! Love it!!

Good work!

2024-02-07, 11:19:22
Reply #7

Beanzvision

  • Former Corona Team Member
  • Active Users
  • **
  • Posts: 3881
  • Bengamin
    • View Profile
    • Cormats
Is this not working for S22? Seems to be fine in 2023/24 ;)
Bengamin Jerrems:
Portfolio l Click me!

2024-02-07, 13:10:19
Reply #8

John_Do

  • Active Users
  • **
  • Posts: 195
    • View Profile
Is this not working for S22? Seems to be fine in 2023/24 ;)

I don't know, I haven't tested the scripts on anything other than the latest 2024.1/2024.2. Did you try it on S22 ?

2024-02-07, 17:36:34
Reply #9

Beanzvision

  • Former Corona Team Member
  • Active Users
  • **
  • Posts: 3881
  • Bengamin
    • View Profile
    • Cormats
I did but no luck. Not to worry though ;)
Bengamin Jerrems:
Portfolio l Click me!

2024-04-12, 16:52:10
Reply #10

John_Do

  • Active Users
  • **
  • Posts: 195
    • View Profile
I'm still planning to release more scripts, here is a little work in progress :

Smart creation


Creating multiple shaders at once


Works also with only one node


Even if there is no node selected


And all the commands can be assigned to a keyboard shortcut! 🥰

2024-04-12, 20:49:53
Reply #11

Beanzvision

  • Former Corona Team Member
  • Active Users
  • **
  • Posts: 3881
  • Bengamin
    • View Profile
    • Cormats
Excellent stuff :)
Bengamin Jerrems:
Portfolio l Click me!

2024-04-15, 15:33:06
Reply #12

tuami

  • Active Users
  • **
  • Posts: 192
    • View Profile
I'm still planning to release more scripts, here is a little work in progress :


whoa i need this! would be great if there are more shaders to be found there, thanks keep doing great helpful work :)

2024-05-07, 18:03:01
Reply #13

John_Do

  • Active Users
  • **
  • Posts: 195
    • View Profile
Moar progress, even if I'm a bit slow lately because of ongoing projects :

Implemented the thing as a plugin



New commands to add often used shaders




More shaders available for insertion in existing node tree, some with unique behaviors




Added something for the tidy maniacs


Finally solved something that was bothering me from a long time

Create mask directly from the active selection and (almost) never bother again with ID numbers


It works on objects and materials, and can create one mask for each selected element or a shared one



For sure it's not really useful if you can leverage Cryptomatte but otherwise, it makes the process a bit simpler and faster.
« Last Edit: 2024-05-07, 18:45:09 by John_Do »

2024-06-21, 09:23:44
Reply #14

tuami

  • Active Users
  • **
  • Posts: 192
    • View Profile
hey when are you planning to publish this? i think it's totally great what you're doing, greetings
tuami

Moar progress, even if I'm a bit slow lately because of ongoing projects :

Implemented the thing as a plugin


2024-06-25, 10:45:48
Reply #15

John_Do

  • Active Users
  • **
  • Posts: 195
    • View Profile
Hey, thanks for the reminder and the interest. I didn't have much time to spend on it lately, I have to get back to it !

2024-07-06, 09:35:06
Reply #16

billycoopdraws

  • Active Users
  • **
  • Posts: 13
    • View Profile
Thank You John !!!
You are APPRECIATED !!!

2024-07-10, 10:38:53
Reply #17

m4drid

  • Active Users
  • **
  • Posts: 19
    • View Profile
Hey, when are you going to release this plugin, it's really, really, really good!

2024-08-07, 08:22:49
Reply #18

iamjens

  • Active Users
  • **
  • Posts: 6
    • View Profile
    • iamjens.net
Very useful. Please keep working on it. Thanks!

2024-10-23, 14:15:32
Reply #19

John_Do

  • Active Users
  • **
  • Posts: 195
    • View Profile
I'm back on the project, I'd like to finish it before the end of the year.

I got motivated again by writing a new command. I don't know why I didn't come up with the idea sooner since I know the ins and outs of Corona Materials for a while now.



Not perfect yet - it breaks with some textures sets - but in the end it will allow you to load pretty much any texture set from any vendor, as long as it follows loosely the PBR convention.


2024-10-28, 11:14:36
Reply #20

mlon

  • Active Users
  • **
  • Posts: 49
    • View Profile
Yai for motivation! :)

2024-10-31, 14:30:22
Reply #21

frv

  • Active Users
  • **
  • Posts: 419
    • View Profile
Tx, You have a good sense of automating the tedious work involved setting up materials. This is AI on a small but important scale. Especially for those among us who render for a living. So much of the work is unnecessarily repetitive.

I am sure years from now we shoot a few photos and the render app just sort the materials out itself. D5 already does that with the sky and sunlight. Magnific AI has some of that too. It may not even take years.

2024-11-01, 11:14:53
Reply #22

John_Do

  • Active Users
  • **
  • Posts: 195
    • View Profile
Tx, You have a good sense of automating the tedious work involved setting up materials. This is AI on a small but important scale. Especially for those among us who render for a living. So much of the work is unnecessarily repetitive.

That's exactly why I'm working on this toolset, because using Blender next to C4D every day made me feel that the node editor could greatly benefit from some love. Unfortunately there's only so much I can do, I had a bit of help from the devs to get started  but apart from that Corona doesn't offer any documentation for Python scripting and even so, I don't have access to everything through the Python API.

I've made a bit of progress on the tools but I'm struggling with the Shared Shader, which is designed to work around the fact that a node in Cinema 4D can't have multiple parents (so a shader output can't be connected to several nodes by design). I'm talking about the classic Cinema 4D materials here, C4D Nodes Materials are something else entirely.

So it kind of works : the shaders are linked and work, but the node links aren't displayed properly. It could be ok if it was a one-time thing but unfortunately, the links disappear each time the node graph is refreshed ( like when copy-pasting a material to a new scene, or dropping the material in a new node editor view).






2024-11-30, 18:57:06
Reply #23

Karen1231

  • Users
  • *
  • Posts: 1
    • View Profile
Hi!Jhon!thank you very much for those excellent scripts! I have also been experimenting with scripting for Corona recently, but I couldn’t find a way to get the selected shader nodes in the C4D SDK. (At the moment, I can only obtain the node by using special same name for all the needed nodes, but this method is very cumbersome.) Not to mention that Corona does not seem to provide any SDK.However, I noticed that your script has an operation to obtain the selected nodes. I would like to ask how this is achieved, and I hope to get some tips.
Again, thanks so much!

Yesterday at 15:12:25
Reply #24

John_Do

  • Active Users
  • **
  • Posts: 195
    • View Profile
Hi!Jhon!thank you very much for those excellent scripts! I have also been experimenting with scripting for Corona recently, but I couldn’t find a way to get the selected shader nodes in the C4D SDK. (At the moment, I can only obtain the node by using special same name for all the needed nodes, but this method is very cumbersome.) Not to mention that Corona does not seem to provide any SDK.However, I noticed that your script has an operation to obtain the selected nodes. I would like to ask how this is achieved, and I hope to get some tips.
Again, thanks so much!

Hi,

Ales ( Corona C4D dev ) showed me how to access the nodal editor, nodes are stored under each node editor view, in a dedicated scene hook.

Code: [Select]
# Access the Corona Node Material Scene Hook
nh = c4d.documents.GetActiveDocument().FindSceneHook(1040750)

# Get the branches containing the nodes
branches = nh.GetBranchInfo(0)

# Get the CNodeSystemViews node that contains the node editor views
for i in branches :
            if i.get('id') == 1040910:
                view = i.get('head')
                views = view.GetChildren()
                return views
        return None

# Then you can navigate in views and node widgets like with any object based on c4d.GeListNode.

# Rename the first view
views[0].SetName("First View")

# Get the first node
views[0].GetDown()

All node widgets are stored under a view. Shaders are either parented to a material if inserted into one, or under the scene hook if free from any parent in the node editor.

Some general instructions like the ones above would be nice to find in the documentation, but IMO a SDK is not necessary since the Corona devs followed as much as possible the "native implementation" described by the C4D SDK. If you know your way around the C4D API, you know how to deal with most things.

Hope it helps