List of all Shaders
-
TwinSnakes007
- Posts: 316
- Joined: 06 Jun 2011, 14:00
List of all Shaders
Is there a way to get a list of all shaders without traversing the RenderTree port by port?
-
xsisupport
- Posts: 713
- Joined: 09 Jun 2009, 09:02
- Location: Montreal Canada
Re: List of all Shaders
Not really. Here's a Python snippet that gets all the shaders in a render tree.TwinSnakes007 wrote:Is there a way to get a list of all shaders without traversing the RenderTree port by port?
-
TwinSnakes007
- Posts: 316
- Joined: 06 Jun 2011, 14:00
Re: List of all Shaders
For a reference parameter on a shader, all shaders from all material libraries in the current scene are displayed in the picking session, whether the shader is connected to anything or not. Is that list available in the SDK?xsisupport wrote:Not really. Here's a Python snippet that gets all the shaders in a render tree.TwinSnakes007 wrote:Is there a way to get a list of all shaders without traversing the RenderTree port by port?
edit: Thanks for the script.
-
xsisupport
- Posts: 713
- Joined: 09 Jun 2009, 09:02
- Location: Montreal Canada
Re: List of all Shaders
Can you give me an example of a reference parameter?TwinSnakes007 wrote:For a reference parameter on a shader, all shaders from all material libraries in the current scene are displayed in the picking session, whether the shader is connected to anything or not. Is that list available in the SDK?xsisupport wrote:Not really. Here's a Python snippet that gets all the shaders in a render tree.TwinSnakes007 wrote:Is there a way to get a list of all shaders without traversing the RenderTree port by port?
edit: Thanks for the script.
-
TwinSnakes007
- Posts: 316
- Joined: 06 Jun 2011, 14:00
Re: List of all Shaders
Steve,
When you set the filter attribute for a shader param:
and then set it's type to siShaderDataTypeReference:
In the PPG for that shader, you'll get a "Pick" button next to the connect icon for that parameter.
When you set the filter attribute for a shader param:
Code: Select all
paramOptions.SetAttribute( constants.siReferenceFilterAttribute, constants.siShaderReferenceFilter )Code: Select all
params.AddParamDef( "bsdf", constants.siShaderDataTypeReference, paramOptions )-
xsisupport
- Posts: 713
- Joined: 09 Jun 2009, 09:02
- Location: Montreal Canada
Re: List of all Shaders
Ah well, I was hoping to save some time by looking at an existing shader to see the behavior you described.
Code: Select all
from sipyutils import si # win32com.client.Dispatch('XSI.Application')
from sipyutils import C # win32com.client.constants
si=si()
sClassID = "{6495C5C1-FD18-474E-9703-AEA66631F7A7}"
x = si.FindObjects( "", sClassID )
-
TwinSnakes007
- Posts: 316
- Joined: 06 Jun 2011, 14:00
Re: List of all Shaders
Steve,
I'm running to a meeting, but I thought about going the ClassID route too, but I have 30-50 custom shader def's. Wouldnt that mean I'd have to look for each one of them in a separate call?
P.S. I dont know of an existing SI shader, but you can load my shaderdefs here and look at one of them to see how the reference parameter behaves:
https://www.mitsuba-renderer.org/hg/mit ... Shaders.py
I'm running to a meeting, but I thought about going the ClassID route too, but I have 30-50 custom shader def's. Wouldnt that mean I'd have to look for each one of them in a separate call?
P.S. I dont know of an existing SI shader, but you can load my shaderdefs here and look at one of them to see how the reference parameter behaves:
https://www.mitsuba-renderer.org/hg/mit ... Shaders.py
-
xsisupport
- Posts: 713
- Joined: 09 Jun 2009, 09:02
- Location: Montreal Canada
Re: List of all Shaders
TwinSnakes007 wrote:Steve,
I'm running to a meeting, but I thought about going the ClassID route too, but I have 30-50 custom shader def's. Wouldnt that mean I'd have to look for each one of them in a separate call?
P.S. I dont know of an existing SI shader, but you can load my shaderdefs here and look at one of them to see how the reference parameter behaves:
https://www.mitsuba-renderer.org/hg/mit ... Shaders.py
Code: Select all
from sipyutils import si # win32com.client.Dispatch('XSI.Application')
si=si()
sClassID = "{6495C5C1-FD18-474E-9703-AEA66631F7A7}"
shaders = si.FindObjects( "", sClassID )
#
# If your shaderdefs had a common prefix, you could
# filter the XSICollection returend by FindObjects
#
#shaders.Filter( "", "", "MTS*")
#
# Using the shaderdef category:
#
def f(x):
return x.ShaderDef.Category == "Mitsuba/bsdf"
# Get list of shaderdefs x that match the filter f(x)
defs = [x for x in filter( f, shaders ) ]
-
TwinSnakes007
- Posts: 316
- Joined: 06 Jun 2011, 14:00
Re: List of all Shaders
Thanks for the tip Steve...looking thru the sdk docs, there was an example there the whole time for FindObjects
Code: Select all
# Enumerate all shaders under the scene root.
from win32com.client import constants as c
shaders = Application.ActiveSceneRoot.FindObjects( c.siShaderID )
for s in shaders:
LogMessage( s.ProgID )
# INFO : Softimage.soft_light.1.0-
xsisupport
- Posts: 713
- Joined: 09 Jun 2009, 09:02
- Location: Montreal Canada
Re: List of all Shaders
There's also Material.GetAllShaders, which I overlooked
-
TwinSnakes007
- Posts: 316
- Joined: 06 Jun 2011, 14:00
Re: List of all Shaders
Here's what I ended up with:
Code: Select all
from sipyutils import log
app = Application
oMatLib = app.ActiveProject.ActiveScene.MaterialLibraries
for oLib in oMatLib :
log (oLib.Name)
for oMaterial in oLib.Items :
log (oMaterial.Name)
oShaders = oMaterial.GetAllShaders()
for oShader in oShaders:
log (oShader.Name)