access texturemap from VRayDirt

Hi I have a problem for getting texturmap from vraydirt that already inside some object.if i using $.material.diffusemap.vraydirt.texmap_occluded_color.bitmaptexture.filename
it result error Unknown property: "texmap_occluded_color" in .
I would be realy greatfull if someone could help me to solve this problem since i have so many material i have to change.

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
senisleft's picture

Nice one, It works thanks a

Nice one, It works thanks a lot guys its save my time :D

Budi G's picture

My pleasure :)

My pleasure :)

barigazy's picture

"collect all DIRT maps from selected objects"

Ok.
In order to collect all VRayDirt Maps on the scene we can use

getClassInstances VRayDirt

But that is easy. Now answer for the post title :

--collect all DIRT maps from selected objects FN
fn getDirtOf objMtl &inTrashCan =
(
	for m in (refs.dependsOn objMtl) do
	(
		case (superclassof m) of
		(
			material: getDirtOf m &inTrashCan
			textureMap: if isKindOf m VRayDirt and (for t in inTrashCan where t.name == m.name collect m).count == 0 do append inTrashCan m
		)
	)
)
 
-- Select some objects and run next
dirtMaps = #() -- here we collect all dirt :)
for obj in selection where obj.material != null do getDirt obj.material &dirtMaps
dirtMaps -- result
 
-- Now when the trash can is full we can do whatever we want
for dm in dirtMaps do
(
	format "vrDirt Name : %\n" dm.name
	format "\tObjects : %\n" (for n in (refs.dependentNodes dm) collect n.name)
	for p in getPropNames dm where isKindOf (gp = getProperty dm p) textureMap do
		format ("\t" + toUpper (p as string) + " : %\n") gp
-- etc.
)

Hope this is not too difficult to understand

;) Cheers!

barigazy

Budi G's picture

Branko run your script , got

Branko
run your script , got an error ...

you wrote :

for obj in selection where obj.material != null do getDirt obj.material &dirtMaps

- What is the value of 'null' ?
- You don't have getDirt() function, probably mean is getDirtOf() , is it right ?

barigazy's picture

...

Yup getDirtOf(). I changed name of fn but forgot to change in for-loop.
null is undefined variable. U can put any word or simple use predefined 'undefined'

fn getDirtOf objMtl &inTrashCan =
(
	for m in (refs.dependsOn objMtl) do
	(
		case (superclassof m) of
		(
			material: getDirtOf m &inTrashCan
			textureMap: if isKindOf m VRayDirt and (for t in inTrashCan where t.name == m.name collect m).count == 0 do append inTrashCan m
		)
	)
)
-- now select some objects and run next
dirtMaps = #()
for o in selection where o.material != undefined do getDirtOf o.material &dirtMaps
dirtMaps
for dm in dirtMaps do
(
	format "vrDirt Name : %\n" dm.name
	format "\tObjects : %\n" (for n in (refs.dependentNodes dm) collect n.name)
	for p in getPropNames dm where isKindOf (gp = getProperty dm p) textureMap do
		format ("\t" + toUpper (p as string) + " : %\n") gp
)

barigazy

Budi G's picture

ok, now a script

ok, now a script works,...sound good.

hmm in this case you just collect the vray dirt map, not the filename as he need.
such as:
format ("\t" + toUpper (p as string) + " : %\n") gp.filename

and it will be better to need more filters because the vray dirt map can apply to standard material or multi material.

btw about standard material, is a different method than vray material if we use this methods.

barigazy's picture

...

This supports any type of material. And I placed "--etc." at the end, so you can add below that anything even to look for filenames. Also in some cases users not use only bitmap textures but other procedural maps.
The main problem is to collect VRayDirt maps from selected objects materials and after that everything is easy. :)
Now next step is to collect all bitmap textures which are directly asigned to VRayDirt maps slot, or indirecty (combined with procedurals)
Now is your turn, Budi :)

barigazy

barigazy's picture

...

The next solution can be related not only to VRayDirt map but any other map type.
As U see I used *superclasses not *classes that why I not needed more filters
Best way is to use RECURSIVE FN.
I already posted a solution how to collect all nested bitmaps on this forum

barigazy

Budi G's picture

Get all Vray Dirt Maps Filename

Yup, Recursive functions can be faster.

(--start
    fn GrabAllMaps mat arr = 
	(
		if mat.numsubs != 0 then (
			for i = 1 to mat.numsubs do (
				if mat[i] != undefined then (
					if classof mat[i] == SubAnim then (
						if superclassof mat[i].object == textureMap then (
							if mat[i].object != undefined then append arr mat[i].object
						)
					)
				GrabAllMaps mat[i] arr
				)
			)
		)
	) -- This function taken from BlurScripts by Neil Blevins, I found in ColinScripts a few years ago. ( Thanks for Them )
  -----------------------------------------------------------------------------------------------------------
  fn GrabVdirtMaps mat =
  (
     if mat != undefined then 
	 (
        local AllMaps=#(), VrayDirtMapFile=#(), x,p
	    GrabAllMaps mat AllMaps 
		for x=1 to AllMaps.count where (classof AllMaps[x])==VRayDirt do
		(
		  for p in (getPropNames AllMaps[x]) where superclassof (prop = getProperty AllMaps[x] p) == textureMap do append VrayDirtMapFile prop.filename
		)
	   VrayDirtMapFile
     )
   )
   --------------------------------------------------------------------- execute as example
   for obj in selection do print (GrabVdirtMaps obj.material)
)--end
barigazy's picture

...

Yup. Thats the one. I used this fn a couple of times but when the scene is complex (with many textures) then is also very slow.
We can optimize this a bit more but requester not asked for more. So... :)
Regards!

barigazy

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.