[Closed] MentalRay compositing set up
hey people, I want to create a simple script to set up a photo/3d compositing using the matte/shadow/reflection, chrome ball,background swither and camera mpa materials.
I have started with the materials but I fail to put them in the right channels.
any help?
matte_shad= Matte_Shadow_Reflection__mi ()
chromeball=Environment_Probe_Chrome_Ball__mi ()
bg_switcher= Environment_Background_Switcher__mi ()
bg_camera=Environment_Background_Camera_Map__mi ()meditMaterials[1] = matte_shad
meditMaterials[1].name = “the matte_shad”
meditMaterials[2] = chromeball
meditMaterials[2].name = “the chromeball”
meditMaterials[3] = bg_camera
meditMaterials[3].name = “the bg_camera”
meditMaterials[4] = bg_switcher
meditMaterials[4].name = “the bg_switcher”bg_switcher.environment.shader = chromeball <– this doens’t work!
bg_switcher.background.shader = bg_camera <– this doens’t work!
matte_shad.background.shader = bg_camera <– this doens’t work!
Try replacing the last “.” by a “_” instead:
bg_switcher.environment_shader = chromeball
bg_switcher.background_shader = bg_camera
matte_shad.background_shader = bg_camera
showproperties bg_switcher returns this:
Environment_Background_Switcher__mi:Environment/Background Switcher
.background : fRGBA color
.environment : fRGBA color
.background_connected : boolean
.background_shader : texturemap
.background_paramName : string
.environment_connected : boolean
.environment_shader : texturemap
.environment_paramName : string
.TheList : maxObject array
.Shader_Version : integer
“matte/shadow/reflection, chrome ball,background swither and camera mpa”
I think you need to look for a new name for that tool, it is a little long winded;)
Thank you people!
works fine
Now I want to use a buttonmap to pick the background picture and the chromeball picture.
this can not be a bitmap Map file but directly the jpg files.
So my first attempt fail…
Any help again?
rollout MR_rollout “MentalRay compositing”
(
label sbm_lbl “Background Map:”
mapbutton choosemap “<<none>>” tooltip:“Select Background Map” width:120
on choosemap picked texmapenv do
(
– environmentmap = texmapenv
choosemap.text=classof texmapenv as string
meditMaterials[7] = texmapenv
)
label sbm_lbl2 “Chromeball Map:”
mapbutton choosemap2 “<<none>>” tooltip:“Select Chromeball Map” width:120label sbm_lbl3 “APPLY SETUP:”
button bt ” ON COMPOSITE ” width:120
on bt pressed do(–MENTAL RAY RENDERER–
mr =mental_ray_Renderer()
renderers.current = mr
mr.FinalGatherBounces =3
mr.FinalGatherDensity = 3
mr.FinalGatherAccuracy = 300–EXPOSURE SETTINGS–
SceneExposureControl.exposureControl = mr_Photographic_Exposure_Control()–MATERIALS–
matte_shad= Matte_Shadow_Reflection__mi ()
chromeball=Environment_Probe_Chrome_Ball__mi ()
bg_switcher= Environment_Background_Switcher__mi ()
bg_camera=Environment_Background_Camera_Map__mi ()meditMaterials[1] = matte_shad
meditMaterials[1].name = “the matte_shad”
meditMaterials[2] = chromeball
meditMaterials[2].name = “the chromeball”
meditMaterials[3] = bg_camera
meditMaterials[3].name = “the bg_camera”
meditMaterials[4] = bg_switcher
meditMaterials[4].name = “the bg_switcher”bg_camera.map = texmapenv.mapfile
bg_switcher.environment_shader = chromeball
bg_switcher.background_shader = bg_camera
matte_shad.background_shader = bg_camera
chromeball.multiplier = 1.5
chromeball.degamma = 2.2
environmentMap = bg_switcher
SceneExposureControl.exposureControl.exposure_value = 0
IDisplayGamma.colorCorrectionMode = #gamma –enable Gamma
IDisplayGamma.gamma = 2.2)
button bt2 ” ON ALPHA MASK ” width:120
label bar2 “______________________________________” offset:[0,0] align:#center
hyperlink hl “:::::::: L o R a n ::::::::” address:“ http://laurent.renaud.free.fr/ ” offset:[0,20] align:#center
)–end
createDialog MR_rollout 250
Hey Loran, instead of using a map button, try using a normal button and use this to select the JPG file (inside the button pressed event):
frmOpenFileDialog = dotNetObject "System.Windows.Forms.OpenFileDialog"
frmOpenFileDialog.Filter = "JPEG files (*.jpg)|*.jpg|All files (*.*)|*.*"
dlgResult = dotNetClass "System.Windows.Forms.DialogResult"
if frmOpenFileDialog.ShowDialog() == dlgResult.OK do (
print frmOpenFileDialog.Filename
)
As you can see, when the user selects the file, it’s returned in the .Filename property of the Dialog, so after this you just have to feed this into the slot you want (environment, chromeball, whatever)
If you want, you can add more file extensions using the .Filter property.
Hope this helps!
thank you for help but I can’t make it work
I don’t understand where to put your syntax
How about now? I dont know if this is what you want but I gave it a shot!
rollout MR_rollout "MentalRay compositing"
(
label sbm_lbl "Background Map:"
button choosemap "<<none>>" tooltip:"Select Background Map" width:120
local texmapenv=bitmaptexture()
on choosemap pressed do
(
-- environmentmap = texmapenv
frmOpenFileDialog = dotNetObject "System.Windows.Forms.OpenFileDialog"
frmOpenFileDialog.Filter = "JPEG files (*.jpg)|*.jpg|All files (*.*)|*.*"
dlgResult = dotNetClass "System.Windows.Forms.DialogResult"
if frmOpenFileDialog.ShowDialog() == dlgResult.OK do (
texmapenv.filename=frmOpenFileDialog.Filename
texmapenv.name="TexMapEnv Bitmap"
)
choosemap.text=texmapenv.filename
meditMaterials[7] = texmapenv
)
label sbm_lbl2 "Chromeball Map:"
button choosemap2 "<<none>>" tooltip:"Select Chromeball Map" width:120
local chromeballenv=bitmaptexture()
on choosemap2 pressed do
(
frmOpenFileDialog = dotNetObject "System.Windows.Forms.OpenFileDialog"
frmOpenFileDialog.Filter = "JPEG files (*.jpg)|*.jpg|All files (*.*)|*.*"
dlgResult = dotNetClass "System.Windows.Forms.DialogResult"
if frmOpenFileDialog.ShowDialog() == dlgResult.OK do (
chromeballenv.filename=frmOpenFileDialog.Filename
chromeballenv.name="ChromeballEnv Bitmap"
)
choosemap2.text=chromeballenv.filename
meditMaterials[8] = chromeballenv
)
label sbm_lbl3 "APPLY SETUP:"
button bt " ON COMPOSITE " width:120
on bt pressed do(
--MENTAL RAY RENDERER--
mr =mental_ray_Renderer()
renderers.current = mr
mr.FinalGatherBounces =3
mr.FinalGatherDensity = 3
mr.FinalGatherAccuracy = 300
--EXPOSURE SETTINGS--
SceneExposureControl.exposureControl = mr_Photographic_Exposure_Control()
--MATERIALS--
matte_shad= Matte_Shadow_Reflection__mi ()
chromeball=Environment_Probe_Chrome_Ball__mi ()
bg_switcher= Environment_Background_Switcher__mi ()
bg_camera=Environment_Background_Camera_Map__mi ()
meditMaterials[1] = matte_shad
meditMaterials[1].name = "the matte_shad"
meditMaterials[2] = chromeball
meditMaterials[2].name = "the chromeball"
meditMaterials[3] = bg_camera
meditMaterials[3].name = "the bg_camera"
meditMaterials[4] = bg_switcher
meditMaterials[4].name = "the bg_switcher"
bg_camera.map = texmapenv.filename
chromeball.texture = chromeballenv.filename
bg_switcher.environment_shader = chromeball
bg_switcher.background_shader = bg_camera
matte_shad.background_shader = bg_camera
chromeball.multiplier = 1.5
chromeball.degamma = 2.2
environmentMap = bg_switcher
SceneExposureControl.exposureControl.exposure_value = 0
IDisplayGamma.colorCorrectionMode = #gamma --enable Gamma
IDisplayGamma.gamma = 2.2
)
button bt2 " ON ALPHA MASK " width:120
label bar2 "______________________________________" offset:[0,0] align:#center
hyperlink hl ":::::::: L o R a n ::::::::" address:"http://laurent.renaud.free.fr/" offset:[0,20] align:#center
)--end
createDialog MR_rollout 250
Thank you! works fine.
Do you know how can I apply the backgound picked image size to the render size?
It would be something like:
renderWidth = texmapenv.bitmap.width
renderHeight = texmapenv.bitmap.height
Keep in mind this, from the Maxscript Help:
NOTE:
Changing the render scene dialog settings via MAXScript should be done with the actual render scene dialog in a closed state.
Leaving the dialog open will make the attempted MAXScript modifications non-sticky.
Cheerios!
Here we go !!
Thank you So much Artur
> download the script
– This script intend to simplify the compositing setup with MentalRay
– Thank you to artur leão ( http://dimensao3.com/al/ ) for his great help in coding !rollout MR_rollout “:: C O M P O S I T T H I S ::”
(
–GUI
group “”
(
label h1 “This script create a MentalRay”
label h2 ” compositing setup in 3 clicks”
label h3 ” ***”
)
group “Environment Pictures”
(label sbm_lbl "Background Map: ChromeBall Map:" button choosemap "<<none>>" tooltip:"Select Background Map" width:90 offset:[-45,0] button choosemap2 "<<none>>" tooltip:"Select Chromeball Map" width:90 offset:[52,-26] ) label sbm_lbl3 "APPLY COMPOSITING SETUP:"
– checkbox myCheckBox “Create Test Objects” checked:true
button bt ” DO IT ! ” width:200 height: 50
button bt2 “Create Test Objects” width:200 height: 20–ACTION
local texmapenv=bitmaptexture()
local chromeballenv=bitmaptexture()
on choosemap pressed do
(frmOpenFileDialog = dotNetObject "System.Windows.Forms.OpenFileDialog" frmOpenFileDialog.Filter = "JPEG files (*.jpg)|*.jpg|All files (*.*)|*.*" dlgResult = dotNetClass "System.Windows.Forms.DialogResult" if frmOpenFileDialog.ShowDialog() == dlgResult.OK do ( texmapenv.filename=frmOpenFileDialog.Filename texmapenv.name="TexMapEnv Bitmap" ) choosemap.text= ":: OK ::" --meditMaterials[7] = texmapenv )
– local chromeballenv=bitmaptexture()
on choosemap2 pressed do
(
frmOpenFileDialog = dotNetObject “System.Windows.Forms.OpenFileDialog”
frmOpenFileDialog.Filter = “JPEG files (.jpg)|.jpg|All files (.)|.”dlgResult = dotNetClass "System.Windows.Forms.DialogResult" if frmOpenFileDialog.ShowDialog() == dlgResult.OK do ( chromeballenv.filename=frmOpenFileDialog.Filename chromeballenv.name="ChromeballEnv Bitmap" ) choosemap2.text=":: OK ::" --meditMaterials[8] = chromeballenv )
on bt pressed do
(
–MENTAL RAY RENDERER–
mr =mental_ray_Renderer()
renderers.current = mr
mr.FinalGatherBounces =3
mr.FinalGatherDensity = 3
mr.FinalGatherAccuracy = 300
renderWidth = texmapenv.bitmap.width
renderHeight = texmapenv.bitmap.height
–EXPOSURE SETTINGS–
SceneExposureControl.exposureControl = mr_Photographic_Exposure_Control()
SceneExposureControl.exposureControl.exposure_value = 0
SceneExposureControl.exposureControl.film_isoUI = 100
SceneExposureControl.exposureControl.f_stop = 8
SceneExposureControl.exposureControl.shutter_speed = 0.015625
SceneExposureControl.exposureControl.processBG = true--MATERIALS-- matte_shad= Matte_Shadow_Reflection__mi () chromeball=Environment_Probe_Chrome_Ball__mi () bg_switcher= Environment_Background_Switcher__mi () bg_camera=Environment_Background_Camera_Map__mi () meditMaterials[1] = matte_shad meditMaterials[1].name = "the matte_shad" --meditMaterials[2] = chromeball --meditMaterials[2].name = "the chromeball" --meditMaterials[3] = bg_camera --meditMaterials[3].name = "the bg_camera" --meditMaterials[4] = bg_switcher --meditMaterials[4].name = "the bg_switcher" bg_camera.map = texmapenv.filename chromeball.texture = chromeballenv.filename bg_switcher.environment_shader = chromeball bg_switcher.background_shader = bg_camera matte_shad.background_shader = bg_camera chromeball.multiplier = 1.5 chromeball.degamma = 2.2 bg_camera.degamma = 2.2 environmentMap = bg_switcher SceneExposureControl.exposureControl.exposure_value = 0 IDisplayGamma.colorCorrectionMode = #gamma --enable Gamma IDisplayGamma.gamma = 2.2 mysky = Skylight pos:[-100,100,0] mysky.sky_mode = 0 --background
bgNewImage = openBitmap texmapenv.filename
setAsBackground bgNewImage
viewport.DispBkgImage = true
completeRedraw()actionMan.executeAction 0 "40182" -- Views: Perspective User View actionMan.executeAction 0 "219" -- Tools: Show Safeframes Toggle
)
on bt2 pressed do (
–CREATE OBJECTS –
myfloor= Plane width: 50 Length: 50
myfloor.name=“Test Plane”
myfloor.wireColor = [50,150,255]mysphere= Sphere radius:5 pos:[0,0,5]
mysphere.name=“Test Sphere”
mysphere.wireColor = [50,150,255]–CHROME MATERIAL
spheremat= Arch___Design__mi()
spheremat.diff_color = color 100 100 100
spheremat.refl_weight = 1
spheremat.refl_metal = on
spheremat.refr_ior = 25
spheremat.refl_func_fresnel = onmysphere.material = spheremat
myfloor.material = meditMaterials[1])
label bar2 "______________________________________" offset:[0,0] align:#center
hyperlink hl “:::::::: L o R a n /” address:“ http://loran-cg.blogspot.com/ ” offset:[-44,0] align:#center
hyperlink hl3 “Artur Leão :::::::” address:“ http://dimensao3.com/al/ ” offset:[44,-20] align:#center
hyperlink hl1 “Master Zap Sample Composite Scenes” address:“ http://mentalraytips.blogspot.com/2007/10/production-shader-examples.html ”
offset:[0,0] align:#center)--end
createDialog MR_rollout 220 320
--TODO : enable shaderlist with Mblur+Glare
– meditMaterials[2] = MBlur
– meditMaterials[1] = Glar
– MBlur =HDR_Image_Motion_Blur__mi ()
– MBlur.Shutter = 0.5
– MBlur.shutter_falloff = 2
– MBlur.blur_environment = off
– MBlur.calculation_gamma = 2.2
– MBlur.pixel_threshold = 1
– MBlur.background_depth = 1000
– MBlur.depth_weighting = off
– Glar = GlaretextureMap ()
– Glar.quality = 2
– Glar.Spread = 2
– Glar.Streaks = off