PDA

View Full Version : Rendering with Mental Ray by T. Driemeyer


LoneRobot
10-10-2005, 04:31 PM
Hi everyone,

I know that people asking for MR training material pops up quite a bit on this forum, but i'm trying to get my head around this renderer to see if we can use it on our next project. So im looking for something more advanced, but dont want to get into the uber-technical eqautions mularkey or any of that custom shader writing business.

has anyone got/read/burnt in a rage "Rendering with Mental Ray" by T. Driemeyer? the second revision is now out and purports to cover the latest MR release 3.4. Is this a book i should be spending my fourty squid on amazon and wait a month for it to be delivered? or is it one of those with a mathematics deathwish? I've read the tutorials, whatever i can find basically but i'm looking for a bit more literature rather than those videos that tell you what boxes to check rather than why.

I know there's bits and bobs about on the web, and most of it has been pushed my way via this forum and the fine MR thread, but i wondered if anyone had read this and could let me know whether i'd be better returning to my slightly pained expression denoting ignorant confusion rather than buying an unsuitable reference book. I seem to understand if i've read in an actual book, that's all, and besides i can read it on the train when i've run out of Lost episodes to watch. :)

I mean, i cant have been the only one who thought about buying it?? thanks chaps. :)

Hazdaz
12-22-2005, 05:41 AM
~BUMP~

Just found out about this book also

http://www.cgarchitect.com/news/newsfeed.asp?nid=3004

And I too woudl be interested in hearing if anyone has it and if they recommend it.

From the look of it (specifically the number of pages, versus the relitively few color photos), it actually appears to be more of a college textbook, than a regular "tutorial" type of book, which just makes me think it is full of technical minutia - not something that I am interested in.

CrackleWax
12-22-2005, 07:03 AM
likewise,


it would be nice to have a clear and explanatory book!

Obi

-Vormav-
12-23-2005, 12:35 AM
The only problem with Rendering with Mental Ray (as well as the similar Programming Mental Ray book from Springer publishing), is that they are more or less what you already have in your mental ray manual and mental ray shader guide (the mr_manual.chm and mi_shader_libs.chm guides found in your max/help folder). I've had both books for a few months now, and a lot of the information is -exactly- the same as what you'll find in the latest versions of those help guides.
There are a few additional sections, but not nearly enough to justify the high prices on those books.

In general, here's what you can expect from each book:
Rendering with Mental Ray: Explanation of all the base/physics/contour shaders (not really how to best use each of them). Most of the book covers the .MI syntax. If you're looking for a book that will teach you how to speed up your render times, get good results out of GI/FG/Caustics, build a more efficient pipeline, or even just how to get nice results through MR shader networks, find something else!
Programming with Mental Ray: Just about everything covered in the 'Mental Ray Manual' - it's almost exactly the same - the wording, the format, everything. This book doesn't actually give you any tutorials on how to get started with shader programming, although it does offer a few uncommented examples. But it does at least give a basic explanation of what all the mi_ and mi_api functions do, although their explanations are often not enough. The book is good to have as a reference guide (although, if you setup an easy way to access the copy of this book that you already have in your max folder, I don't think you'll find yourself using the book very often). If you ever buy this book, just do it for the demo copy of MR Standalone that comes with it. But if you actually want to learn MR programming, you should be more concerned with getting your hands on as much source code as you can: All of the source code files from the mentalimages ftp, all of the sourcecode that various shader writers have released with their shaders, etc.

Hazdaz
12-23-2005, 01:26 AM
Good Lord! Thanks for the warning and that is exactly what I expected this book to be like... after all it was written by one of the MR guys.

That is exactly NOT the type of book I want... I want something that will give me suggestions as to what would work good in this situation or that situationm - someone that actually have experience in this type of stuff. Or tips in how to speed up stuff. Another "technical manual" is sooo not required.

Thanks for the heads-up.

LoneRobot
12-23-2005, 09:15 AM
Whoo, I'd forgotten about this thread i posted but thanks for the heads-up Vormav.

soulburn3d
12-23-2005, 03:36 PM
Well, the main problem is this (from my perspective). Mental Images business plan is that they write the renderer, and the software company (discreet, alias, softimage, etc) write the integration to the 3d app. So from Mental Images perspective, a book about mentalray is basically a programming book, hence the Driemeyer books.

And from an author's perspective, because mentalray has some major differences depending on which 3d app you're using, writing a single tips and tricks book about mentalray would be hard because a lot of the material would only be applicable to a single 3d app.

