View Full Version : Fluid slice / sample rendering
I need to make sample renderings from a fluid. So I have to get slices from a cached fluid, parallel with 1 side, and render all those slices. I made a script that's making it with fluid extend command, but that's "physically" altering the fluid, so the shadows are lost. Camera clipping planes are not affecting the fluid. With the fluid paint tool I can get slices, that's close, but it's only displayed in the viewport, not renderable. Does anyone have other ideas?
03-22-2011, 01:43 PM
Maybe create a 2D Fluid with the same resolution as the slice, and copy the density values from the 3D Fluid to the 2D one with an expression, maybe using the current frame as the index for the z-position in the 3D Fluid so you could batch render it?
i.e. frame 1:
voxel (1,1,1) --> voxel (1,1)
voxel (1,2,1) --> voxel (1,2)
voxel (1,3,1) --> voxel (1,3)
voxel (n,n,1) --> voxel (n,n)
voxel (1,1,2) --> voxel (1,1)
voxel (1,2,2) --> voxel (1,2)
Not sure if it would work but it's an idea
03-22-2011, 09:22 PM
You could look at the script "bakeFluidShading.mel" included with Maya. This samples one fluid with the internal lighting and texturing into a second that is just density and color with no lighting( yet looks roughly the same ). You could modify the second fluid to be a planar slice and create a render sequence script marching through the fluid.
(or perhaps instead do a playblast where you've animated the paint slice tool positions).
Hi Duncan and Eaclou,
many thanks for the replies!
Eaclou: nice idea, I will try it!
Duncan: even better thanks! Looks a way to go. By the way I found out, that camera near clip is affecting the fluid, but the far clip isn't (mental ray). Is it a bug, or I'm just missing something?
03-22-2011, 11:07 PM
I hadn't thought of using the clipping. It could work OK I think if you render the fluid with the Maya renderer (autoRenderClipPlane off). Have the fluid completely against the background with no objects... if you have any objects they do not get fine clipped by the far clip, and the far clip for the fluid in those regions would be the object surface. If you need shadows from objects, then turn off their primary visibility.
Mental Ray does not seem to do a fine clip on the far. It will far clip at the level of triangles which is better than maya where the far clip is at the object level, but neither render will far clip at the pixel level. However the maya renderer does seem to far clip in terms of volume sample depth. (perhaps there is some sort of fine-far clip option one can enable for Mental Ray somehow, but I'm not aware of one) ... note that I think this far clip behavior is not a bug but rather just the renderer doing things in a more optimized way. (fine clipping can be slow depending on the method used)
At any rate you should be able to render your slices by animating the near/far clip and rendering with the Maya renderer.
Just hit this problem. Is there anyone that found the "magic" setting that Duncan suggested?
With very high resolution fluid, the other ideas are not very practical, neither render in maya software for pipeline issues (in my case).
07-05-2011, 07:55 PM
If you need to render in Mental Ray, I don't know if anything will make the clip method work.
Another option might be to texture part of the fluid transparent with a projection map:
However this method would also make the hidden parts not affect the shadows. (if you are rendering layers to depth composite then this would not be so good, and the only solution I know currently is rendering with clipping using Maya SW)
07-05-2011, 08:19 PM
While I'm thinking of it, another method occurs to me, but it also requires rendering with Maya sw renderer.
One can assign the fluid a surface shader on a plane and hide the fluid shape. The fluid outColor needs to connect to the shading groups surfaceMaterial, not the volume materal, so you might need to make that connection by hand.
Then on the fluid there is a hidden attribute you can set using setAttr: "surfaceShaderDepth".
The plane acts like a window into the fluid and the surfaceShaderDepth is the distance into the fluid one can see through this "window".
Then one could simply animate the plane moving away from the camera to get depth slices. (although to be honest, the clipping method is probably easier and more foolproof)
thanks Duncan for the quick reply. The second idea is very interesting, I have to try it asap.
In the meantime (I was in a rush for that shot) I solved by using a polyplane with surface shader at the same distance where the far clipping plane is supposed to be. The near clip plane works fine, so I use just that.
Not a very clean way, especially if you have a stereo cameras, but it solve the problem, at least in my case.
07-06-2011, 11:52 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.
vBulletin v3.0.5, Copyright ©2000-2015, Jelsoft Enterprises Ltd.