RTT Switching between Scanline and Mental Ray AO Bake

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
  06 June 2013
RTT Switching between Scanline and Mental Ray AO Bake

Hey Everybody,

I am trying to figure out how to tell the RTT system to render out an AO map using a light map when using the Scanline renderer and Ambient Occlusion(MR) map when using Mental Ray. I can get it to kind of work by using some like this...


if foo = true
(
  Run some code..
)

if nfoo = true
(
 Run some other code...
)


But this codes cause a lot of issues and I think it's because the way above the script just runs it all. Now if I do something like this...


if foo = true then
(
  Run some code..
)

else if nfoo = true then
(
 Run some other code...
)


The first part will run but it will not run the second part of the code and I have no idea what I am doing incorrectly. Here is the main code that I am working I have cleaned it up so that it's not too long to look at. Yes I know it could probably be coded better but I am still in the learning process.


Global SLR = false
Global MRR = false


-- Makes sure that we have only one window open at a time. 
if (( mainRoll != undefined) and ( mainRoll.isdisplayed)) do
(destroyDialog mainRoll ) -- test if dialog exist 

--Moved this up here because it was causing lots of errors down below. 
--global n = $.name as string

rollout mainRoll  "Unreal Multi Tool"
(
	group "Change Render" -- define change render buttons
		(
		  button butScanline "Scanline" 	 align:#left  across:2 width:70 height:20 
		  button butMR "Mental Ray" 		 align:#left width:70 height:20
		)	
		
		fn checkRender nSearch =  -- function check if render installed 
		(
			theRenderer = for obj in RendererClass.classes where 
			  (matchPattern (obj as string) pattern:nSearch) -- check if the name in nSearch variable exist
				collect  obj
				if theRenderer.count ==1
				   then  renderers.current = theRenderer[1]()
		 else  
				 (messageBox "render not  installed")
		)	
		on butScanline pressed do 
		(
		SLR = true

		-- Set the Render Engine to be Scaneline
		renderers.production = Default_Scanline_Renderer()
		
		--These are the Advanced Ligthing settings
		SceneRadiosity.radiosity = Light_Tracer()
		
		-- Check to make sure that we have the correct render engine installed 
		varScan = "*Scanline*"
		checkRender varScan
		
		-- Set the sampleing size of the light tracer
		SceneRadiosity.radiosity.initial_sample_spacing = 0
		
		-- These are the Render options
		renderers.production.globalSamplerEnabled = true
		renderers.production.globalSamplerClassByName = "Hammersley"
		
		--This makes a skylight and sets it to be white. 
		select $Sky*
		max delete
		Skylight pos:[0,0,0] isSelected:off
		select $Sky001
		$.color = color 255 255 255
		--$.hide = true
		hideByCategory.lights = true
		
		)
		
		on butMR pressed do 
		(
		MRR = true
			
		-- Set the Render Engine to be Scaneline
		renderers.production = mental_ray_renderer()
		varMR = "*mental_ray*"
		checkRender varMR
		
		renderers.production.BoxFilterWidth  = 1.0
		renderers.production.BoxFilterHeight = 1.0
		renderers.production.FinalGatherEnable2 = true
		--renderers.production.
		select $Sky*
		max delete
		Skylight pos:[0,0,0] isSelected:off
		select $Sky001
		$.color = color 255 255 255
		

		)
		group "Render To Texture Setup"
		(
			button hp "High Poly" align:#left width:85 height:20
			button lp "Low Poly" align:#left width:85 height:20
			edittext SourcePath1 "Export File Location :" text: "<Select Valid source path>" fieldWidth:150  align:#left  readOnly:true labelOnTop:true
			button browse1 "Browse" align:#left width:85 height:20 
			
			spinner cage "Cage Offset" align:#left width:70 height:20
			colorpicker csRayMissColor "Ray Miss Color" align:#left  fieldwidth:15 height:15 color:black
			
		)
		group "Render Texture Maps"
		(
			spinner size "Map Size" range:[0,4096,128] align:#center width:70 height:20
			button butAO "AO Map"      align:#left  across:2 width:70 height:20 
			button butNO "Normal" align:#left width:70 height:20
			
		)
		
		On hp pressed do
		(
			fn geometryHP  = isKindOf obj Geometry 
			(
				theGeo1 = selectByName title:"Select High Poly" buttonText:"Select Mesh"  showHidden:false single:true
				global theProjObj = theGeo1
			)
		)
		On lp pressed do
		(
			fn geometryLP  = isKindOf obj Geometry 
			(
				theGeo2 = selectByName title:"Select Low Poly" buttonText:"Select Mesh"   showHidden:false single:true
				global theObj = theGeo2
			)
		)
		
		on butAO pressed do
			(
				try(
				if (ClassOf theObj.modifiers[1]) != projection do
				(
					-- add project modifier and projection objects
					 fn addProjMod lowResObj highResObjs cageOffset =
					 (
						modMode = getCommandPanelTaskMode()
						setCommandPanelTaskMode #modify
						 
						projMod = projection()
						addModifier lowResObj projMod
						for obj in highResObjs do
						(
							projMod.addObjectNode obj
						)
							projMod.resetCage()
							projMod.pushCage cage.value 
							projMod.displayCage = true
							projMod.name = "ProjMod"
							setCommandPanelTaskMode modMode
						
							-- This is our retun for later. 
							projMod
					 )
				 ))
				 catch
				 (
					 messagebox"Not all items filled in with data"
					 return()
				 )
				 
				 if (ClassOf theObj.modifiers[1]) == projection do
				 (
					fn addProjMod lowResObj highResObjs cageOffset =
					(
						--projMod = projection()
						projMod
					)
				 )

					 -- define variables
					 renderSize = size.value
					 fileName = theObj.name + "_AO.tga"
			
					 filePath = SourceDirectoryName_STR1
				 
					 -- the bake object needs to be selected	
					 select theObj
					 
					 -- set up the bake interfaces
					 bakeProps = theObj.INodeBakeProperties
					 bakeProps.removeAllBakeElements()  
					 bakeProjProps = theObj.INodeBakeProjProperties
					 
					if SLR = true  then
					(
						MRR = false
					 --  add type of map to render
						mapLM = LightingMap()
						mapLM.shadowsOn =true --enable shadows
						mapLM.filename = fileName
					 try
					 (
					 mapLM.fileType = filePath + filename
					 )
					 catch
					 (
						 messagebox"Please select a place to export your image"
						 return()
					 )
					 
					 -- map size
					 mapLM.outputSzX = renderSize
					 mapLM.outputSzY = renderSize
					 mapLM.enabled = true
					 
					 --New options that I need to look up what they do.
					 
					 mapLM.filterOn = true --enable filtering
					 
					 bakeProps.addBakeElement mapLM --add first element
					 
					 bakeProps.bakeEnabled = true --enabling baking
					 bakeProps.bakeChannel = 1 --channel to bake
					 bakeProps.nDilations = 1 --expand the texture a bit
					 bakeProjProps.rayMissColor = csRayMissColor.color
					 
					 --  projection
					 bakeProjProps.enabled = true
					 bakeProjProps.projectionMod = (addProjMod theObj #(theProjObj) 1)
					 
					 --*******
					 -- If this is not run when you make adjsutments to the cage they will not be saved. 
					 --********
					 --  open and close RTT 
					 macros.run "Render" "BakeDialog"
					 destroyDialog gTextureBakeDialog
					 
					 
					-- the bake object needs to be selected	
					select theObj
					 -- do the render
					render rendertype:#bakeSelected frame:0  vfb:true progressBar:true  outputSize:[renderSize, renderSize] cancelled:&wasCanceled
					)
					
					 else if MRR = true  then
					(
						SLR = false
						mapAO = Ambient_Occlusion() 
						mapAO.samples = 128 
						mapAO.filename = fileName
						
					 try
					 (
					 mapAO.fileType = filePath + filename
					 )
					 catch
					 (
						 messagebox"Please select a place to export your image"
						 return()
					 )
					 
					 -- map size
					 mapAO.outputSzX = renderSize
					 mapAO.outputSzY = renderSize
					 mapAO.enabled = true
					
					 --New options that I need to look up what they do.
					 
					 mapAO.filterOn = true --enable filtering
					 
					 bakeProps.removeAllBakeElements()
					 bakeProps.addBakeElement mapAO --add first element
					 
					 bakeProps.bakeEnabled = true --enabling baking
					 bakeProps.bakeChannel = 1 --channel to bake
					 bakeProps.nDilations = 1 --expand the texture a bit
					 bakeProjProps.rayMissColor = csRayMissColor.color
					 
					 --  projection
					 bakeProjProps.enabled = true
					 bakeProjProps.projectionMod = (addProjMod theObj #(theProjObj) 1)
					 
					 --*******
					 -- If this is not run when you make adjsutments to the cage they will not be saved. 
					 --********
					 --  open and close RTT 
					macros.run "Render" "BakeDialog"
					destroyDialog gTextureBakeDialog
					 
					 
					-- the bake object needs to be selected	
					select theObj
					 -- do the render
					render rendertype:#bakeSelected frame:0  vfb:true progressBar:true  outputSize:[renderSize, renderSize] cancelled:&wasCanceled
					)

					 -- file name
		)
	)
	
	createDialog  mainRoll  177  575


I think I am pretty close on this but I just have no idea what I might be doing wrong. As always any and all advice would be greatly appreciated.
__________________
|*BILLY$CLINT*|



 
  06 June 2013
Did you tried RTTAssist? You can find it in my signature. The script is not encrypted and you can see the code. The script provides an option to bake AO with MR and other map types with Scanline in one session.
 
  06 June 2013
Originally Posted by miauu: Did you tried RTTAssist? You can find it in my signature. The script is not encrypted and you can see the code. The script provides an option to bake AO with MR and other map types with Scanline in one session.


No I have not and I am looking into it now, however I can only see the .mzp which is an encrypted file correct? I think so because when I open it I can not read any of what is going on.
__________________
|*BILLY$CLINT*|



 
  06 June 2013
Thread automatically closed

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.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 06:33 AM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.