Announcements

Announcement: We’re aware of an issue affecting starting a new topic from category pages and creating new blog posts. New topics can still be started directly from the relevant board. Learn more here.

Adding shaders to the IPR for Arnold in Blender

Adding shaders to the IPR for Arnold in Blender

Anonymous
Not applicable
1,232 Views
5 Replies
Message 1 of 6

Adding shaders to the IPR for Arnold in Blender

Anonymous
Not applicable

Trying to get an IPR working in blender, I'm able to get the polymesh to show up, how would I go about adding the shaders? Here's what I have so far:

nodes.append(('polymesh', {  
	'name': ('STRING', "O::" + ob.name)  
	'matrix': ('MATRIX', numpy.reshape(ob.matrix_world.transposed(), -1)),  
	'vlist': ('ARRAY', (arnold.AI_TYPE_VECTOR, vlist)),  
	'nsides': ('ARRAY', (arnold.AI_TYPE_UINT, nsides)),  
	'vidxs': ('ARRAY', (arnold.AI_TYPE_UINT, vidxs)),  
}))
0 Likes
Accepted solutions (1)
1,233 Views
5 Replies
Replies (5)
Message 2 of 6

Stephen.Blair
Community Manager
Community Manager

You need to create a shader node, and then set (link?) polymesh.shader



// Stephen Blair
// Arnold Renderer Support
0 Likes
Message 3 of 6

Anonymous
Not applicable

@Stephen Blair Like this?

'shader':('POINTER', (arnold.AI_TYPE_POINTER, shader))
0 Likes
Message 4 of 6

Anonymous
Not applicable
shader.append(('lambert', {  
  'name': ('STRING', mat.name),  
  'Kd': ('FLOAT', (mat.diffuse_intensity)),  
  'Kd_color': ('RGB', (arnold.AI_TYPE_RGB, *mat.diffuse_color))  
}))
0 Likes
Message 5 of 6

Anonymous
Not applicable

And you’d append that shader data to the shader array with the above code? ^

0 Likes
Message 6 of 6

Anonymous
Not applicable
Accepted solution

Figured it out, not perfect though:

    index = index_containing_substring(nodes, ob.name)
    nodes.append(('polymesh', {
        'name': ('STRING', "O::" + ob.name),
        'matrix': ('MATRIX', numpy.reshape(ob.matrix_world.transposed(), -1)),
         'vlist': ('ARRAY', (arnold.AI_TYPE_VECTOR, vlist)),
         'nsides': ('ARRAY', (arnold.AI_TYPE_UINT, nsides)),
         'vidxs': ('ARRAY', (arnold.AI_TYPE_UINT, vidxs)),
         'shader':('NODE', (nodes[index])),
         #'smoothing': ('BOOL', True),
    }))
0 Likes