Simple Reflection Map creator (diffuse to reflection copy...)

Hello, i would appreciate the script that does the following:

It operates on objects selected in viewport (or all objects; it doesnt matter really probably) which have Vray materials or on MultiSubObjects materials filled with Vray materials assigned.

It:

1) Crates a composite map type and insert it in the Reflection slot of the Vray material.
2) Crate a Color correction map in (under) the layer of the Composite map type
3)Set the saturation of Color Correction map to -100,0
4) Copy the map (bitmap) from diffuse slot of Vray material to the Reflection--> Composite-->Color correction map slot of the vray material.
5) Crate additional layer in the composite map type above the collor correction one. To this additional layer place VrayColor map type with absolute black color (RGB 0,0,0) and set the opacity of this new layer to 50 (blending type to normal).

Im using 3ds max 2009 64 but with V-RaY 1.5 sP4.

The goal is to speed up creating simple reflection maps from the diffuse ones inside 3ds max.

Comments

Comment viewing options

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

Great :-)

Wow great, it works nicely, thanks :-), even the multiplayer works fine for the opacity setting in the layer in composite, nice!

barigazy's picture

:)

Ok. Enjoy!

barigazy

roamn's picture

Tried it, worked :-)

So i have tried it, it works, thanks :-)

Could you please also make the solution with the composite map, allowing a better and immidiate preview of how it will look like/how much will it shine?

I made a picture of what i mean

http://s14.postimg.org/k9e2z921d/See.jpg

barigazy's picture

...

Give me 5-10 minutes :)

barigazy

barigazy's picture

...

Jist kidding. I needed only 2min
Here we go

try(destroyDialog ::dtrRoll)catch()
rollout dtrRoll "Diffuse To Reflection"
(
	label lbl "Process on:" pos:[10,10]
	radiobuttons rb labels:#("Selected Objects", "Scene Materials", "Material Editor Mtl's") pos:[8,25] --width:NM height:NM
	spinner spn "Opacity Multiplier:" range:[0,100,50] fieldwidth:30 pos:[10,75] type:#integer
	button btn "Do The Job!" pos:[8,95] width:124
	fn ProcessMaterial m =
	(
		if isKindOf m VRayMtl then 
		(
			if m.texmap_diffuse != null do
			(	
				local ccMap = Color_Correction  name:("CC_"+m.name) map:(copy m.texmap_diffuse) rewireMode:1
				local vcMap = VRayColor name:("vrCol_"+m.name) color:black rgb_multiplier:1 alpha:1 gamma_correction:0 gamma_value:2.2
				m.texmap_reflection = CompositeTexturemap mapList:#(ccMap,vcMap) layerName:#("ccMap", "vrCol") blendMode:#(0,0) opacity:#(100,spn.value)
			)
		)
		else if isKindOf m VRay2SidedMtl then (ProcessMaterial m.frontmtl ; ProcessMaterial m.backmtl)
		else if isKindOf m SHELLAC then (ProcessMaterial m.shellacMtl1 ; ProcessMaterial m.shellacMtl2)
		else if  isKindOf m VrayMtlWrapper then (ProcessMaterial  m.baseMtl)
		else if isKindOf m VRayBlendMtl then (ProcessMaterial m.baseMtl ; for i = 1 to 9 do ProcessMaterial m.coatMtl[i])
		else if isKindOf m VrayOverrideMtl then (for i in 1 to getNumSubMtls m do ProcessMaterial (getSubMtl vr i))
		else if (isKindOf m Multimaterial or isKindOf m compositematerial) then (for sm in m.materialList where isKindOf sm material do ProcessMaterial sm)
		else if isKindOf m blend then (ProcessMaterial m.MAP1 ; ProcessMaterial  m.MAP2)
		else if isKindOf m topbottom then (ProcessMaterial m.topmaterial ; ProcessMaterial m.bottomMaterial)
		else if isKindOf m shell_material then (ProcessMaterial m.originalMaterial ; ProcessMaterial m.bakedMaterial)
	)
	on btn pressed do
	(
		with undo off with redraw off
		(
			case rb.state of 
			(
				1: for m in scenematerials do ProcessMaterial m
				2: for o = 1 to selection.count where selection[o].material != null do ProcessMaterial selection[o].material
				3: for n in meditMaterials do ProcessMaterial n
			)
		)
	)
)
createDialog dtrRoll 140 120 10 110 style:#(#style_titlebar, #style_sysmenu, #style_toolwindow)

