Jump to content

rsl arrays from multiparm list

Recommended Posts


I'm trying to build RSL VOP texture layering node using Multiparm Block list.

RSL array looks something like this:

string texture_array[] = { "texture_a.tif", "texture_b.tif", "texture_c.tif" };

How can I get Multiparm Block number and values propagated into my SL code?

Thanks in advance


Share this post

Link to post
Share on other sites

Alternatively I tried to use Texture node in 'For Loop' node but I couldn't figure out how to use loop count index to change the channel name inside 'For Loop' node in order to feed next texture path to the Texture node.

Edited by rutra

Share this post

Link to post
Share on other sites

Ok, I've got seriously dodgy way of doing it. Basically Python script dynamically generates SL arrays. The only problem is that I often have to refresh the script.

Muliparm texture parameter Python CallBack script

print hou.pwd().hdaModule().refresh(kwargs)

..runs following script:

def refresh( kwargs ):
    this_node = kwargs['node']
    num_layers = this_node.parm('layers').eval()
    prefix = 'texturepath'
    parms = this_node.parms()

    texture_paths = []
    for p in this_node.parms():
        parm_name = p.name()
        if parm_name.startswith(prefix):
            texture_paths.append( '"'+p.eval()+'"' )


    code_string = ''
    code_string += 'string Kd_texture_array[] = {'
    code_string += ','.join( texture_paths )
    code_string += '};'

    this_node.parm('texarray').set( code_string )

    return code_string

SL code looks like this:

// generate Kd_texture_array sting array from Multiparm Block list via Python callback script
// looks like this: string Kd_texture_array[] = {"texture1.tdl, texture2.tdl"}

// Get total number of textures in array
uniform float $numLayers = arraylength( Kd_texture_array );

uniform float $i;
string $Kd_texture = "";

for( $i = $numLayers ; $i >= 0; $i -= 1 )
    $Kd_texture = Kd_texture_array[$i];
    $outColor += texture($Kd_texture);

Hopefully someone has better ideas:)

Share this post

Link to post
Share on other sites

I was thinking co-shaders could be helpful for this task. You could construct a shader that would accept multiple co-shaders with each having their own texture and blending modes.

In Houdini you might have the multi-parm block call-back copy a co-shader living inside your HDA & wire it up into a co-shader merge SHOP.

Naturally this could fail easily. It's hard to know without getting my hands dirty. I'm not sure if you're using prman either.



Edited by Alanw

Share this post

Link to post
Share on other sites

Interesting idea but I'm actually trying to build Texture layering node for VOP network (VEX Builder Type). Not sure if co-shaders would work.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now