Sunday, 21 April 2013

3d: Render higher resolution images with "Render_autosave", using VRay or mental ray

The 3d image shown above was created while at GMJ. To see my entire 3d portfolio and the architectural rendering, simply click on the above image! 

While today’s fast computers may ensure rendering crashes are less and less frequent, there are still instances when processing high resolution photorealistic renders will cause computers to freeze and ultimately crash!

I have certainly experienced in numerous occasions having renders freeze and crash when there were only few “render buckets” left to complete the entire image!

Such inconveniences may cause major setbacks with the final deadline and user’s workflow, especially when the renders are taking a considerable amount of time to process.

For example, the above panoramic image was rendered at 22.000 x 11.000 pixels,while at GMJ design ltd. As one can imagine, it was a huge challenge to create and render the above image due to its unusual output pixel size, and the manner in which it was captured (panoramic).

And yes, it crashed several times while the render was being processed!!
We had decided to render the space in a panoramic style to save the client time and money by NOT having to create and render countless camera angles to capture the entire proposed space.
The end product was a full panoramic image rasterized as a JPEG, which the client was then able to view and navigate through, by using a free software called “ iMove Viewer” .  

Very recently, a prolific script writer/ Senior Visualiser and Photographer called  David Venables has created an ingenious and simple script that allows users to set 3Ds max to automatically save the render periodically while still being processed in the frame buffer.

Users can also set the location and the frequency of the renders being saved.

