Make a splash - inweboftp

Oct 24, 2006 - photograph of a water droplet falling into a larger body of water, controlling ... since this may lead you in the wrong direction. 02. Although you ...
4MB taille 84 téléchargements 431 vues
TUTORIALS | Dynamic fluids

ON THE WEB ● Full supporting files for this article www.3dworldmag.com

REALFLOW

ON THE CD

● RealFlow 4 Special Edition (exclusive to 3D World) SEE PAGE 66

Make a splash

Who needs high-speed macro photography when you’ve got RealFlow? Discover how to use the Special Edition of this powerful fluid simulator on the CD to capture the microscopic world shown above BY GUSTAVO SÁNCHEZ PÉREZ

FACTFILE FOR RealFlow 4 DIFFICULTY Elementary / Intermediate TIME TAKEN 45 minutes ON THE WEBSITE • Full-size screenshots • RealFlow scene files • Final OBJ file • Bonus RealFlow script • Final XSI scene file ON THE CD RealFlow 4 SE ALSO REQUIRED Softimage XSI (optional)

S

ome time has passed since Next Limit

package and render it to achieve a water-like appearance. We’re

released RealFlow 3. Now a new version of

using XSI, but the .obj file is included in the supporting files, so

this multi-platform fluid and dynamics

you could render it in any application you prefer.

simulator, used on Ice Age 2: The Meltdown

The Special Edition has a maximum particle count of

and Poseidon, has arrived – and it comes loaded with cool

50,000, limiting the fine detail that can be achieved, so we will

features. A revamped interface, integrated Python

also provide some tips for refining the simulation in the full

scripting and a massive improvement in stability are just

commercial edition of the software: to upgrade and claim a

a few of the many good things in this new version. These

special 3D World reader discount, turn to page 65.

features make RealFlow 4 the ideal solution for studios faced with the complex task of simulating liquids. In this tutorial, we are going to use the exclusive Special

Full supporting files for the tutorial are available for download from our website, www.3dworldmag.com. To find them, click the Stop Press link from the left-hand menu of the

Edition of RealFlow 4 on the CD to recreate a high-speed

homepage. Further tutorials can be found on the CD itself, and

photograph of a water droplet falling into a larger body of

in the user guide that comes with the software. Consult these

water, controlling the simulation – within limits – to generate a

if you get stuck at any point in the walkthrough.

classic crown-shaped splash. We will start by exploring the basics of fluid simulation, then refining the parameters that

Gustavo Sánchez Pérez is a Spanish VFX artist. Formerly

control the effect that we want to achieve. Once the initial

employed at the Moving Picture Company, he now works

particle-based simulation is complete, we will generate a mesh

for Bren Entertainment, and is co-founder of Barna VFX

to export. Finally, we will import this mesh into a 3D software

www.barnavfx.com

060 | 3D WORLD Christmas 2006

TDW85.t_realflow 060

24/10/06 16:29:10

Dynamic fluids | TUTORIALS

STAGE ONE | Setting up the simulation drop

gravity force splash crown

stillWater container

The first thing to do when starting with a new package is set up the environment to suit your requirements. Start by changing a few basic parameters. Go to the File menu and create a New Project. Call it dropSplash. Go to File > Preferences and set up your Scenes Folder path, then configure ‘Axis setup’ for the 3D package you are going to use later.

Now that you have the environment set up, think about what other basic elements are needed to create the simulation. A drop, a volume of still liquid, a container, and a gravity force should be enough to get things moving. The final simulation may end up more complex than this, but it’s best not to start from a complicated set-up, since this may lead you in the wrong direction.

Create a Fill Object emitter in the same way and rename it stillWater. Add a Cube to the scene (Edit > Add > Objects > Cube) and rename it ‘container’. Make it 10 units long in every axis, then move it six units in Y. You need to connect the container to the water that fills it, so go to the Fill Object tab and click the ‘-’ next to Object. Select the container from the pop-up window. Set ‘fill Y ratio’ to 0.05.