So basically someone would have to write a mr book specifically for max, which I don't think exists yet, and may take awhile considering the limited audience (book publishers generally like to know they have a huge audience before greenlighting a book). So in the meantime you may have to deal with the tutorials and online ressources such as this forum.

- Neil

gulio
01-08-2006, 07:43 PM
This is probably a newbie question. I`ve got a copy of the new released mr handbook "rendering with mental ray". On the accompanying cd is a Demo version (3.4.3.61) of the mr standalone .exe which I would like to test.
I´ve just copied the .exe on my HD and run the programm via doubleclick. The progam launches and tells me some restictions of the Demo version and an warning that the standard startup file ray3rc is not found. I´ve tried to take a copy of the "rayrc" file from my 3ds max 8 and renamed it so the warning message was gone. In the way which is described in the book, one has to enter the comand "ray" and then the .mi file name and may be a output option.
But unfortunatly nothing happens. So i´m wondering if the program is not running properly or do I have to enter anything differnt?
Is there a comand which can make the program respond, may be "help"?. Also, I would think one can close the program via "exit" or "quit" commad. I now just can get out by closing the window of the console window.
Any help would be much appeciated.

-Vormav-
01-08-2006, 08:54 PM
gulio - Open up your mi file, and add this line to the top:
verbose on

That way, if any error messages are being presented, you'll at least be able to see them. I would guess that, more than likely, your shaders are failing to be loaded (actually, if you're using the rayrc file from Max, you're not loading any shaders at all - Max links shaders directly through the MI file, not the rayrc - and even then, the paths used in the mi files are relative, so if you're not loading your rayrc folder from the right folder, these won't point to the right location).
I'll post a sample rayrc file later on, when I get on my other computer. But for now, take a look at the example on this page at lamrug: http://www.lamrug.org/resources/standalonetips.html

Also, you can use Ctrl-C to exit from programs in the command prompt. This works for getting out of programs that are doing nothing, as well as cancelling renderings. Also, keep in mind that 'ray' just renders to a file; you still have to use imf_disp (or whatever imaging app) to see the results. Without verbosity on, and not realizing that, it may often seem that ray isn't really doing anything.

mustan9
01-08-2006, 08:59 PM
I know there's bits and bobs about on the web, and most of it has been pushed my way via this forum and the fine MR thread, but i wondered if anyone had read this and could let me know whether i'd be better returning to my slightly pained expression denoting ignorant confusion rather than buying an unsuitable reference book.

I have not read this book.

But, I have heard that it does not translate to 3D Studio Max. The Mental Ray intergration in Max is confusing.

Also the book covers the huge topic of writting your own custom shaders, but it doesn't tell you how you can do this in Max. It's confusing and frustrating to write MR shaders in Max.

It mainly talks about Maya (I think???).

MR was such a late after thought when added to Max that it doesn't compair well when you look at the new implementations in Maya and XSI.

-Vormav-
01-08-2006, 11:23 PM
I have not read this book.

But, I have heard that it does not translate to 3D Studio Max. The Mental Ray intergration in Max is confusing.

Also the book covers the huge topic of writting your own custom shaders, but it doesn't tell you how you can do this in Max. It's confusing and frustrating to write MR shaders in Max.

It mainly talks about Maya (I think???).

MR was such a late after thought when added to Max that it doesn't compair well when you look at the new implementations in Maya and XSI.
Not true. It does not cover shader writing directed at any specific application. And it does not cover integration with Maya.
And really, the process for writing custom shaders in Max is just the same as creating custom shaders for Maya - exact same process. There is nothing about Max that makes writing MR shaders for it any different than for other applications (this is why it's so easy to transfer MR shaders between different applications with only minor changes in the MI declaration files [changes are needed mostly because Maya has neglected to make use of apply type statements, which are standard in the MI syntax, which has led most Maya MR shader writers to ignore them entirely] - the only thing that these shaders really depend on is the version of MR that they're being run with). Don't be mistaken: This is aimed at custom shader writing more for standalone MR than anything else. That's why you won't find any in-depth explanations of Max's GUI declarations in the MI syntax, or Maya's integration of default and range values through MI files and the use of MEL to define shader interfaces, or XSI's alternative to the MI syntax for shader declarations and interfaces.
If anything, it's actually more difficult to write shaders for Maya than for Max or XSI: Whereas default shaders in Max and XSI only return miColor values, the Maya standard shaders return structs with various pieces of information instead, meaning the shader writer has to go through a few extra loops to make their MR shaders compatible with Maya's standard (non-MR) shaders.

The MayatoMR connection is also just as shoddy as Max's connection (granted that in the latest versions of both applications, most of the bugs have been worked out for both of them - although Max still needs to have render passes revisited, and Maya needs to add support for PaintFX). It offers more options than Max for sure, but it's still a fairly poor integration - which is why MR Liquid for Maya was created. MR in Maya was just as much an afterthough as with Max.

gulio - Here's a look at one of my rayrc files - the one I use just for compiling and testing shaders for MR3.4 standalone:

registry "{MR_DIR}" value "C:\Program Files\mental images\mental ray" end registry
registry "{SHADER_DIR}" value "C:\shader_dev" end registry
$lookup "{MR_DIR}"
$lookup "{SHADER_DIR}"

registry "{_MI_REG_INCLUDE}" value "{MR_DIR}/include;{SHADER_DIR}/shaders" end registry
registry "{_MI_REG_LIBRARY}" value "{MR_DIR}/shaders;{MI_DIR}/lib;{SHADER_DIR}/shaders" end registry
link "base.so"
$include "base.mi"
link "contour.so"
$include "contour.mi"
link "physics.so"
$include "physics.mi"
link "subsurface.so"
$include "subsurface.mi"


For standalone rendering with MI files exported from Max, you don't really need any rayrc files (ray will still warn you about the lack of a rayrc file, but you can ignore this). What you do have to do is change the paths in the link & include statements in the MI file to point to the right place, unless you're doing your rendering from your shader folder, which is a major pain in the ass. There's a couple ways to deal with this: You can write a simple Python script to quickly change the paths for you (Go grab python and learn the basics of it right away. It's one of the easiest programming languages to learn, and is perfect for doing little things like this). Or you could manually remove all of those link/include statements, and 'include' another MI file that has all of the link/include statements for each of your shaders instead - which would at least minimize all that you have to do to prepare for rendering. Or you can just link/include everything in a rayrc file, and ignore the link/includes from the MI file: Ray will complain about redeclaring shaders, but this can be ignored. The only annoyance here is that, if you have verbosity on for error checking, you'll have a lot of extra error messages to wade through, which can be very annoying. But if you're fine with that, here's what a rayrc file for that could look like (place the rayrc file in the folder that you're going to be doing your rendering in):

registry "{MAXBASE}" value "C:/3dsmax6/mentalray" end registry
$lookup "{MAXBASE}"

registry "{_MI_REG_INCLUDE}" value "{MAXBASE}/shaders_standard/include;{MAXBASE}/shaders_autoload/include" end registry
registry "{_MI_REG_LIBRARY}" value "{MAXBASE}/shaders_standard/shaders;{MAXBASE}/shaders_autoload/shaders" end registry



One more thing: Max (as with pretty much every app that uses MR) has its output pointing to its own framebuffer, so even if the 'ray' command on the file does run without errors, you'll still have to change this before you can actually see any results from the rendering. Just open up your exported MI file, and look for a line under the 'camera' declaration that looks like this:

output "+rgba_16" = "ImageCollector|Effect"


Just change that to whichever output type you like. Maybe:

output "rgba" "tif" "finalimage.tif"

Just to give another little tip on the workflow: I usually prefer to set the output name the same as the filename of the exported mi file (well, apart from the file extension) - so for render_01.mi, render_01.tif. That way I can quickly run a batch file that does the rendering, and then uses imf_disp to show the rendered frame as well. And of course, if you were using a python script to adjust all of the link/include paths from your MI file, it would be pretty easy to automate this change in the MI file as well while you're at it. ;)

gulio
01-09-2006, 03:55 PM
Hi Vormav,
thanks for your effort and the detailed explanation. I´ve forgotten to mention that after I renamed the "rayrc" file from max to "ray3rc" the ray.exe told me that \shader_standard\standard.mi and \shaders_3rdparty\3rdparty.mi are not found. So I just copied the two folders from my mr folder of the 3d max app in the ray.exe root folder. After this at least the message disappered. I have to take really small steps due to my poor knowledge of commad line applications :sad: . First success is, your ctrl +c commad works and I don´t have to kill the ray.exe anymore to close it. Luckily I´ve got Python already installed, when I was checking out the Blender 3d programm. Sadly I haven´t got very far with it. So I have to take a new appoach. But first, I will try the other hints of your post to get the first rendering out of the ray.exe.

gulio
01-24-2006, 10:41 AM
Hello,
after I´ve finished a job and some days where this forum was not obtainable from my PC, I´m back again on this topic.
I´ve had some success with the application of the rayrc file, the ray3rc respectively, which now points to the location of the shader and include folders and a .mi file in which the linkage of the shaders is. (thanks to Vormav once again :thumbsup: )
One of my major mistakes was, that I didn´t know how to run a command line progam properly, that one has to navigate to the location where the . exe resides and than typ the name of the .exe and the name of the file which should be edited. So I just opened the command line window, via doubleclick on the ray.exe Icon, and got lost somehow. I thought this was equivalent to the approach of GUI Apps which one opens and then open a file to edit.
So now I can follow the examples of the book and render the scenes described. I hope this may help anybody sometime in the same situation, and I´m pretty sure that the next questions are not too far away in the future. :)

Fess
10-25-2006, 02:25 AM
Rise.........rise........rise from the dead

Time to ressurect this thread.

I'm just got to P. 31 of Rendering with Mental Ray by T. Driemeyer & my bloodpressure's soaring. :surprised


I've tried all combinations but nothing is working with the file from hell...............rayrc

I've installed the mentalRay stand alone that accompanied the book.
Using the cmd prompt, I changed directories & got the following :


C:\Documents and Settings\Administrator>cd \

C:\>e:

E:\>cd Maya\Books\Rendering With Mental Ray\nt-x86\bin

E:\Maya\Books\Rendering With Mental Ray\nt-x86\bin>ray -o output.jpg -resolution
510 510 test.mi
_____________________________________________________________________

This is a restricted mental ray demo version. Disabled features:
- thread and host parallelism,
- loading and saving of shadow, photon, and final gather map files,
- hardware rendering,
- light mapping, and
- resolutions greater than 510 * 510 (even numbers only).
- A mental ray stamp is overlaid.
_____________________________________________________________________
MI 0.0 warn 122001: standard startup file ray3rc not found

LINK 0.0 error 191007: cannot load mayabase.dll, The specified module could not be found.

MI 0.0 error 121417: test.mi, line 9: cannot find $include file "mayabase.mi"

API 0.0 error 301031: test.mi, line 12: call to undeclared function "maya_options"

API 0.0 error 301031: test.mi, line 57: while defining options "miDefaultOptions": call to undeclared function "maya_state"

API 0.0 error 301031: test.mi, line 66: call to undeclared function "maya_directionallight"

API 0.0 error 301032: test.mi, line 82: while defining light "directionalLightShape1": undefined shader "directionalLightShape1:shader"

API 0.0 warn 302029: test.mi, line 84: while defining light "directionalLightShape1": light has no light shader

API 0.0 error 301031: test.mi, line 92: call to undeclared function "maya_lightlink"

API 0.0 error 301031: test.mi, line 96: call to undeclared function "maya_shaderglow"

API 0.0 error 301032: test.mi, line 130: while defining camera "perspShape":undefined shader "shaderGlow1:perspShape"

API 0.0 error 301031: test.mi, line 146: call to undeclared function "maya_lambert"

API 0.0 error 301031: test.mi, line 179: call to undeclared function "maya_shadow"

API 0.0 error 301031: test.mi, line 188: while defining material "initialShadingGroup": call to undeclared function "maya_shadingengine"

API 0.0 error 301032: test.mi, line 192: while defining material "initialShadingGroup": undefined shader "lambert1:shadow"

API 0.0 error 301031: test.mi, line 336: call to undeclared function "maya_lightlink"

E:\Maya\Books\Rendering With Mental Ray\nt-x86\bin>



The result were the above errors & the a output.jpg for my trouble.

Looking a the lamrur.org's stand alone tips (http://www.lamrug.org/resources/standalonetips.html), I can infer I'd copy my .rayrc file and append or replace the information as in "METHOD 1".

The problem is I don't understand what to append or replace.

To be detailed in this post, here is original .rayrc file:


#*****************************************************************************
# Copyright 1986-2003 by mental images GmbH & Co.KG, Fasanenstr. 81, D-10623
# Berlin, Germany. All rights reserved.
#*****************************************************************************
# Evaluated at startup time of the plug-in to fill the mental ray registry.
#*****************************************************************************/

registry "{MAYABASE}" value "D:/Program Files (x86)/Alias/Maya6.5/mentalray" end registry

registry "{SYSTEM}" value "windows" end registry
registry "{DSO}" value "dll" end registry

$lookup "{MAYABASE}"
$lookup "{SYSTEM}"
$lookup "{DSO}"

registry "{MRMAYA_START}"
link "{MAYABASE}/lib/base.{DSO}"
link "{MAYABASE}/lib/physics.{DSO}"
link "{MAYABASE}/lib/mayabase.{DSO}"
link "{MAYABASE}/lib/contour.{DSO}"
link "{MAYABASE}/lib/subsurface.{DSO}"
link "{MAYABASE}/lib/mi_openexr.{DSO}"
mi "{MAYABASE}/include/mayabase.mi"
mi "{MAYABASE}/include/base.mi"
mi "{MAYABASE}/include/physics.mi"
mi "{MAYABASE}/include/contour.mi"
mi "{MAYABASE}/include/subsurface.mi"
echo "mental ray for Maya - startup done"
end registry

$lookup "{MRMAYA_START}"



To specifically load the mayabase.mi and link the mayabase.so, I have to append or replace this to the existing file .rayrc? :


registry "{_MI_REG_INCLUDE}" value "/pathToMayaIncFiles" // never heard of "INC" files, where would I find them? Are they the files in the 6.5 folder?
end registry
registry "{_MI_REG_LIBRARY}" value "/pathToMayaShaders" // is this the path to my shaders in 6.5 folder or to the shaders in the Mental Ray Rendering folder?
end registry
$include "mayabase.mi"
link "mayabase.so"



Apologies for this lengthy post, but I need to be detailed to relate my issue.


Any advice is much appreciated.

Stressed :banghead:
Fess

mustan9
10-25-2006, 01:25 PM
The standalone version of MR does not come with the Maya extensions used by the MayaToMR converter. So if you try to render a MI file generated by Maya you will have to remove all the references to the MR DLL's and Maya MI files.

There is a standalone version of MR sold by Alias (now Autodesk) that works with Maya. It comes with all the missing MI and DLL files that your errors are reporting.

The standalone version that comes with the book (I'm just guessing, because I don't have the book). Is most likely setup for manually editing MI files, and submitting them. Files created by hand will not have references to the Maya extra's that come with the Maya MR version.

You will have the same problem if you generated MI files from 3D Studio Max, and SoftImage XSI. You need to strip out the extra add ons these applications need in order to render the images.

P.S. I hope this is all correct information. I haven't worked with the standard alone in a while.

Zbuffer
10-25-2006, 04:01 PM
HI,

you only need to change the line:
registry "{MAYABASE}" value "D:/Program Files (x86)/Alias/Maya6.5/mentalray" end registry
to reflect the location of you MAYA installed directory

Fess
10-26-2006, 09:00 PM
You need to strip out the extra add ons these applications need in order to render the images

matt, thanks for posting. How would I go about "stripping" out the extra add ons?



you only need to change the line:
registry "{MAYABASE}" value "D:/Program Files (x86)/Alias/Maya6.5/mentalray" end registry
to reflect the location of you MAYA installed directory

Zbuffer, thanks for responding, I tried that and no workie :cry: .


:sad:

mustan9
10-27-2006, 02:42 PM
HI,

you only need to change the line:
registry "{MAYABASE}" value "D:/Program Files (x86)/Alias/Maya6.5/mentalray" end registry
to reflect the location of you MAYA installed directory

I would think that the demo version of the standalone MR that comes in the book won't load extra compiled code such as the Maya extensions. If it did, then people could just buy the X number of books, and get a fully working MayaToMR render farm.

mustan9
10-27-2006, 02:47 PM
matt, thanks for posting. How would I go about "stripping" out the extra add ons?

I haven't done this in a while. So I may be incorrect, but I think it's something like this.

You need to load your scene in Maya, and then export it to MI using the popup dialog for the MayaToMR converter. Then in the popup you want to select just the basic elements. Such as geometry, cameras, lights and shaders.

After you've saved the MI file. You need to load them into a text editor, and remove the extra Maya references.

NOTE: There is another MayaToMR converter plug-in you can get for Maya. I forgot what it's called, but it does all this automaticly for you. It can generate a clean MI file that will run with the "commercial" version of MentalRay from Mental Images. (i.e. not the special MR standalone sold by Alias). I think this converter is free, but I don't remember the name.

CGTalk Moderation
10-27-2006, 02:47 PM
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.