barigazy

roamn's picture

Hello

Thank you for your script, that was fast :-)!

3.Set reflection multiplier to 50 %.

Yeah i thought about that, but the problem with this one is you dont have immidiate visual reference of how it will look like e.g. ho much intense the the reflection is.

If you use the solution with composite map you have immidiate visual reference of how much will each pixel reflect in the end, and within few seconds, using additional work (using the Vray frame + buffer) you can get even the exact RGB code of each pixel (how much it will shine) and you can regulate this within the composite map and see the result immidiatelly. Thats why i wrote it in the first place.

Would you be so kind please and try to implement it in the script? (or is it some other way how can i get immidiate visual reference of how the reflection map will look like (how much brigher or darker it will be?)

Neverthless thank you :-)!

barigazy's picture

...

Better idea is:
1. Create color correction map in reflection slot and set it chennels type to monochrome
2. Copy map from diffuse slot to CC map of refl. slot
3.Set reflection multiplier to 50 %.

NOTE: You can specify to process to Scene Material, Selected Object Material and Medit Materials.

Supports material classes like:
VRay2SidedMtl, SHELLAC, VrayMtlWrapper, VRayBlendMtl,VrayOverrideMtl, Multimaterial, compositematerial,blend, topbottom, shell_material

One more thing (this works with vray 2+).
If one on above classes are not supported with your version of vray then just remove line in "Processmaterial" function.

Here is my concept

try(destroyDialog ::dtrRoll)catch()
rollout dtrRoll "Diffuse To Reflection"
(
	local VAR
	label lbl "Process on:" pos:[10,10]
	radiobuttons rb labels:#("Selected Objects", "Scene Materials", "Material Editor Mtl's") pos:[8,25] --width:NM height:NM
	spinner spn "Refl. Multiplier:" range:[0,100,50] fieldwidth:30 pos:[10,75] type:#integer
	button btn "Do The Job!" pos:[8,95] width:124
	fn ProcessMaterial m =
	(
		if isKindOf m VRayMtl then 
		(
			if m.texmap_diffuse != null do
			(
				m.texmap_reflection = Color_Correction map:(copy m.texmap_diffuse) rewireMode:1
				m.texmap_reflection_multiplier = spn.value
			)
		)
		else if isKindOf m VRay2SidedMtl then (ProcessMaterial m.frontmtl ; ProcessMaterial m.backmtl)
		else if isKindOf m SHELLAC then (ProcessMaterial m.shellacMtl1 ; ProcessMaterial m.shellacMtl2)
		else if  isKindOf m VrayMtlWrapper then (ProcessMaterial  m.baseMtl)
		else if isKindOf m VRayBlendMtl then (ProcessMaterial m.baseMtl ; for i = 1 to 9 do ProcessMaterial m.coatMtl[i])
		else if isKindOf m VrayOverrideMtl then (for i in 1 to getNumSubMtls m do ProcessMaterial (getSubMtl vr i))
		else if (isKindOf m Multimaterial or isKindOf m compositematerial) then (for sm in m.materialList where isKindOf sm material do ProcessMaterial sm)
		else if isKindOf m blend then (ProcessMaterial m.MAP1 ; ProcessMaterial  m.MAP2)
		else if isKindOf m topbottom then (ProcessMaterial m.topmaterial ; ProcessMaterial m.bottomMaterial)
		else if isKindOf m shell_material then (ProcessMaterial m.originalMaterial ; ProcessMaterial m.bakedMaterial)
	)
	on btn pressed do
	(
		with undo off with redraw off
		(
			case rb.state of 
			(
				1: for m in scenematerials do ProcessMaterial m
				2: for o = 1 to selection.count where selection[o].material != null do ProcessMaterial selection[o].material
				3: for n in meditMaterials do ProcessMaterial n
			)
		)
	)
)
createDialog dtrRoll 140 120 10 110 style:#(#style_titlebar, #style_sysmenu, #style_toolwindow)

barigazy

Comment viewing options

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