Results 1 to 8 of 8

Thread: 3dsMax 2014 and mental ray AO on the GPU

  1. #1
    Join Date
    Jan 2009
    Location
    Berlin/Germany
    Posts
    1,147

    Cool 3dsMax 2014 and mental ray AO on the GPU

    Hi mental ray for 3dsMax users,

    you might have heard about this already in other forums, mental ray is now using the GPU to speed up "ray tracing".

    au_gpu_gpu_800.jpg

    The version of 3ds Max 2014 is based on mental ray version 3.11. This version introduces support for Ambient Occlusion computation on the GPU, based on NVIDIA technologies OptiX and CUDA. The new AO rendering mode does not require special shaders or material setup. It is implemented as a separate render pass that stores the final image in a user frame buffer, so that the beauty render is not affected, and may be rendered in parallel on the CPU. In fact, in the GPU mode the AO pass can be computed for free because it typically finishes much faster than the beauty pass. See below for information how to enable and use AO GPU from within 3ds Max and render the final image from inside the application.

    Please note, that the new AO GPU capability is not yet fully integrated into 3dsMax as a supported feature. However, it can already be tested and used in its current form with the advanced workflow described in this tutorial. We would like to get your feedback about this feature in general, and technical issues you might have.

    Workflow

    With the help of 3ds Max Render Elements and custom mental ray String Options, the AO GPU feature can be used with mental ray for 3ds Max 2014 as follows.

    • Load a scene into 3ds Max.
    • Select mental ray production renderer.
    • Add a Render Element (any will do, e.g. Alpha).
    • Add String Options to enable AO GPU.
    • Render.


    See below for the manual steps.
    Alternatively, the attached MAXScript script can be used to perform those steps automatically after loading your scene. Execute it, and press Render.

    1. Add a Render Element

    AO_GPU_Max_Render_Element.jpg

    Add a new render element of type "Alpha". This will create an additional frame buffer inside mental ray to store the Ambient Occlusion result. The trick is to determine the name of the buffer (different from the name which is displayed in the render elements). If you there is just 1 render element, the name will be "fb_re#0". The index of the render element is incremented to build the fb name ("fb_re#1", "fb_re#2", …). The .mi file export of the scene will reveal the actual fb name, like in:

    Code:
    camera "Viewport|Viewport"
           output = "ImageCollector|Effect"
           framebuffer "FB_NAME_MAIN"
                  datatype "rgba_16"
                  filtering true
                  compression "rle"
                  useopacity true
                  premultiplied true
                  primary true
                  clip true
           framebuffer "fb_re#0"
                  datatype "rgba_16"
                  filtering true
                  compression "rle"
                  user true
                  clip true
    2. Add String Options

    Once the fb name is determined the required string options can be added to enable AO GPU:
    Code:
    "ambient occlusion gpu" on
    "ambient occlusion framebuffer" "fb_re#0"
    AO_GPU_Max_String_Options.jpg

    Render

    The render log should tell if the GPU was used.

    Code:
    GPU  0.4    115 MB info : gpuao:  Waiting for gpu...
    GPU  0.4    117 MB info :   gpuao thread:  context kernel compiled
    GPU  0.4    117 MB info :   gpuao thread:  [139.028 ms]  context AS built
    GPU  0.4    117 MB info :   gpuao thread:  start render ambient occlusion (48)
    GPU  0.4    117 MB info :   gpuao thread:  [1344.21 ms]  finish render ao frames
    GPU  0.4    117 MB info :   gpuao thread:  [2768.33 ms]  start pixel transfer
    GPU  0.4    117 MB info :   gpuao thread:  [74.6352 ms]  end pixel transfer
    GPU  0.4    117 MB info :   gpuao thread:  [4.32624 s total]
    GPU  0.4    117 MB info :   gpuao thread:
    The corresponding AO rendering result will pop up automatically (thanks to ''Render Elements''):

    Image:Steve_AOGPU_Max_Render_Display.jpg

    MAXScript

    Execute the following lines of MAXscript code in the MAXScript Editor. Once this was successful the render options will contain new options. Those are not stored with the 3dsMax scene file. The options are gone if a new scene is created, so the same script code has to be executed in order to enable this for the new scene.

    Code:
    -- Switch to production renderer 
    macros.run "Render" "RenderButtonMenu_Switch_To_Production_Mode"
    
    -- Ensure mr is production renderer
    renderers.current = mental_ray_Renderer()
    
    -- Get render element manager
    re = maxOps.GetCurRenderElementMgr()
    
    -- Name of the next render element buffer will be ="fb_re#<index>"
    index=re.numrenderelements()
    fb_name="fb_re#"+ (index as string)
    
    -- Add render elements for AO GPU
    re.addrenderelement (alpha elementname:("Ambient Occlusion on the GPU"))
    
    -- Setup AO GPU string options
    mental_ray_string_options.addoption "ambient occlusion gpu" on
    mental_ray_string_options.addoption "ambient occlusion framebuffer" fb_name
    We hope it works for you. BTW, most recent and previous GPU generations are supported.

    Have Fun

    Best, Steve.
    Attached Files Attached Files
    Last edited by steve; July 19th, 2013 at 17:26. Reason: screenshots

  2. #2
    Join Date
    Dec 2010
    Location
    Denmark
    Posts
    168

    Default

    Very nice
    Is it possible to control quality samples somehow?

  3. #3
    Join Date
    Apr 2009
    Posts
    759

    Default

    Hi you can use Render Optimizer V3. This tool have all option in the UI. look here:

    http://forum.nvidia-arc.com/showthre...r-Optimizer-V3!

    mfg
    hot chip

  4. #4
    Join Date
    Jan 2009
    Location
    Berlin/Germany
    Posts
    1,147

    Default

    Quote Originally Posted by Braiz View Post
    Is it possible to control quality samples somehow?
    Raising the "max samples" settings in "unified sampling" mode will implicitly increase the GPU AO quality. I have used 1000 samples in the rendering. Explicit control of GPU specific settings is also possible but not fully working in the version coming with Max2014. We will add more information once we verified what actually works

    Best, Steve.
    Last edited by steve; July 19th, 2013 at 18:39. Reason: wording

  5. #5
    Join Date
    Sep 2014
    Posts
    1

    Default

    i run this script several times but NO AO were Generated. help me..

  6. #6
    Join Date
    Jan 2009
    Location
    Berlin/Germany
    Posts
    1,147

    Default

    Quote Originally Posted by nidhishacharya View Post
    i run this script several times but NO AO were Generated. help me..
    Any error messages or other hints for us to look at ?

  7. #7
    Join Date
    Jul 2014
    Posts
    2

    Default ao

    Quote Originally Posted by steve View Post
    Any error messages or other hints for us to look at ?
    Hi Guys, my scene rendered with no error messages however the AO element was just a white window. Any ideas? cheers

  8. #8
    Join Date
    Apr 2009
    Posts
    759

    Default

    hi

    have you a screen shot from the viewport, and have you try Render Optimizer?

    mfg
    hot chip

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •