PDA

View Full Version : Querying a material type, i.e Composite, Standard, Blend etc


EverZen
02-11-2005, 12:09 PM
Hi guys,

I am sure this is obvious, but I am really struggling over what must be one line of code. I am writing a tool that cycles through all materials in the scene (using the scenematerials command) and changes the sampling type, quality for each material. I can do this if the material is a blend, or a composite or a standard. But I cannot find a way of checking what type the "i"th material in the scence is. I.e is it a composite, blend etc.

if you use getMeditMaterial[Slot Number], then it will return the name of the material, followed by a colon and then the type.

I.e TableWoood:Composite

All I need is to check whether it is a composite or not, I dont care about the name. Once I have the type, I can apply one of the functions I have written, and then I can easily build an interface, so you can change the type and quality of sampling of all your scene textures at once, at a touch of a button/slider.

People are welcome to the script, if I can get it finished :) So enlightenment for this pesky little line would be really really appreciated.

Thanks guys :)

EverZen

prettyPixel
02-11-2005, 02:23 PM
I believe that this could work:

if isKindOf $.material Standardmaterial then
(
if isKindOf $.material.diffuseMap compositeTexture
then print("composite==true")
else print("composite==false")
)

have a good day

Bobo
02-11-2005, 05:05 PM
The shortest way known to mankind:


for m in scenematerials where classof m == compositeMaterial do
--your code here...

erilaz
03-18-2005, 12:12 AM
It's a good thing I search! Was just about to ask the same question!

EverZen
03-18-2005, 09:37 AM
Pretty pixel: Cheers man, used a very close adaption of that little block of code to check different materials in my scene. Very useful!

Bobo: Thanks man, that is the line I have used for the overall scene analysis. Incredibly eloquent as always :)

prettyPixel
03-18-2005, 02:01 PM
I think that the recursive function I have used in this thread (http://www.cgtalk.com/showthread.php?t=219556) could be useful for you (?)

EverZen
03-21-2005, 03:43 PM
Hi guys,

Thanks for help there dude, my work were really pushing me to get this out for a current project. I had taken the recursive approach, but your other thread showed me a much smoother way of writing it, which I promply borrow ;) . This was written exceedingly quickly, so I am sorry for poor annotation, I am also self taught, and still learning lots, so I am sure there is a million ways to write this better!

The tool Gives you the option of changing all the details on super sampling on all materials or any type of material. E.g Just all the composite materials in your scene. All options for all levels of sampling are included, i.e quality and threshold values in adaptive Uniform etc. The script also allow you to disable supersampling on material groups, for test rendering etc, then re activate the sampling again for the final render.

There is also per object sampling which will change all sampling on the object selected, works for standard materials, blends, multi materials, and composites.

I have uploaded it here as a .txt file, since I didnt know a better way of doing it.

Anyone feel free to grab this and have a play, hope it helps :) Feedbackl always welcome!

Take care everyone,

Everzen

CGTalk Moderation
03-21-2005, 03:43 PM
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.