PDA

View Full Version : custom MRShader doesnt displace in Maya batch render !! Help !!!



rohitwesley
June 21st, 2012, 14:29
Hi,

I have created an algorithm based MR shader that creates an ocean displacement over an object based on Jerry Tessendorf's paper .
The shader calls a pure c++ class that calculates the ocean for every frame . I am not able to get it to calculate the ocean every frame when I batch render in maya . But get the result when I do a view port render. There is no error message it just doesn't calculate for every frame but takes the value of the 1st frame . Anyone who has any ideas as to why I am facing this problem ?
Your help is much appreciated.

cheers and a big thanks

bart
June 22nd, 2012, 07:07
A batch render at the command line of the same machine that it works on inside of Maya? For example,

Render -r mr <some maya scene>

How is the shader determining the frame number?

steve
June 22nd, 2012, 13:54
I am not able to get it to calculate the ocean every frame when I batch render in maya . But get the result when I do a view port render.


That's a case of animated displacement, which is handled in special ways in mental ray for Maya, and mental ray in general. Expensive operations like tessellation are performed on demand only. This means, if there is no hint that the geometry (Maya "shape") is actually animated mental ray will re-use the tessellation from the previous frame. If there is a displacement shader attached then this shader should be "known to be animated" as well.

If you use Maya's animation tools like "key frame" on your custom shader then animation should be detected automatically by the plug-in (your node should display as a slanted box in hypershade/hypergraph). If your shader determines animation internally only, you would need to "mark" it as animated. Simply "key framing" one of its attributes without actually changing the value should do the trick. Alternatively, you can add a dynamic attribute to the shape node to force displace animation, see mental_ray_for_Maya_rendering_Dynamic_Attributes (http://download.autodesk.com/global/docs/maya2013/en_us/index.html?url=files/mental_ray_for_Maya_rendering_Dynamic_Attributes.h tm,topicNumber=d30e655757).

mental ray's .mi syntax provides the "touch" command for similar purpose.

Hope this works for you. Best, Steve.

rohitwesley
June 26th, 2012, 11:06
Hay thanks for the reply's, I have tried what you said and still no difference .
I have an attribute called 'time' on my ocean node and it has to be keyed to get the animation as it has to change for the ocean class to be called for computation. Yes the node there for is displayed as a slant box in the hypershade. I tried adding both the miAnimated and the miDisplaceAnimation node and putting them on and still no animation. Also I have connected the shader to maya's default vector displacement node (maya 2012) and not the MR displacement attribute of the shader as I need a vector displacement . I have tried this on a few different machines using maya 2012 . Also since I am coding in c++ express I am using the 32 bit versions of maya for now .

steve
June 26th, 2012, 12:50
I tried adding both the miAnimated and the miDisplaceAnimation node and putting them on and still no animation.

I guess in your case the attribute "miDisplaceAnimation" on the shape node (not the shader node itself) is necessary. I wonder what else could be different to the built-in Maya oceanShader, which does pretty much the same thing: driven by a time node and plugged into the displacement slot.

If you export your scene to .mi file it should contain the "touch" statement for the geometry in every frame.

Best, Steve.

rohitwesley
June 26th, 2012, 15:16
I have exported the file as a .mi file and yes it has "touch" for every frame. Could this be that maya is not calling my c++ class every frame and if so is there a way around it. Also I had assigned the miDisplaceAnimation to the shape node . Any other ideas !!!

I do have one more question to add . My class stores hight values for a 512 x 512 matrix(can be changed depending on processing power) but there are more points on the geometry then that what would you suggest to make it smooth out and calculate the remaining values without using the mental ray approximation editor . I would rather do it in my code by adding something like the Catmull-Rom Splines equation to find out the in between's . Is there a way to get the total number of points on the mesh ahead of time for instance ?

thanks a tone ,
wesley

steve
July 4th, 2012, 17:43
it has "touch" for every frame. Could this be that maya is not calling my c++ class every frame


To debug, I suggest you let your shader print a message when it gets called by mental ray.



Is there a way to get the total number of points on the mesh ahead of time for instance ?


Yes, should be possible, although not really fun ;-)
Is there a reason you need to precompute into a fixed size height field ? Normally, displacement shaders compute a value on-the-fly for the given input point on the surface.

Best, Steve.