If you hit Simulate, you will see that nothing happens. That’s because at this stage the scene contains fluid emitters, but no external forces to make them move or interact. It’s time to add some daemons. First, add a Gravity daemon (Edit > Add > Daemons > Gravity). Rename it ‘globalGravity’.

Although you can play cached simulations, it’s easier to export a series of images, then play them in real time. To export screen captures of the simulation, hit [F12] to go to Export Central and activate Preview. Rename it ‘stage_1’ so that you can compare the results to those of future simulations. Set ‘Image formats’ to .jpg or .png. Set the end frame in the timeline to 50 and run the simulation.

Open the captures from the ‘/preview’ folder of your RealFlow project in an image viewer that enables you to view image sequences. Problems quickly become apparent. First of all, you can see that the stillWater is not that still. Second, while there is a splash, it’s really shallow, and dissipates too quickly. It isn’t a bad start, but we can refine the simulation to improve on it.

Begin by getting rid of all the elements in the Global Links panel. Go to Edit > Add and uncheck Add to Global Links. This ensures that new elements are not connected to anything else. Create four groups in the Nodes panel: Emitters, Daemons, Objects and Meshes. Place all the elements into these groups according to their type. Do this from now on whenever you create a new element.

Sort things out by dragging elements into the Exclusive Links tab. First, move the drop itself. Then parent under it everything that affects it: globalGravity, container, and stillWater. Now drag and drop the stillWater element and parent drop, globalGravity and container under it.

01

04

07

02

05

08

Start by creating the emitters. Begin with a Sphere emitter: select Edit > Add > Emitters > Sphere. Rename it ‘drop’. Modify its Scale to 0.5, go to the Sphere tab and set ‘Fill sphere’ to Yes. Position the drop high in Y: around 9 units is appropriate.

03

06

09



Christmas 2006 3D WORLD | 061

TDW85.t_realflow 061

24/10/06 16:29:21

TUTORIALS | Dynamic fluids

STAGE ONE (Continued) | Setting up the simulation EXPERT TIP

i

Playing with time Time shifting can make it easier to fine-tune a simulation. If you want to save some time while waiting for the simulation to get to a crucial point that is not working properly, you can reduce the time steps in order to get some ‘extra’ speed: click the arrow next to the Simulate button, select ‘Options...’ and reduce the value of ‘Max substeps’. This can be handy when relaxing fluids. Just remember that by doing this, the accuracy of the simulation will decrease: try to strike a balance between speed and accuracy. Wrong time steps can also lead to the entire simulation becoming unstable.

To avoid simulations going haywire, it is wise to add a k Volume daemon. This confines the simulation to a particular area: if any particle strays outside the confines of this area, it is destroyed. Create a k Volume daemon and connect it under both emitters in the External Links tab. Under Node Params, select ‘Fit to object’ and choose the container.

10

You need to adjust a few settings to make the static fluid a bit ‘tighter’ but also to make it react more quickly to the impact. Set Density to 500 and Ext Pressure to 0.1. This will help the water surface react more naturally when hit by the drop. Set Viscosity to about 30, to glue everything together. Set ‘fill Y ratio’ to 0.02 and increase the Resolution to 2. This will give you a large number of particles in a small area. Press Reset to update.

12

EXPERT TIP

Add a k Speed daemon. Connect it to both emitters. Set the Min and Max speeds to 0, and turn on ‘Limit & Keep’. The velocities of any elements it affects will now converge to 0. Reset and press the Lock button. Run the simulation, keeping an eye on the Max and Min speeds of the emitters in the Statistics tab. Once the values get close to 0, stop the simulation, and unlock and deactivate the daemon. Now active the Gravity01 daemon.

13

The impact of the drop on the stillWater surface isn’t violent enough yet. To fix this, add a Gravity daemon that only affects the drop while it is falling. It needs to be Bounded and have a Strength of 100, as in the image above. Set it to be Inactive for now. Make the drop denser by setting the Scale of the sphere to 0.3. Change Int Pressure to 0.1 and Surface Tension to 20. Set Resolution to 10 and hit Reset.

