PDA

View Full Version : material types from renderer


Alex Morris
02-11-2008, 02:32 PM
Is it possible to get a list of the material types from installed renderers via maxscript?
You can see them in the material editor/map browser, and when they're in the scene already, test them for compatabilty for a given renderer.
What I'm looking to do is automate listing out the materials associated with scanline, MR, VRay, FinalRender etc to generate an interface, so that when updates appear i don't have to completely rewrite and check the list again :)

ypuech
02-11-2008, 02:48 PM
Hi Alex,

Maybe you've already done that but have you looked at areMtlAndRendererCompatible() function.

Alex Morris
02-11-2008, 03:12 PM
Hi Yannick,

Yes I looked at that and I need to do that later in the process, but first I need the list of materials to check from all those available to max.
Just running FinalRender and Vray gives a total of 59 materials to check (about 20 of which were new in the latest version of each renderer).
Right now I'm just looking in the browser, loading them up and taking a note of properties in the listener, then creating a huge array! There must be a better way of doing this ....hehe!

Thanks

Kramsurfer
02-14-2008, 12:32 AM
This is a simplified version of what I've done for something similar... Its builds a array of the Structure RendererAndMats. You'll see some of the Materials are not constructible in MaxScript, so they drop out with the try()catch()


(
struct RendererAndMats ( Renderer , Materials )

local RenderMatArray = #()

local tnMatClasses = material.classes

for ChkRenderer in RendererClass.classes do
(
append RenderMatArray ( RendererAndMats Renderer:(ChkRenderer as string) Materials:#() )
for ChkMat in tnMatClasses do
if ( areMtlAndRendererCompatible ChkMat renderer:ChkRenderer ) then
append RenderMatArray[ RenderMatArray.count ].Materials ChkMat
)
for RendNMat in RenderMatArray do
(
format "% [%]: % \n" RendNMat.Renderer RendNMat.Materials.count RendNMat.Materials
)

)


Hope this helps...

Alex Morris
02-14-2008, 09:33 AM
Thanks Keith,

That is so elegant compared to how I was approaching it. What I was missing was knowledge of the .classes queries.

Alex

Alex Morris
02-14-2008, 10:09 AM
Hi Keith,

I have one question......on the line:

append RenderMatArray[ RenderMatArray.count ].Materials tnMaterial


how does it know which index to put the materials into? Doesn't the count always remain the total for the array as a whole? It obviously works ok - just trying to understand what's going on.

Alex

Alex Morris
02-14-2008, 10:25 AM
Ah got it now........

because we're building the array as we go along the count increases by one each time we append an entry..........doh!

Alex

CGTalk Moderation
02-14-2008, 10:25 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.