# Tag Info

122

I tried it. Splashes (springs) As that tutorial mentions, the surface of water is like a wire: If you pull on some point of the wire, the points next to that point will be pulled down too. All points are also attracted back to a baseline. It's basically lots of vertical springs next to each other that pull on each other also. I sketched that in Lua using ...

25

Check out how PixelJunk Shooter did it (including simulation) in this presentation (PDF) at GDC2010.

20

The physical basis of the colors of an oil slick is iridescence, and also related to Newton's rings. Specifically, the thickness of the oil layer is on the order of the wavelength of light. Since light reflects from both the top and bottom surface of the oil, at any given wavelength, at some angles the two reflections will be out of phase and cancel each ...

19

I created a system similar to the one you're after in 3D. I have a short video demonstrating the simple mechanics of it here and a blog post here. Here's a little gif I made of the pressure mechanics behind an invisible wall (played at high speed): Let me explain the data involved, to give an idea of some of the features of the system. In the current ...

16

How about simply not permitting this situation? I don't know how you are making your game, but if you detect that the view will be partly underwater, you can force the camera to be above water, and only when the entire view would be below water, you can switch to the underwater view. Depending on how you do it, this could mean that there is an additional ...

11

George Duckett's answer is far more direct and really well presented if you need fully-simulated water in your game. For simulated shallow-water physics with minimal accuracy (less realism, more playful), this image gave me an incredible moment of clarity: http://www.patrickmatte.com/stuff/physicsLiquid/

11

every time I tried to simulate water I just ended up applying a lowpass filter on a texture representing water level. It's very simple to implement but it fails whenever you get massive changes in water level which may generate large waves. In this method there are some places where water always have some constant level, like river ends. in those cases you ...

9