11

Now it’s time to create an Initial State for both emitters. Go to the Initial State tab in each emitter and activate Use Initial State. You will also need to activate ‘Reset to Initial State’ from the Reset button, so that when you reset the simulation it will go back to the saved state when the fluids are relaxed. Reset the simulation to the Initial State and press the Simulate button. You should now see a better looking ‘splash crown’ ready for the next step.

14

i

Ghost the simulation When using low-resolution simulations that don’t take long to load from disk, a good way of keeping track of changes is to use Binary Loader emitters to load the previous simulation in the background. This way, you can compare the results of the new simulation with the previous one to check that your refinements are taking it in the right direction. Just make sure that you don’t export the new simulation while comparing the two and ensure you are exporting it with a different name, so you don’t overwrite the one loaded in the binLoader emitter.

1

2

It’s time to create the mesh. It would be possible to generate a render from the particles that you have been generating already, but RealFlow offers the more useful possibility of creating a polygonal mesh surrounding those particles, so that is what we are going to do next. Go to the mesh icon on the icons bar or select Edit > Add > Mesh to create a new one.

15

Go to frame 15, or any frame that might give the mesh a nice shape. Right-click on stillWater_mesh in the Nodes panel and select Build. Unless you have only one emitter in the scene, nothing will be connected to the mesh and therefore no mesh will be calculated. As you have two emitters in the scene, you need to tell RealFlow which ones are going to be part of the mesh calculation.

16

062 | 3D WORLD Christmas 2006

TDW85.t_realflow 062

24/10/06 16:29:31

Dynamic fluids | TUTORIALS

STAGE ONE (Continued) | Setting up the simulation

Right-click again on the stillWater_mesh node and select ‘Insert fluids’. A pop-up window will appear with all the emitters in the scene. You could hit the All button, but you don’t really need the drop emitter, as it has been mostly dissipated under the surface of the still water. Instead, just select the stillWater fluid and Build the mesh again. This time, a mesh appears, but it’s very blobby.

17

This is to do with the particle count: in general, the higher it is, the closer the mesh will be to the particle simulation. If you’re using the full version of RealFlow, you can increase the Resolution of the emitter without having to resimulate: select the stillWater fluid, set Interpolation to Local, and double the Resolution. Go to Export Central and rename the mesh ‘stillWater_localInt’. Build the mesh again.

18

EXPERT TIP stillWater particles

If you export hi-res simulations or meshes while testing, you will quickly fill up your disk space. By default, every time an element is created, it is configured for export. To solve this, uncheck everything in Export Central before you run the simulations, and only export when you really need to. You can also turn off elements by modifying the Simulation parameter from Active to Inactive, or save time by using the Cache simulation state if the elements of the simulation don’t have to change. All three are options from a drop-down menu in the Simulation parameter on each node.

stillWater Resolution = 2 Interpolation = Global

stillWater Resolution = 2 Interpolation = Local

Open your 3D application and find the three meshes you have generated. Load them one by one and place them side by side so you can compare them in shaded mode. You can immediately see that increasing the resolution may be a good idea for certain types of simulations, but that it probably won’t be the only thing you have to do in order to get the result you want.

20

Ultimately, an ‘acceptable’ result is a matter of personal taste. If you want extra detail, lower the ‘Polygon size’ to 0.01 in the Mesh tab. Build the mesh once again. A more detailed mesh is always welcome, but bear in mind that since the meshes must be loaded from disk at each frame, poly count may become an issue.

23

You need to refine the mesh generated by adjusting some of the settings under the Mesh node in Node Params. Go to the Filters tab and set ‘Filter method’ to Yes. Leave the default values for now. Right-click the Mesh node and select Build. The generated mesh looks smoother, but it is still quite blobby.

21

The final touch while refining a mesh is to activate the Optimize tab. Open it and activate it by setting Optimize to Curvature. This will help to reduce the number of polygons in the geometry, which will help when importing it in your 3D package. Build the mesh once more. Now that it is as good as it’s going to get, you can finally export the file!

