PhysX Fluid Demo (Modding)
From PhysX Wiki
- This article is about modding the PhysX Fluid Demo. For information about the demo itself, see PhysX Fluid Demo.
This guide is based around the basics of modding the PhysX Fluid Demo. It turns out that even though the demo was never intended to be modded, the nature of the non-proprietary file formats allows for it to be easily possible. It's as simple as replacing any file outlined in the How To category.
The only limitation you have at creating a new scene is the polygon budget, the size of the scene and the fact that all geometry will remain static. Even with these limitations, it's still possible to create some interesting levels. Such as a sewer, a street or even a beach of some sorts.
This guide assumes the reader has some knowledge of 3D Modelling. It is recommended to use any 3D application capable of exporting directly to .obj (Wavefront), since this is the kind of work that encourages quick prototyping and testing.
Blender is a free 3D application that is capable of exporting directly to .obj.
The 'source files' are located in the installation directory, located at:
- 32-bit OS:
Program Files\NVIDIA Corporation\NVIDIA PhysX\Demos\Fluids
- 64-bit OS:
Program Files (x86)\NVIDIA Corporation\NVIDIA PhysX\Demos\Fluids
It's recommended to create a desktop shortcut to the PhysX Fluid Demo directory for quick access. Also, it's not a bad idea to backup this directory, if you want to save yourself from re-installing for whatever reason.
In the directory you will see all of the texture files, and also the original models. It is possible to mod both scenes. The “Logo Scene” can be modded further by generating a new “positions_logo.txt”. Either by manually typing each position of every particle, or by using some kind of tool that can automatically generate this (coming soon-ish).
In order to mod the demo, it’s simply a matter of modifying any file visible in the following table:
|corridor.bmp||Texture||Outdoor||Base texture map used to encompass all of the geometry|
|corridor_n.bmp||Normal Map||Outdoor||Bump map used for first scene|
|corridor_new.obj||Model||Outdoor||Model used for rendering|
|corridor_new_collision.obj||Model||Outdoor||Model used for collision. It contains simpler geometry to maximize performance|
|ground.bmp||Texture||All||Texture used for the ground plane|
|nv_logo2_invert.obj||Model||Logo||Used for both rendering and collision|
|positions_logo.txt||Text File||Logo||A text file containing the position of every particle to be used|
|sky_negx.bmp, sky_negy.bmp, sky_negz.bmp, sky_posx.bmp, sky_posy.bmp, sky_posz.bmp||Skybox Texture||All||Six images, which are used as the skybox|
|wood_D.bmp||Texture||Outside||Diffuse map used for the crates|
|wood_N.bmp||Normal Map||Outside||Bump map used for the crates|
Remember, these files are found in the installation directory. You can find the path by reading the Introduction.
Modding the Outdoor scene in Blender
A step-by-step tutorial of how to mod the Outdoor scene in Blender. For the purpose of keeping it simple, all that we will be adding is a simple cube, acting as a floor. This tutorial was written for Blender 2.56.0 Beta, for the purpose of being future-proof. Users who are using Blender 2.49 or older can also follow along, however the UI has changed drastically. If you are unable to follow through on Blender 2.49 or below, it is recommended to Download the beta just for the purpose of this tutorial.
|1) Once you start up Blender you will notice there is a cube in the scene by default. With it already selected, press Delete, and lastly press Enter to confirm.|
|2) Click File>Import>Wavefront (.obj)|
|3) Navigate to the Demo folder, select “corridor_new.obj” and click Import OBJ.|
|4) Press the spacebar, type in “Add Cube” and press Enter.|
|5) Click the Cube icon on the right side pane. Change the position of the cube to 5, 6, 3.5 (for XYZ). Change the scale of the cube to 3, 3, 0.1 (XYZ).|
|6) Now we can export it into the demo’s directory. Click File>Export>Wavefront (.obj)|
|7) Navigate to the “corridor_new.obj” file the demo directory, and select it to overwrite it. Uncheck the Material checkbox since this is unnecessary. Click Export OBJ.|
|8) You can now test it by running the demo. It should look something like the image on the right.|
Note that the fluid is clipping right through the box. This is because we only changed the model used for rendering
|9) Now its time to modify the collision model. Press Ctrl+N to create a new scene. Delete the cube in the scene once again by pressing Delete, then accepting with Enter.|
|10) Click File>Import>Wavefont (.obj). Select “corridor_new_collision.obj” and click Import OBJ.|
|11) Press the Space bar, type in “Add Cube” and press Enter.|
|12) Change the position of the cube to 5, 6, 3.5 (XYZ). Change the scale of the cube to 3, 3, 0.1 (XYZ).|
|13) Click File>Export>Wavefront (.obj)|
|14) Navigate to the “corridor_new_collision.obj” file the demo directory, and select it to be overwritten. Uncheck the Material checkbox and click Export OBJ.|
|15) Run the demo to test your final results|
|Download the completed project files|
Modding the Logo Scene
To mod the Logo Scene, you can edit the "nv_logo2_invert.obj" model. On top of that, the "positions_logo.txt" can be modified, allowing the user to create any formation of particles possible.
If you intend for the particles to remain inside of the the model, remember to flip the normals of the object.
Modding a Texture
Since the demo is surprisingly moddable, it's possible to texture your creation by creating a UV map for the mesh. For detailed instructions about how to do this, it would be a good idea to search on the internet for a tutorial specifically made for your 3D application of choice. Eg: Blender UV Mapping.
If you have a very lot of surface area, and you want to have unique texturing of different geometry, you will most likely want a texture file of 2048x2048. Usually this can be a bad idea, however in this case it actually is a very intelligent move, since most (if not, all) graphics cards will have hundreds of free megabytes remaining.
The following table displays the video card's memory usage in the custom map Two Story Building for the purpose of trying out a different texture. Keep in mind that the texture specifications are not combined, and that the Total Memory Usage isn't the memory usage of the demo itself.
|Textures||Total Memory Usage (MB)|
|2048x2048 (12 MB)||388 MB|
|1x1 (58 bytes)||347 MB|
The filesize of a texture doesn't necessarily represent the amount of VRAM that is used, rather it acts as a rough indicator. It is evident that the textures do in fact take up a significant part of VRAM.
Resizing from the default 1024x768 resolution to 1680x1050 increases VRAM usage by 40 MB on average. This is good to keep in mind when budgeting the texture resolution, because effectively a resolution increase is far more memory hungry then a texture upgrade.
Scene scale notes
When importing and exporting a model is that a 3D Application might interpret the scale differently then the Nvidia PhysX Fluid Demo. This can result in exported scenes looking up to a hundred times larger than normal. When the time comes to export you creation to an .obj file, make sure your applications export settings are setup accordingly.
When creating a new scene, it is important to maintain a polygon budget. While there isn't a set in stone limit, it is more of what target system the map is intended for. The budge varies between the render and collision meshes.
Due to the fact that the render mesh can be magnitudes greater in detail that the collision mesh, it is a good idea to keep two versions of the scene while working on it; one with high detailed objects for the render mesh, and one with simplified geometry for the collision mesh.
The render mesh can easily contain more than one-hundred thousand polygons. So long as the mesh is split up into multiple objects. The demo seems to build geometry is such a way, that splitting the render mesh into multiple objects lowers the load time of the demo, and potentially speeding up the rendering task slightly.
The collision mesh should be under a heavy budget, where all small geometry should be simplified for maximum performance. Here are some rough estimates of where the target lies for different hardware levels:
|Target Range||Polygon Budget|
|Low (8600 GT)||1,000|
|Medium (9800 GTX)||5,000|
|High (GTX 480)||15,000|
As opposed to the render mesh, the collision mesh doesn't need to be split into multiple objects, however if possible, it is better to do so.
To speed up the learning process, these templates outline the boundaries and the arbitrary point at which the centre of the scene is located.
The pack contains:
- Outdoor Scene - Emitter Markers
- Outdoor Scene - Emitter Markers (with a bowl)
- Logo Scene - Logo Bounding Box
Download the templates.