PDA

View Full Version : Convert XSI MentalRay shader to Max?


ExP
11-03-2005, 08:53 PM
Hi everybody,
I'm currently working on some effects for a film and I'm having some problems with lens distortion.
The person responsible for the 3D tracking of the BG plates used a program called 3D Equalizer and exported the trcaking data to 3dsMax (the app I'm using for the 3D effects).
Now in order to handle lens distortion I need to render my elements using the appropriate lens parameters that will match the BG plates.

I did some quick research and I found a MRay shader that computes accurate lens distortion, but it's compiled for XSI MentalRay and not Max.
The shader comes with a .dll file of the actual code and a .spdl for the XSI UI declaration.

I know the .dll should work in MRay for Max, but is there an easy way to convert the .spdl to a .mi declaration for max?


Here's a link to the XSI shader:
http://www.alamaison.fr/3d/lmWarpDistort/lmWarpDistort.htm


I've also found this:


how can i convert a shader from XSI to max????
export to mi file. until xsi is based on spdl, the mi declaration file cannot be $include(d) within
the exported file, so xsi has to do his own conversion from spdls and put them directly into
the mi scene file.. basically copy and paste the declarations there into a new mi
file and give it the name of the function(shader). take care that mentalray may read
also spdls directly.


But I'm not sure how to do it, and I don't have access to XSI right now...

Any help is deeply appreciated!

Thanks

Saturn
11-04-2005, 07:44 AM
use this mi file and it will work in MAX.

Remove the .txt in the name.

ExP
11-04-2005, 07:03 PM
Hey Saturn,

Thank you so much for your help!! This is going to solve a lot of problems for me!
Cheers

chris_b
11-05-2005, 01:15 PM
Did you consider maybe removing the distortion from the plates before matchmove (I think that 3D Equalizer has built in tools to remove lens distortion)? You can always re-introduce some lens distortion in post (to the comp) and that way avoid extra (expensive) calculation steps during your render in MR. Just thinking out loud :)

Saturn
11-05-2005, 05:40 PM
well the big advantage to MR to do the distortion instead of the post effect is that are ryour more accurate. MR do the sampling and AA the CG. Post you will stress your image and you need some sub pixel calculation that can lead to an expensive calculation.

Plus you don't get double file to manage ( in the case of if you don't to degrade the original footage ).
Add to this that you don't have to render a bigger image to compensate the distortion.

In fact it 's more efficient to do througth MR and this shader is very fast and can work in scanline mode !

Splin
11-05-2005, 07:46 PM
hmm do the alamaison guys have also link to their central shader repository where all shaders are listed? At first I thought they only have released that motion blur verctors shader but now, bum, they have also released some other stuff!

ExP
11-05-2005, 07:52 PM
Hey chris-b,

I strongly agree with Saturn on using the lens distortion at render time. Here are the problems you may encounter otherwise:

- I think removing the distortion before tracking is not a very good idea. 3DE and many tracking software try to reconstruct the real world camera used to shoot the scene. Now if you introduce a perfectly "flat" undistorted lens, you may have problems with your FOV, gate width, and focal length not matching your real lens. This can easily lead in inaccurate tracking and more problems later on.

-Also, the real MAIN problem is that when you have a positive distortion value (pillow effect, common in most wider angle lenses), as you distort tour BG plate or CGI element, the sides of the frame are "shrunk" and you suddenly have a nice black border around your image!! (not very pleasant if you need your entire FOV).

P.S. Saturn, rendering a bigger image to compensate, is not as easy as it seems. You would have to either move the camera back, or change the focal length, and try to increase the output size accordingly. This can easily compromise the accuracy of your tracking.

-Finally, like Saturn said, there is the "quality" factor, or rather a "loss of quality" when you distort your elements with a post effect with the additional file management problems.


Hope any of this makes sense...

Cheers

chris_b
11-05-2005, 08:23 PM
Hmm.... it certainly does make sense. I stand corrected and with lens-shader in hand should the need arise :) Thanks for taking the time to go over the pros and cons.

Saturn
11-06-2005, 11:21 AM
Hey chris-b,

- I think removing the distortion before tracking is not a very good idea. 3DE and many tracking software try to reconstruct the real world camera used to shoot the scene. Now if you introduce a perfectly "flat" undistorted lens, you may have problems with your FOV, gate width, and focal length not matching your real lens. This can easily lead in inaccurate tracking and more problems later on.

Cheers

I strongly disagree with that. You have to remove distortion to match wireframed viewport with images until we get a real time distortion on viewport. Otherwise your reconstruction will be false ( at least compared to reality ). But yes you will not obtain the same FOV, i don't touch focal but i compensate it with a new calculated filmback ( or gate width ). And a perfectly "flat" images give you definitively a better geometry reconstruction and a better camera path.

ExP
11-06-2005, 07:16 PM
Hey Saturn,

What I meant is, I don't like to remove the distortion before CAMERA TRACKING, but OF COURSE I remove the distortion form my BG plate as I reconstruct my scene in the 3D animation app.

Here is my workflow:

-Camera tracking in a tracking software like 3DE (the BG plate in NOT undistorted yet, I've no idea how you can remove the distortion before, unless you have VERY precise info about your lens and accurate lens distortion grids shots form the shoot, which is never the case...)
-Export reconstructed camera data into 3D Animation package
-Distort BG plate with the calculated lens distortion from 3DE (using a lens distortion post filter)
-Import Distorted BG plate into 3D animation app as a BG image
-Render CG elements with lens distortion shader
-Comp distorted elements with original undistorted BG

Take care.

Saturn
11-06-2005, 07:54 PM
What I meant is, I don't like to remove the distortion before CAMERA TRACKING, but OF COURSE I remove the distortion form my BG plate as I reconstruct my scene in the 3D animation app.


We are in phase ! I said nothing :beer: .

By the way we have an inhouse tools based on 3DE lens model and we impose to get grid for distortion so we have a precise known of the lens.

We had to make this tools because 3DE ( So far the best tools if you ask me ) is discontinued on windows and i use realviz machtmover instead.

have a look to my reel : http://perso.wanadoo.fr/harry.bardak/MM_Showreel.htm we got the same workflow.

ExP
11-08-2005, 08:23 PM
Hey Saturn, glad we are on the same page.

Somehow I wasn't able to see the QT video, but your resume is very impressive. You really are a lens distortion specialist!

Your in-house lens distortion tool semms like a very helpful add-on to have.

About grid distortion references, you're right, they're very important. I guess I was speaking too much about my current situation as we are working on complex tracking shots that where not even supposed to be VFX shots during prodiction. Now we find ourselves without grid shots or any camera info.

Saturn
11-08-2005, 08:45 PM
damn it :

try the direct link :
http://perso.wanadoo.fr/harry.bardak/video/MM_showreel_2005mm_light.mov

I have to fix that. Do you use Firefox or something like this ?

we are working on complex tracking shots that where not even supposed to be VFX shots during prodiction.

So true so true ! I have a lazzy VFX supervisor here and sometimes i have to call the shop where you hire the lens series to get wich one was used.
It can be so frustrating sometimes.

CGTalk Moderation
11-08-2005, 08:45 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.