24



Select the stillWater fluid under the Meshes node and set ‘Blend factor’ to 80. This parameter helps to add detail by separating particles if they are more than a certain distance apart. You could also modify the Radius parameter – but be careful: if it’s decreased too much with Filter on, the mesh will almost disappear. Set the value to 0.03. Build the mesh again to see the detail it has gained.

i

Things to keep in mind

stillWater Resolution = 1

22

Now try generating a new mesh from the stillWater fluid with Interpolation set to Global. Again, go to Export Central and rename the mesh, this time to stillWater_globalInt. Build the mesh again. For a detailed explanation on how Local and Global parameters work, left-click the Interpolation parameter in the Node Params panel and hit [F1] to get the contextual help.

19

Christmas 2006 3D WORLD | 063

TDW85.t_realflow 063

24/10/06 16:29:39

TUTORIALS | Dynamic fluids

STAGE ONE (Continued) | Setting up the simulation EXPERT TIP

i

Try Python

Open Export Central and check the stillWaterMesh box. (If you want to preserve any meshes you exported earlier, rename the node, but bear in mind that the files quickly eat up disk space.) Check ‘Mesh cache (.bin)’ and ‘Mesh sequence (.obj)’ and close the tab. Go to the frame that you want to render and build the mesh. This will be exported in RealFlow .bin format and also as an .obj file.

25

To see how much space the files take up, and what kind of format you might need if you were exporting a long simulation, open the \meshes folder in your RealFlow project. It’s worth noting that .bin files have two advantages over .obj files: first, they’re smaller in size, and second, if you need to use the mesh UVs, they’re preserved by default.

26

If you are an adventurous coder, you may find that writing your own export formats suits your needs better than using the standard RealFlow ones. This is where Python scripting comes into its own. There is an in-depth section in the User Guide that covers most of the areas you will need to explore, plus an official RealFlow scripting site (www.nextlimit.com/ nlscript) and forum. Don’t be scared: even if you don’t know anything about programming, you can easily pick up the essentials. Learning Python scripting will improve your workflow and make life easier.

STAGE TWO | Rendering the mesh Your 3D app

Your 3D app

Your 3D app

Open the mesh in your 3D package. In XSI, if you are using the .obj file rather than RealFlow’s native .bin file, all you need to do is to select File > Import > Obj File. For details of how to import a .bin file, or for information relating to the other 3D applications RealFlow supports, check the Help documentation.

27

Even in the final render, you will notice that the result is not as close to reality as it could be. Inevitably, the full version of the software – which would enable more particles to be used in the simulation – would produce a better result. Only high particle counts can generate the fine detail that tricks the eye into believing that what it is seeing is real. If you are using the commercial version of the software, there are two ways to increase the number of particles used to calculate the mesh. The first option is to increase the Resolution of the emitters before running the simulation – although this will mean that the new simulation does not necessarily maintain the same look

29

Apply XSI’s Water_Stuff Shader Preset to the mesh. This is the easiest way to get a watery-looking result. Your software will probably have an equivalent, but if not, you could try to find a preset online. You can simplify the shading by using Phong materials and playing around with incidence and transparency, while a good HDRI environment map will help add detail to the render.

28

as the lo-res one. The second option is to generate multiple low-resolution simulations and combine them together using an NBinary Loader emitter to generate the mesh. This way, you can ensure that the original look remains when building the mesh. If you want to try it, the emitterMultisim.rfs script (included in the supporting files for the tutorial, available from the Stop Press section of www.3dworldmag.com) will generate these multiple simulations. To get finer detail, you will have to be prepared to face long simulation times, so the more processing power you can muster, the better. It would also be a wise move to check the recommended specifications for RealFlow 4 before you start, unless you want to risk simulations that go on forever... ●

064 | 3D WORLD Christmas 2006

TDW85.t_realflow 064

24/10/06 16:29:50

Xx