Page 1 of 2 12 LastLast
Results 1 to 10 of 18

Thread: mental ray standalone input from named pipe

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

    Lightbulb mental ray standalone input from named pipe

    Hi,
    I'd like to give some more hints about this possibility to drive mental ray Standalone in kind of interactive mode.

    Operating systems support so called named pipes (Windows), or named fifo buffers (Unix, Mac), for communication between applications which support reading and writing files. Such named pipes appear as files on disk, but they actually don't store data on disk. Instead, such a pipe is reading data from its (standard) input and immediately passing it through to its (standard) output, with some temporary buffering.

    mental ray Standalone can be run on such a named pipe to render the .mi stream it will receive, while another process may constantly feed this pipe with .mi text input. As long as the .mi stream is not closed, and valid .mi syntax is passed (mental ray will stop on serious syntax errors) , the renderer will continue until stopped explicitly.

    Here is a code snippet for a command line version (Unix, Mac) :
    Code:
    > mkfifo ray_pipe
    > ray -v on mi_file.mi ray_pipe &
    > cat - >>ray_pipe
    render "world" "camera" "options"
    ^D
    This would start mental ray in a background process to read scene data from a file mi_file first, then continue to read from the ray_pipe pipe until end-of-file. In the same shell we start a terminal input in the foreground, where we enter .mi text directly that is passed on to the pipe. As soon as this data has been copied through the pipe by the operating system mental ray will read it and execute the commands. In the example it would trigger a second rendering. The whole pipeline can be stopped by pressing Ctrl+D, as end-of-file.

    There is one small caveat, especially with small text snippets like the above which are not passed through immediately when typed. That is because there are buffers involved, not only in the operating system but also in mental ray. mental ray keeps a .mi input buffer of 4096 characters. The buffer in the OS may be turned off, but the mental ray buffer is not controllable. That means, to get small text pieces pushed through, they should be followed by enough 'space' characters to make it a block of >4k characters. Update for mental ray 3.9 and beyond: with the introduction of compressed .mi stream support the internal buffers are now larger in size of approx. 16KB.

    I hope this helps,
    Steve
    Last edited by steve; August 1st, 2012 at 15:31. Reason: typo

  2. #2
    Join Date
    Aug 2005
    Location
    Toronto
    Posts
    192

    Default Thanks Steve. Quick question though...

    Is there a way to interrupt the mental ray process using this method to send new data? I've implemented this but have to wait until each render completes before I can send any new data through the pipe.

  3. #3
    Join Date
    Aug 2005
    Location
    Toronto
    Posts
    192

    Default

    Still can't seem to figure this out. Any help would be greatly appreciated.

  4. #4
    Join Date
    Jan 2009
    Location
    Berlin/Germany
    Posts
    648

    Cool Abort rendering with mental ray Standalone

    Here is a secret trick that should work on Linux (and Mac),

    Code:
    kill -HUP nnnn
    with nnnn being the process ID of mental ray, should abort rendering but not kill the process.

    There is no way to abort rendering with a command in the .mi stream, which is intentional.

    Hope this helps, Steve.

  5. #5
    Join Date
    Aug 2005
    Location
    Toronto
    Posts
    192

    Default

    Thanks again Steve. Unfortunately our artists machines are all windows.

  6. #6
    Join Date
    Dec 2004
    Location
    Marina Del Rey, California
    Posts
    3,070

    Default

    To clarify, you want to allow the artists to stop rendering an mi file with standalone while rendering? And they don't use imf_disp, where you could just use the red stop button?
    Barton Gawboy
    Training and Special Projects, NVIDIA ARC
    LAmrUG Forum Originator

  7. #7
    Join Date
    Aug 2005
    Location
    Toronto
    Posts
    192

    Default

    Hi Bart. Unless I'm mistaken streaming with imf_disp 2.0 is broken, so I'm using the old imf_disp that doesn't have that button.

    What I'm trying to achieve is a level of interactivity similar to IPR within maya, using maya as the interface but mentalray standalone as the renderer. I would have a script job running in maya that is monitoring the file for changes, when changes are made ideally it would send a command to ray to stop (but not exit) and then stream the changes to ray and render again.

    So far I'm only able to kill ray entirely and restart the entire render which is not desirable as I don't want to have to parse all the geometry, tesselate, build acceleration structures, etc.., or wait for the current render to finish and then stream the changes and render again, which is working but not ideal.

    I wanted to speed up the interactivity by leveraging progressive rendering, but I can't stop the progressive render if the user wants to update something in the scene ie- parameter change on a shader, camera position etc..

    I was hoping there was a way to send a stop command directly via the stream, but I guess that's out. I guess I need to see if there is a windows version of SIGHUP.

  8. #8
    Join Date
    Aug 2005
    Location
    Toronto
    Posts
    192

    Default

    edit: double post
    Last edited by 1armedScissor; March 30th, 2012 at 15:59.

  9. #9
    Join Date
    Jan 2007
    Location
    Berlin, Germany
    Posts
    101

    Default

    In mental ray 3.10, we've restored the image pipe functionality for imf_disp 2.0.
    The 3.10's imf_disp can be used with older versions of mental ray as well.

    If you use older version and eager to write some scripts: when mental ray starts rendering it creates image stub, which is just one line like this:

    ray3.6,1000,1000,juri-dt,52454,1.000000,5292,52455

    Take the last number (52455 in that case). It is a port number. Telnet to it, like
    telnet localhost 52455

    Send the command "stop<ENTER>".

    This is pretty much what the red button does. At least the imf_disp's one.

    Cheers,
    Juri

  10. #10
    Join Date
    Aug 2005
    Location
    Toronto
    Posts
    192

    Default

    That's great. Thanks Juri. I'll implement it as soon as I get my hands on the new imf_disp

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
  •