I tried to implement what teodron suggested: void main() { vec2 uv = gl_FragCoord.xy / resolution.xy; float sepoffset = 0.005*cos(iGlobalTime*3.0); if (uv.y > 0.3 + sepoffset)// is air - no reflection or effect { gl_FragColor = texture2D(texture, vec2(uv.x, -uv.y)); } else { // Compute the mirror effect. ...

7

You need to check out cellular automata, and possibly fluid dynamics. Tarn Adams implemented a cell based fluids system in Dwarf Fortress, and those are the tools he claimed to use in an interview I read some time back (and also in 3 dimensions as per your use case). I think for your purposes, cellular automata (self-replication/propagation of water cells) ...

7

For the solution (mathematically speaking you can solve the problem with the solving of differential equations, but im sure they don't do it that way) of creating waves you have 3 possibilities(depending on how detailed it should get): Calculate the waves with the trigonometric functions (most simple and the fastest) Do it like Anko has proposed Solve the ...

6

If you're looking to have not a lot of water move over a terrain, then your best bet will likely be some form of Smoothed Particle Hydrodynamics (or SPH). In this formulation, you simulate a set of particles as they adhere to the laws of hydrodynamics (namely, the Navier-Stokes equations). There is a great series of articles written about this from Intel: ...

6

The problem you are referring to has to do with the camera's view volume clipping through the water plane; typical "underwater effects" are done via full-screen post-process effects, and wouldn't look correct if the view is clipped like this (it would just be the opposite problem). Even if you do bother to detect the clipping case (potentially difficult) ...

6

The formula returns a scalar (the height of the water surface at coordinates x,y), not a vector. It is hard to tell what the authors had in mind, because the paper is very confused, but my guess is that it should have looked like this: Y（x,y,t） = A * cos(w * f(x,y) + wt * t + FI) Where f is a function that controls the shape of the wave. This function ...

5

Note that I've never done this; these are only ideas which may help. Or might be totally bogus. I'd been wanting to tackle this problem ever since Terraria but am not currently working on such a game. A way I've considered trying is to give each surface water block (any block with water in it and with no water block above it) an initial pressure value ...

5

Grant Kot has put some of his fluid simulation code up on Github with implementations in both javascript (canvas) and C++ with OpenFrameworks: https://github.com/kotsoft He has a few demos up on his youtube account: http://youtu.be/HqWheJSEiaw I have no idea how it works, but I know it runs fast and there's all sorts of variations to build with it. A good ...

5

Or, for a quick and easy approach: Use metaballs!

5

To add constant waves add a couple of sine-waves after you have calculated dynamics. For simplicity I would make this displacement a graphical effect only and not let it affect the dynamics themselves but you could try both alternatives and see which works out the best. To make the "splashhole" smaller I would suggest altering the method Splash(int index, ...

5

Disclaimer: I haven't heard of a paper describing how From Dust was done, so this is entirely guess-work. A few things I noticed about From Dust: Anything on the landscape is a fluid (notice what happens when you drop a lot of sand at once) - everything just has different viscosities. You never get overhangs (at least on my computer) - this would be a ...

5

I only have some mild knowledge in unity, but here are some suggestions I hope you find useful. Split the whole simulation into a few things: Large waves Medium waves Small waves Boat's reaction water Water's reaction to boat The first two can be done by moving a tiled displacement map over a plane mesh. You have a large, low detail map which represents ...

5

You have incorrectly implemented the formula as a function. The function is missing + 1 after the call to Math.sin(), which moves the wave to the range [0, 2]. Regarding your second problem, I don't see anything wrong. In fact the screenshot looks exactly like it should and seems to match the plotted curve. Try with k=10 and you should see the difference ...

5

Why are all three lines of the formula seperated by commas? P(x,y,t) is a vector valued function. Its values are thus 3D vectors. The commas just separate these components, probably akin to a Matlab style of coding. D refers to a directional vector (i think) D is a 2D vector in the (x,y) plane. It describes the direction (and magnitude, if not ...

4

In a nutshell, what makes a shallow water equation a shallow water equation is that the water height is not zero and it assumes no variation in the seafloor. Note: No fluid dynamics equation will allow for a water depth of 0, as that would mean you have no fluid. You should read the Wikipedia article on the shallow water equation. Basically, in shallow ...

3

While I don't think they'll give you what you're asking for out of the box, you should definitely check out these two classes because they might be able to get you something very close. CCShaky3D & CCRipple3D Play around with those effects and see if you can get close. If you can't, you can always dive deeper into the engine to see how those effects ...

3

It's named Z-fighting. You can google a lot information about it. For example here on wiki. In short: your water and terrain plane are in the same distance from camera (they are coplanar). If you move your camera (direction), float results differ a bit, so sometimes (I mean: some pixels) it chooses water to be drawn, sometimes it chooses terrain. And you ...

3

I cannot say what is commonly used, but my first thought would be to use a particle system with particles of varying sizes representing water of various volumes. The top of the water would use smaller particles to form the undulations of the surface and waves, the water nearest the player would use the smallest particles to simulate splashes and small ...

3

Except the spluttering / water jets (seems to be done with particles) it looks like a displacement shader. Check out this http://http.developer.nvidia.com/GPUGems2/gpugems2_chapter19.html It is in 3D but the theory behind it should provide helpful if it is that kind of water effect you look for.

3

Games usually turn on some sort of effects, primarily blue fog, when the camera is underwater. To handle the situation where the near plane clips through the water surface, you can turn on the fog shader when the camera gets close to the water surface, but then add some code to the pixel shader that calculates the point on the near plane corresponding to ...

3

If you want to draw 2d drop of water a solution is to draw sphere normals and then blur the normal buffer. Then use the buffer to calculate the refraction. This technique is briefly explained here (in 3d): http://developer.download.nvidia.com/presentations/2010/gdc/Direct3D_Effects.pdf

3

ilmale's answer is very comprehensive for 3D. For the 2D case, a trick I've used in the past is to render a bunch of blobs with feathered edges using additive blending. (This example I had kicking around used rounded squares, but any shape works. The soft edges let them merge smoothly together when they get close.) This creates something like a height ...

3

The function returns a scalar, but the variable w is indeed a vector. More traditionally, the one-dimensional wave function is written as: Ψ(x,t) = A cos( k x - ω t ) In more than one dimension, for example waves in water instead of on a rope, the spatial part is written as the dot product of two vectors: Ψ(x,t) = A cos( k·x - &...

Only top voted, non community-wiki answers of a minimum length are eligible