Below is the simple script created by David Venables:


                Global AutosaveImg


                fn dntTick =


                                Local Autosavedir = (getdir #autoback) + "\\" + "Rend_autosave.tif"

                                TIF.setType #color16

                                TIF.setAlpha #true

                                ::AutosaveImg = getLastRenderedImage copy:off

                                AutosaveImg.gamma = 2.2

                                AutosaveImg.filename = Autosavedir

                                Save AutosaveImg


                Global dnetTimer = dotnetobject "system.timers.timer" (2*60*1000)

                dotnet.addEventHandler dnetTimer "Elapsed" dntTick

                callbacks.removeScripts id:#RenderAutoSave

                callbacks.addScript #preRender "dnetTimer.start()" id:#RenderAutoSave

                callbacks.addScript #postRender "dnetTimer.stop()" id:#RenderAutoSave


To save this script, simply open 3Ds Max, followed by clicking on the MAXScript button from the main toolbar, and choosing the MAXScript Editor option from the dropdown list.

Its dialog should open. Next, copy and paste the above mentioned script onto the dialog’s text field.   

By default, the script automatically finds the autosave path with the (getdir #autoback) string of code; and saves the file under the name of  "Rend_autosave.tif"  as a TIF file format.  

This can be changed manually. For instance, the default path could be saved in the following location: C:\Users\Public\Pictures

The relevant line of code would be replaced with the following: “Local Autosavedir = C:\\Users\\Public\\Pictures + "Rend_autosave.tif" .

In addition, the script automatically sets the saving frequency to every 2 minutes: (2*60*1000).

This default timer can also be changed by simply typing in a different number you may find more adequate (i.e. replace nr 2)!

Once satisfied with everything, simply save the script by pressing Ctrl+S.

The Save file dialog should appear. In order for this script to automatically start as a callback everytime 3Ds Max is lauched, it must be saved as an ms file in the following location:
C:\Program Files\Autodesk\3ds Max 2012\Scripts\Startup.   

Note: If using a different version of Max, simply save the script in the adequate 3ds Max folder (i.e. 3ds Max 2013; etc). 

Next, close and restart 3Ds Max. Render anything that would take longer than 2 minutes to test whether the script works or Not.

Finally, go to the designated folder/location to see the saved image/file; or simply type in the following in the bottom left part of 3ds Max: display (getLastRenderedImage()) ; followed by pressing Enter.
The OK text in blue should appear below, along with the last saved render in the frame buffer.  

The beauty of this script is that it will give the user the reassurance/peace of mind that when/if the render crashes it will be saved. This will also enable the user to continue from where the render was last saved; as opposed to starting from scratch again! 

Currently the script works mainly with the 3Ds Max frame buffer, regardless of the rendering engine being deployed.

The panoramic image below was rendered using the Render_autosave script!

If there are any specific features you would like to see implemented in this script, please contact David Venables through his LinkedIn page HERE or via email HERE.

I hope you have found this article useful.

Checkout below my other Courses with High Resolution Videos, 3d Project files and Textures included.

Course 1: Exterior Daylight with V-Ray + 3ds Max + Photoshop  

Course 2: Exterior Night with V-Ray + 3ds Max + Photoshop

Course 3: Interior Daylight with V-Ray + 3ds Max + Photoshop

Course 4: Interior Night with V-Ray + 3ds Max + Photoshop

Also, please Join my Patreon page to download other Project files; Watch more Videos and receive Technical Support. Finally, check out my New channels below:


Wednesday, 10 April 2013

3d images: Correcting the Viewport colour display of imported AutoCAD drawings, when added into a Layer in 3Ds Max

Often, imported AutoCad drawings lose their original colour once added into a new layer (using “Manage Layers” toolbar) in 3Ds Max.  
This “glitch” usually frustrates numerous users for a number of reasons, as colour coded drawings help to quickly understand the design and to easily “select by colour” any given layer/s of the relevant drawing in the 3Ds Max scene.    

After countless requests to post an article/tutorial on how to correct this problem, I have finally managed to put something together with help of a prolific script writer/ senior Visualiser/Photographer called David Venables.

David created a simple script to override the above mentioned problem! 
I have had the pleasure to meet and continue to work with David while at AVR London.

David Venables can also be contacted via LinkedIn Here.

Without further ado let us start by importing an AutoCAD file format (i.e. DWG) into 3Ds Max. 

With the DWG file imported into Max, the next step is to quickly create a simple script and apply it.
A- Click on the “MaxScript” button from the main toolbar, and choose the “Maxscript Editor” from the dropdown list, to open its dialog box.
B-Copy and paste the following text/script created by David, into the text field of the “Maxscript Editor” dialog:

     Fn ColourFromLayer =
                Local SelectionArr = (selection as array)
                Local myarr = #()
                for i in SelectionArr do append myarr i.wirecolor
                for i = 1 to SelectionArr.count do
                                SelectionArr[i].colorByLayer = false
                                SelectionArr[i].wirecolor = myarr[i]

The next step is to “Evaluate” the script.
A- To do so, first open the “MaxScript Listener” dialog by pressing the “F11” key.

B-Next, select the “Maxscript Editor” dialog and press “Ctrl+E” to evaluate the script for any possible errors. Alternatively, simply go to “Tools” and choose the “Evaluate All” option from the dropdown list.
The “ColourFromLayer()” text should automatically appear in the text field of the “MaxScript Listener” dialog…without any red text errors.

Following that, select the entire imported drawing with the “Selection Region” tool.

To apply the script to the selected drawing, simply go to the text field of the “MaxScript Listener” dialog; ensure that a blinking vertical text bar is in front of the “ColourFromLayer()” text ,followed by pressing “Enter”.  
The “OK” text should appear, and the blinking vertical text bar should automatically jump below it…without any red text errors.

This is an indication that the script had been applied successfully.    

To test whether or not the script will serve its purpose once the drawing is added into a new layer, first open the “Manage Layers” dialog by clicking on its button on the main toolbar.
While the drawing is still selected, create a new layer by simply clicking on its button in the “Manage Layers…” dialog. Also, re-name the layer.  

The entire content of the drawing should now be part of the newly created Layer, with the drawing’s original colours intact.  Press "Ctrl+D" to unselect everything in the 3Ds Max Scene.  

If/when satisfied with the results, save the script by first selecting, right clicking and copying the “ColourFromLayer()OK” text from the “MaxScript Listener” dialog; followed by pasting it onto the “Maxscript Editor” dialog. Ensure the newly pasted text is below the existent ones.  

Next, press “Ctrl+S” to save it as a *.mcr.* file format in an accessible shared location.

To quickly be able to deploy this script in future occasions, users often run it off the Max quad menu or as a toolbar button.
Too add it as a toolbar button, simply click on “Customize” main toolbar and choose the “Customize User Interface” option from the dropdown list.   
Its dialog should open. Under the “Toolbars” tab, create a new toolbar, by clicking on the “New” button.

In the “New Toolbar” dialog, name it accordingly and “OK” to close the dialog. A new toolbar button should automatically appear.  

With the new toolbar button created, one can now close the “Customize User Interface” dialog.

Next, we are going to drag and drop the previously created script text in its entirety from the “Maxscript Editor” dialog into the newly created toolbar button.
An image button should automatically appear in the newly created toolbar.
To edit its appearance, simply right click on its image and choose to “Edit Button Appearance” from its pop up menu.

The “Edit Macro Button” dialog should open. By default it is set to “Image Button”.

One can change it to “Text Button” type and name the “Label”, as well as the “Tooltip”. This action will allow users to see the name of the script on the button, as opposed to the previous default “Image button”
Once satisfied, “OK” to close the dialog.


Place the newly created toolbar close to the others, by simply clicking and holding on the top edge of its button; followed by dragging /placing it adequately.  

Finally, close and restart 3Ds Max. The newly created toolbar button should now be visible/part of the main toolbar.    

To test whether the new toolbar is working or NOT, import a completely new drawing into 3Ds Max.

Select the entire drawing as previously done and apply the script by simply clicking on the “ColourFromLayer” toolbar button created earlier.

Next, reselect the entire drawing and add it to a completely new layer as previously done.
As one can see:The drawing's original colours remained intact when added into a new layer...which is a clear indication that the new toolbar button worked as expected!

Tip: Adding a “#” before the layer name will ensure the newly created layer always stays on top of the list.  

I hope you have found this tutorial/article and the script useful.

Checkout below my other Courses with High Resolution Videos, 3d Project files and Textures included.

Course 1: Exterior Daylight with V-Ray + 3ds Max + Photoshop  

Course 2: Exterior Night with V-Ray + 3ds Max + Photoshop

Course 3: Interior Daylight with V-Ray + 3ds Max + Photoshop

Course 4: Interior Night with V-Ray + 3ds Max + Photoshop

Also, please Join my Patreon page to download other Project files; Watch more Videos and receive Technical Support. Finally, check out my New channels below: