Watersurface for MonkeyWorld3D

Hi there.

Here is what I am currently struggling with. We are trying to implement a water

surface for MonkeyWorld3D. I have been told by Mojo that it can be done with the

ClothPatch. I have been playing with it, but I can't seem to get the

surface horizontal. If I apply a SpringForce to it, the whole cloth starts to move!

Also I don't want any gravity on this water surface!



Does any one have an idea how to implement a water surface?



Thanks

tGiant

	//lock all sides for wind test<br />

for (int y = 0; y < sizeY; y++) {

for (int x = 0; x < sizeX; x++)

{

if (y == 0) {

//cloth.getSystem().getNode(x).position.x *= .8f;

cloth.getSystem().getNode(x).setMass(Float.POSITIVE_INFINITY);

}

if (y > 0 && y < (sizeY - 2)) {

if (x == 0 || x == (sizeX - 1))

//cloth.getSystem().getNode(y * sizeX + x).position.x *= .8f;

cloth.getSystem().getNode(y * sizeX + x).setMass(Float.POSITIVE_INFINITY);

}

if (y == (sizeY - 1)) {

//cloth.getSystem().getNode(y * sizeX + x).position.x *= .8f;

cloth.getSystem().getNode(y * sizeX + x).setMass(Float.POSITIVE_INFINITY);

}



}

}

Thanks sonicviz



This is exactly what I had in mind and it works like a charm.

I only which to make the wave impulses a little bit more and smaller.



Should I try to apply more wind force or what do you think?

tgiant have you considered perlin noise to generate the ripples or would that be to heavy for a game it been done in j3d using ImprovedNoise class they even did the stargate effects with it I posted a link in releases

Okay people I neeed some help again.

Renanse, maybe you or Mojomonk can help me.

I need to apply an AlphaState on the watersurface, so that it can look a little bit more

realistic, but I can't seem to get the alphastate setup currectly to give  nice effect.

Can anyone of you please help?

This is what code I currently use:


            AlphaState as = DisplaySystem.getDisplaySystem().getRenderer().createAlphaState();
          as.setBlendEnabled(true);
          as.setSrcFunction(AlphaState.SB_SRC_ALPHA);
          as.setDstFunction(AlphaState.DB_ONE);
          as.setTestEnabled(true);
          as.setTestFunction(AlphaState.TF_GREATER);
          as.setEnabled(true);
            waterSurface.setRenderState(as);



Also, I have a simple water texture on the watersurface quad.

O’ yes, and here is a screenshot of what I currently have.

It is not much yet, but I want this to be perfect…



Try setting the defaultColor of your water quad to a color with an alpha that is something like .5f.

Thanks man, this helped a lot.

It made a difference and I can actually see through the water now!

Cool…





Thanks for this.

Very nice looking :)  Keep up the awesome work.

Opaque water surfaces in games are usually done as a cheap hack using a teleporter. Translucent water with a texture on top on which to reflect light is the shit these days, though. I've always been in favour of having a standard water level, having water devided into cubes and having each cobe able to translate an effect to the other cubes. That is, the water is distubed somewhere and when that disturbance reaches the edge of one cube, it is moved to the next. So you could set off a ripple and it'd spread.



I just like dynamic water. The static stuff, even animated, just doesn't feel like water. It's like jumping into molten glass or something.

there was a water test a while ago renanse did it had splash and ripple but needed lots of work and wasn,t considered useful, dependinding on what tgiant used for his surface it might be worth looking at again the " splash and ripple" part using springs instead who knows, I'm also interested in seeing how best to accomplish caustics from the art side that is when its released we'll know what we'll be able to do :smiley:

I've just taken a quick look at the water effects in Halo and FarCry.  Halo's seemed to be  base textures with an animated alpha channel (for streams).  Ocean surf seemed to have animated texture layers.  Neither ocean nor stream would let the camera pass below the water surface. 



FarCry, of course, raises the bar significantly.  The surface at the lowest quality appears to be multitextures/alpha channels.  The high end maybe reflects Nyphur's comments.  Nyphur gives a great explanation of the current trends that I didn't know before.  One question I have is related to the cube distribution of effects; would it be similar to an LOD or mipmap where at a certain distance from the camera the cubes would merely be texture layers and not dynamic?



FarCry's underwater air bubble effects seemed to be sprite animations on a quad that's displayed right in front of the camera (which is a cheap trick for snow, rain, etc).  Fog effects, light refraction, and surge where extra icing on the cake for underwater.



As far as MW3D goes, I think that surface multi-texture layers and alpha channels is a start.  We also need some kind of visible distinction for when the camera goes underwater; such as setting a translucent blue filter.  What do you all think?

Yes I agree. We need to get the best out there, but before we can do that, we must first

begin with something simple.

Well we are planning to improve on the water surface a lot for the next release and

the translucent blue filter is a very good idea and we will build that in as well.

If you work smartly with the editor, you can already make some sort of bubble effect with the

particles on the camera entity!

The water examples mrcoder posted looked pretty good too. Underwater as well.

the underwater effect was just the same as the refractioneffect when above water, but with added blueish fog.



i'm head on with implementing it suitable for jme. as you may have seen, the bloom and sketcheffect are allready in the latest jme cvs. i've now split the water up in a simple version with just reflection, and a phat version with reflection, refraction etc…they will all be in the (render)pass format, just like bloom and sketch…

digitalntburn said:

FarCry, of course, raises the bar significantly.  The surface at the lowest quality appears to be multitextures/alpha channels.  The high end maybe reflects Nyphur's comments.  Nyphur gives a great explanation of the current trends that I didn't know before.  One question I have is related to the cube distribution of effects; would it be similar to an LOD or mipmap where at a certain distance from the camera the cubes would merely be texture layers and not dynamic?

Everquest 2 uses a cubemap effect. I think their cube sizes remain identical at all ranges but the clever thing to do would be to increase cube size depending on distance. Water closer to you would have smaller cubes. Water effects closer to you like ripples would thus seem a lot more fluid than the ones further away. It could be a continuous level of detail type effect but I would be more in favour of having discrete levels of cube density roughly centred around you. That is, when a cube gets close enough, it splits into smaller cubes. When it gets closer still, it splits into even smaller ones. At a certain distance, it would turn to animated procedural textures, ideally at a distance where you would have a hard time telling the difference.

I've been meaning to play about with systems like that. When I get a chance, I'll have some fun with them.

an alternative to usual lodding techniques on grids, cubes or whatever is the “projected grid” method…really beautiful thing…



and look at the lovely demos…



http://graphics.cs.lth.se/theses/projects/projgrid/

Wow.  That'll work.



Man, that's one messed up duck.  :smiley:

and it's so alone…  :cry:



i will have a go at the projected grid method as soon as i can…

MrCoder said:

an alternative to usual lodding techniques on grids, cubes or whatever is the "projected grid" method...really beautiful thing...

and look at the lovely demos...

http://graphics.cs.lth.se/theses/projects/projgrid/

Looks nice, even if it does eat all my system resources.
Correct me if I'm wrong but this is just another way of implementing a Continuous LOD system, isn't it? Water surface mesh vertex spacing is simply applied at spacings dependant on distance from the camera. It might be using perspective projection (which could be a bit CPU intensive for some applications) but that still sounds like Continuous Level of Detail to me, which tends to eat up a lot of CPU as it is done every frame.

That thesis makes for an interesting read. It's probably not entirely how I would do things but it's interesting nonetheless.