Jump to content

rsl arrays from multiparm list


rutra

Recommended Posts

Hi,

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

a

Link to comment
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
Link to comment
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()+'"' )

        else:
            pass

    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"}
$texarray

// 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:)

Link to comment
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.

Cheers,

Alan

Edited by Alanw
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...