Mental Ray - Shaders


#541

hello:thumbsup:

I’ve received some info through a mental ray shader, mailling group on mental ray tag feature. I’m not too sure i understand any of it, but here’s what was asked and a professionals reply

Question

I’m new in MR shader developement. I work on Maya 5.01 using MR 3.2 How can I get the shader associate with a parameters in a shader ?

Answer

Short answer is that you can’t. mi_eval_* evaluates the connection for you automatically. It was a design decision of mental images not to expose how this works internally nor let you travel around the shading network tree as you are bound to be wanting to do very bad things, most likely.
Yet… if you want to live very dangerously…I’ll tell you how :
You can find out if a shader is connected at all with something like:

template< typename T >
inline bool connected( const miState* const s, const T& p )
{
return (!(s)->shader->ghost_offs ? false :
(!((miTag)((char*)(&p)+(s)->shader->ghost_offs)) ? false :
true));
}

you use the function like ( I hate c pointers, that’s why I tend to code in c++ whenever possible – use a macro if you hate c++):

if ( connected( state, params->color )
{
{

If you also see mi_eval() in shader.h and you will kind of understand how you could perhaps get the tag you want.

Potentially, my guess is that the expression: ((miTag*)((char*)(&p)+(s)->shader->ghost_offs) is returning a pointer to the miTag of the shader you need.
But I would not trust it to keep working in future versions as it is undocumented.
Perhaps the question is why do you need to do that (ie. what are you trying to achieve in the end)?
And if you really, really have to, why not pass the shader name from maya directly as a shader parameter and then you can do a simple mi_api_name_lookup, perhaps, as that is indeed documented.

  • I know this appears to be maya related, but i’m sure the same basic code applies to max aswell.

I hope this helps ! :applause:

Philip Bruton


#542

hello

Pholical9 told me how to add an avatar to my name, but i can’t do this
I followed your guide, my profile, edit options but this is all i get here is a message saying :

      "choose your avatar from the available list"

              "Displaying avatars 1 to 0 of 0"

how do i get a list?
This is doing my nut, let alone mental ray !!!

Philip Bruton


#543

Jim_uk, take your glass render into photoshop and hit it with a sharpen filter and it should look identical to mine. :thumbsup:


#544

philipbruton:

You can’t add an Avatar until you’ve posted at least 25 times (according to the CGTalk moderator/webmaster).


#545

Jeff I gave that new paint mat you just posted a run, not bad at all! :beer: I did some tests before applying it to my car, I found that with the IOR of 2.5(what it was set at when Dl’d) it wasn’t giving me much reflection at all. I turned it up, probably too much, and did a render of the Rolls. The IOR is about 4.2, a bit too reflective now, but the render gives the idea. The renders you posted were they with the ior set at 2.5? Just wondering if I was doing something wrong;) I also applied your tire rubber material to my tires…looks very good! Anyway, I did have to apply mapping co-ords for the paint, the first car render had an area of splotchiness. Here’s the link for those interested in seeing it applied to a model.

http://zneekinround.250free.com/speckgood-02.jpg

Thanks again for all of the info!

Todd


#546

Hey guys, is it possible to bake textures with mental ray in max6?

I know it is possible in MR for Maya…


#547

I found a little Max/MR/this-thread related prob:

Draw a spline and add a Lathe modifier so it becomes geometry. Then apply the Black Paint material found in the CGTalk matlib and hit render. MR should crash and Max shuts down upon translating the scene. So far this only happens this material but it might flag a problem with typically Max related geometry and MR. Weird thing is it only happens with the black_paint material assigned. I also noticed a weird little bug where sometimes Max Material Editor doesnt show the specular spot of the black_paint material in the slot.

You might be able to replicate the mat editor bug by doing this:
Open scene
Open Mat Editor
Get Black Paint from matlib
Close scene
Open Scene
Look for lighted specular dot on blackpaint material in mat ed slot. If it aint there, press the show background button on the mat ed panel. It should show up now.

With me it doesnt happen all the time thoug :confused:

You can work around the crash render bug by collapsing the geometry.


#548

:thumbsup:

thanks bobg

Phil b


#549

hello grooveholmes

you cannot use the max texture baking facility with mental ray, it isn’t supported. Although mental ray does support its own light maps and the ā€œwrite light mapā€ shader is available in one of the .mi files in the include folder, i can’t remeber which. it needs unlocking though, and i haven’t been able to successfully use it myself yet, still testing

Phil b


#550

Thanks folical9 :slight_smile: I was looking for the solution from the render settings and it was a photoshop thing all along … hehe

Sometimes the obvious answers just go unoticed :stuck_out_tongue:


#551

Ok… Thanks for the speedy reply.

Do you know of a workaround then for baking textures in a scene that has Reflection, refractions, and Caustics?


#552

Originally posted by folical9
[B]I’ve added some new materials to the .mat file. Metal flake paints and another metal and tire/rubber texture.


[/B]

What is your lighting/rendering setup? I can never seem to get anything to look good! would you mind posting some pics or possibly the scene?


#553

Originally posted by Grooveholmes
[B]Ok… Thanks for the speedy reply.

Do you know of a workaround then for baking textures in a scene that has Reflection, refractions, and Caustics? [/B]

Grooveholmes,

it’s not very usefull to texturebake reflections and refractions imo,
unless you do not move the camera position that is :

cause the reflections and refractions will be different each time you move the camera :shrug:

so i suggest u use the lighttracer (supports textbaking) to bake the lightning of the scene and render reflections and refractions on the fly.
caustics are not supported with lighttracer, but you can allways do a topview render in mental ray and replace the texture from your groundplane you made in lightracer…

hope this workaround can help…

cheers :smiley:


#554

this seems VERY nice
i downloaded the mat file but: how do i aply the content of that files to my models? sorry im totaly new to mental ray

edit: i opened the mat file, aplied one of the ā€œtexturesā€ to my object
now how do i config mental ray please? my rendering is ā€œnormalā€ red


#555

Todd, the car’s looking good man. I would love to see that car sitting on a drag strip about to launch though. :thumbsup:

Edit: Also, yes the renders I made (trans-am), had the IOR at 2.5. Maybe the HDR that I used is a bit brighter and thus reflected more?

OCT, just grab one of the many scenes that I’ve posted in this thread to see the setup for those renders. It’s just a sunlight system and final gather with an HDR in the environment slot for reflections.

Jeff


#556

Alright, thanks man!

Cheers :beer:


#557

Hi,

I’m wondering if people have a solution to the following problem - I have a particle system that has to render as a transparent cloud. Then I have a surface with reflection in the scene. For render time and other reasons I don’t want the particle system reflected. But turning off reflections on the particle system also turns off spawned refraction rays (even if IOR==1.0) which are neccessary to render the layered particles. To complicate matters further it’s inside other fog like volumetric effects which do need to be reflected. Any way I can get the control needed ???

update: turning off the reflection/refraction flag in the global events properties (the one at the top of the event chain) does the trick. I could have sworn I verified this didn’t work, but that was in a more complicated setting using MR only materials. I’ll update here again if I can characterise the behaviour more fully…

update2: the key was the fact that the particles were encased in another volume. When they are inside a volume you have to turn on ā€œautovolumeā€ for opacity mapped faces to work properly and it’s at that point that turning off reflections/refractions stops the particle system itself from rendering. Any comments/ideas ?

max file

Updated max file where particles are inside another volume (lume mist) …
max file

-Drew


#558

i’m having trouble rendering a scene with a mr metal shader reflecting a hdri file, the final gather just crashed when it trys to render the camera’s body.
i’ve tried lower rays (50) for the FG setting, now the FG doesnt crash but the render takes 6 hours on a 800x600 rez. i’m not using GI in the scene. is the a way to speed things up?
i’ve tried to turn off the skylight and use a spot and omni to make it less heavy on the rendering.
the camera’s body has a mr metal shader with samples on 25 maybe thats too high but thats how it doesnt look grainy
:cry:
and another question about the FOV quality, the back of the background is out of focus but the quality is really bad, i’ve tried higher smaple still looks bad:hmm:


#559

Shakey, I’m no expert, but I would tend to think it is the material that is causing your woes. Is the material you are using 1 of the mats featured in this thread? I would say to test it, try changing the mat to something different and render.
As far as your background, from my limited experience, HDR files almost always look blurry when in the environment slot, it has nothing to do with your FOV settings AFAIK. You could either, build some background elements to obscure the hdr from the cameras view, or you could place the hdr in each materials reflection slot, and not in the environment slot. The second option should result in your object reflecting the hdr, but the map will not be seen as your background when rendered. Oh you could also use a high camera angle that would eliminate seeing the hdr as well. I’m sure others will offer some solutions as well, hope this helped.:thumbsup:

Todd


#560

One of the best threads ever done!!!

Simply amazing work and studies, congrats to all, even tho I’m not a Max user now we all have a common language, mRay one.

So cool!!! :love:

I bow to you all :bowdown:

Cheers,
dg