Driving a switch node with renderer picked in viewport ?

   240   2   1
User Avatar
Member
2 posts
Joined: 11月 2024
オフライン
Hello,

I am making a small lookdev HDA just for myself and I like to switch between Karma and Redshift quite a lot to try both renderers. My idea was making a switch node with a Karma branch and a Redshift branch with the render settings.

I can make this manual with an index selection exposed on the HDA, which works.

But I was wondering if there was a way to automate this by simply switching the renderer in the viewport and driving the switch node by this selection.

Gemini had me try some python but it led me pretty much nowhere and I am stuck. I don't even know if this is possible. This is not very important but would be nice. But maybe there is a much simpler way I am missing.

For reference, Gemini made me do a Python script in the HDA type properties

import hou

def get_render_delegate_index():
    scene_viewer = hou.ui.paneTabOfType(hou.paneTabType.SceneViewer)
    
    if not scene_viewer:
        return 0 

    delegate_name = scene_viewer.curViewport().settings().renderDelegateName()
    
    if "Redshift" in delegate_name:
        return 1
    elif "karma" in delegate_name.lower():
        return 0
        
    return 0

then an expression in the switch node

hou.node('..').hdaModule().get_render_delegate_index()

Cheers
User Avatar
Member
9280 posts
Joined: 7月 2007
オフライン
each renderer will use just its own settings, so you should be able to have just a single RenderSettings prim with settings for both renderers without any switching necessary
Tomas Slancik
CG Supervisor
Framestore, NY
User Avatar
スタッフ
4559 posts
Joined: 7月 2005
オフライン
The reason that python code won't work is that there is no dependency set up. It may work once, but when you change renderers, there is nothing to notify the Switch LOP that it needs to recook.

There is an outstanding RFE for allowing a python script to run when switching delegates. This mechanism could be used to drive a global context option value, and you could switch based on the context option value. Not sure if/when this RFE will be implemented, but this is the most likely path forward on this request (assuming it's not just a matter of different render settings as suggested by @tamte).
  • Quick Links