Results 1 to 6 of 6

Thread: Maya 2014 and mental ray AO on the GPU

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

    Cool Maya 2014 and mental ray AO on the GPU

    Hi mental ray for Maya users,

    here is a gimmick for you, especially for those with a decent NVIDIA GPU and plenty of memory on the card.

    ao_gpu_hunter_hq_ao_pass.jpg

    The released edition of Autodesk Maya 2014 integrates the latest NVIDIA mental ray version 3.11. This version introduces support for ambient occlusion computation on the GPU. The implementation is based on the NVIDIA technologies OptiX and CUDA, using the GPU "compute" mode in mental ray for the first time, rather than "graphics" mode as in past attempts for GPU acceleration.

    This new Ambient Occlusion (AO) rendering mode does not require special shaders or material setup any more. It is automatically rendered as a separate pass using global String Option parameters. The computed image is stored in a user frame buffer, so that the beauty render (on the CPU) is not affected while AO is being rendered simultaneously on the GPU. In the ideal scenario, the AO pass can be produced almost for free on the GPU because it typically finishes much faster than any of the other passes or the main image without impacting the CPU rendering. For a typical scene and setup, the AO computation on a GPU takes in the range of seconds, instead of minutes on the CPU.

    Please note, that the new AO GPU capability is not yet fully integrated into Maya 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 auxiliary procedures and custom String Options,
    the AO GPU feature can be used with mental ray for Maya 2014 as follows.

    • Load an existing Maya scene, or import a model into a new Maya scene.
    • Create the AO render pass and user buffer nodes (see 1. below), and
      add AO GPU string options (see 2. further below). Or, just run the script attached to this post.
    • Render Current Frame, or Batch Render.


    The beauty rendering will be shown in Maya’s Render View window, as usual. The AO pass image is stored in the background to the "images/tmp/" directory of the current Maya project, using a name like "<scene_name>_ao_pass.<format>". If all went well.

    You may want to check a GPU monitoring applet or render log for performance numbers and comparisons.

    1. Create the AO render pass and user buffer nodes

    Copy the following lines of MEL script code into the Maya Script Editor and execute it. Once this was successful the scene contains new nodes connected to the perspective render camera, and they will be stored with the Maya scene file. The nodes are gone if a new scene is created, so the same MEL code has to be executed to take effect in this new scene. It is convenient to turn on the Maya preferences option to Save Script Editor Contents.

    Code:
    // create AO render pass with user buffer
    //
    createNode -n "ao_pass" mentalrayOutputPass;
    setAttr ao_pass.fileMode true; // write to file
    setAttr ao_pass.fileFormat 5; // tiff
    setAttr -typ "string" ao_pass.fileName "ao_pass"; // file postfix
    createNode -n "ao_buffer" mentalrayUserBuffer;
    connectAttr -lock on ao_buffer.dataType ao_pass.dataType;
    connectAttr -force ao_pass.message perspShape.miOutputShaderList[0];
    If this was successful then the resulting Maya node graph should look as followed (select the “ao_pass" node to see its in/out connections):

    Maya hypergraph.jpg

    If you display these nodes in AE then Maya may print the following error, which can be ignored.
    Code:
    // Error: The attribute 'ao_pass.dataType' is locked and cannot be disconnected.
    2. Add AO GPU string options

    The following script enables the AO GPU feature in mental ray, and announces the frame buffer used to store the image.

    Code:
    // mental ray 3.11 AO GPU
    //
    $idx = `getAttr -size miDefaultOptions.stringOptions`;
    setAttr -type "string" miDefaultOptions.stringOptions[$idx].name "ambient occlusion framebuffer";
    setAttr -type "string" miDefaultOptions.stringOptions[$idx].value "ao_buffer";
    setAttr -type "string" miDefaultOptions.stringOptions[$idx].type "string";
    $idx = `getAttr -size miDefaultOptions.stringOptions`;
    setAttr -type "string" miDefaultOptions.stringOptions[$idx].name "ambient occlusion gpu";
    setAttr -type "string" miDefaultOptions.stringOptions[$idx].value "on";
    setAttr -type "string" miDefaultOptions.stringOptions[$idx].type "boolean";
    //
    // These settings are not required, but can be used to control the effect
    //
    $idx = `getAttr -size miDefaultOptions.stringOptions`;
    setAttr -type "string" miDefaultOptions.stringOptions[$idx].name "ambient occlusion max distance";
    setAttr -type "string" miDefaultOptions.stringOptions[$idx].value "5.0";
    setAttr -type "string" miDefaultOptions.stringOptions[$idx].type "scalar";
    $idx = `getAttr -size miDefaultOptions.stringOptions`;
    setAttr -type "string" miDefaultOptions.stringOptions[$idx].name "ambient occlusion falloff";
    setAttr -type "string" miDefaultOptions.stringOptions[$idx].value "1";
    setAttr -type "string" miDefaultOptions.stringOptions[$idx].type "integer";
    Known Issues

    Memory CPU / GPU
    The amount of CPU RAM needs to be similarly high as on GPU.
    The amount of main memory has to be as high as what is needed to store the scene data on the GPU. In a modern computer setup this is usually the case anyway. The main memory is used for additional temporary storage of pre-computed GPU acceleration data that is needed for rendering on the CPU. This is a known issue with certain procedures and settings in the version of OptiX that is currently used.

    AO Quality Settings
    The global AO settings are respected, but local override settings per pass are not.
    The AO settings are "derived" from the global sampling settings if no specific AO parameters are provided. This is working correctly, but the procedure of this mapping is hidden and tuning of actual AO quality is only indirect. For direct control, the GPU mode supports specific AO settings, but those seem to not be respected in some cases. That means, the AO GPU pass - now rendering much faster than the beauty render – can not be tuned individually towards higher quality to fully utilize the extra horsepower of the GPU.

    Troubleshoot

    The AO GPU does not work on Mac and Linux.
    There is a known problem with default library dependencies in the plug-in. Setting the environment variable DYLD_LIBRARY_PATH (Mac OS X), or LD_LIBRARY_PATH (Linux) to point to the folder of the OptiX libraries before starting Maya may fix this.
    On Mac OS X and Linux, a CUDA capable driver needs to be installed separately. For Mac instructions see http://www.nvidia.com/object/cuda-mac-driver.html.

    Details

    The AO GPU functionality is implemented in a plug-in package of mental ray, called gpu_ao_plugin. It is based on NVIDIA OptiX, thus it depends on additional runtime libraries, see below. A decent NVIDIA CUDA capable graphics card is required, preferably running with the latest driver.

    Example (Maya2014 64bit on Windows Vista/7):
    Code:
    C:\Program Files\Autodesk\mentalrayForMaya2014\bin\gpu_ao_plugin.dll
    C:\Program Files\Autodesk\mentalrayForMaya2014\bin\optix.1.dll
    C:\Program Files\Autodesk\mentalrayForMaya2014\bin\optixu.1.dll
    C:\Program Files\Autodesk\mentalrayForMaya2014\bin\cudart64_42_9.dll
    Have Fun

    Best, Steve.
    Attached Files Attached Files
    Last edited by steve; July 8th, 2013 at 19:20. Reason: steps

  2. #2
    Join Date
    Feb 2014
    Posts
    1

    Default

    Hi Steve,

    Thanks for this Script.

    I also want to know if i can render full beauty pass or saperate passes on nVidia GPU coz my CPU is Core2Duo on which rendering is very slow and i have ASUS nVidia GTX650 2Gb Graphics card of which i can take advantage. I dont want to upgrade my cpu because of my budget. I thought i can render on GPU inside maya in mental ray. Hope you will help me.

    Thank You.

  3. #3
    Join Date
    Dec 2005
    Location
    Wherever The Computer Says
    Posts
    2,853

    Default

    For now certain functions in mental ray are GPU, this includes AO on the GPU and the announced GI (global illumination) on the GPU in 3.12

    Shaders have to be written in a certain way for the GPU to understand them. This means current shaders cannot be rendered in your scene on the GPU.

    However, there is hope: the Material Definition Language that iray uses is a way to use agnostic descriptions to render on different hardware.

    http://on-demand.gputechconf.com/gtc...n-Language.pdf
    "Don't argue with an idiot, they will drag you down to their level and beat you over the head with experience."

  4. #4
    Join Date
    May 2014
    Posts
    1

    Default

    er... really struggling to get this to work. dunno what to say. tried everything I can think of for like the past 2 hours
    tif is spat out but is always blank.
    any ideas?

    i have a Geforce GTX 680....

  5. #5
    Join Date
    Aug 2013
    Posts
    2

    Default

    Quote Originally Posted by steve View Post
    Troubleshoot

    The AO GPU does not work on Mac and Linux.
    There is a known problem with default library dependencies in the plug-in. Setting the environment variable DYLD_LIBRARY_PATH (Mac OS X), or LD_LIBRARY_PATH (Linux) to point to the folder of the OptiX libraries before starting Maya may fix this.
    On Mac OS X and Linux, a CUDA capable driver needs to be installed separately. For Mac instructions see http://www.nvidia.com/object/cuda-mac-driver.html.
    Looks like this still doesn't work 1.5 years later on OSX.

    Latest CUDA drivers Quadro K5000 on OSX 10.9.5 Mac Pro, latest Maya 2016 beta, Maya.env provided with:

    DYLD_LIBRARY_PATH = /Applications/Autodesk/mentalrayForMaya2017/bin:/Volumes/Mac Pro HD/Applications/Autodesk/mentalrayForMaya2017/bin
    Mental Ray output log:

    JOB 0.0 9 MB info : slave rendering on
    MEM 0.3 59 MB info : physical memory detected: total 65536 MB, free 63986 MB
    MEM 0.3 59 MB info : virtual memory limit set to 63986 MB
    LIB 0.4 59 MB warn 292014: loading /Applications/Autodesk/mentalrayForMaya2017/bin/gpu_gi_plugin.dylib: dlopen(/Applications/Autodesk/mentalrayForMaya2017/bin/gpu_gi_plugin.dylib, 1): Library not loaded: @rpath/liboptix_prime.1.dylib Referenced from: /Applications/Autodesk/mentalrayForMaya2017/bin/gpu_gi_plugin.dylib Reason: image not found
    GPU 0.3 59 MB error 871001: GI-GPU not available. (Could not load plugin /Applications/Autodesk/mentalrayForMaya2017/bin/gpu_gi_plugin.dylib.)
    SCEN 0.3 64 MB info : 1132 geometry leaf instances (1132 scheduled, 0 cached, 0 shared)
    SCEN 0.3 64 MB info : 9 light leaf instances
    SCEN 0.3 64 MB info : wallclock 0:00:00.01 for scene preprocessing
    SCEN 0.3 64 MB info : CPU usage 0:00:00.01 for scene preprocessing
    SCEN 0.3 64 MB info : current mem usage 64 MB, max mem usage 64 MB
    RC 0.3 65 MB info : scene extent: (-1832.36,-15.02,-694.15) : (689.80,622.75,864.60)
    LIB 0.28 65 MB warn 292014: loading /Applications/Autodesk/mentalrayForMaya2017/bin/gpu_ao_plugin.dylib: dlopen(/Applications/Autodesk/mentalrayForMaya2017/bin/gpu_ao_plugin.dylib, 1): Library not loaded: @rpath/liboptix_prime.1.dylib Referenced from: /Applications/Autodesk/mentalrayForMaya2017/bin/gpu_ao_plugin.dylib Reason: image not found
    RC 0.3 65 MB warn : Fast AO pass not available, will use core fallback. (Could not load plugin /Applications/Autodesk/mentalrayForMaya2017/bin/gpu_ao_plugin.dylib.)
    Rendered image: no GI. Disappointed.

  6. #6
    Join Date
    Mar 2009
    Location
    Brazil - Santa Catarina
    Posts
    10

    Default

    Quote Originally Posted by DutchDimension View Post
    Looks like this still doesn't work 1.5 years later on OSX.

    Latest CUDA drivers Quadro K5000 on OSX 10.9.5 Mac Pro, latest Maya 2016 beta, Maya.env provided with:



    Mental Ray output log:



    Rendered image: no GI. Disappointed.

    You need to set the DYLD before start maya, but using the command line.
    Open a terminal and type this:
    DYLD_LIBRARY_PATH=/Applications/Autodesk/mentalrayForMaya2016.5/bin/
    export DYLD_LIBRARY_PATH

    Then start maya from the same terminal
    That was the way i could make it work here.

    Hope it helps!
    raio mental
    Bucket Watcher

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
  •