Wave simulattion gregsn - wave reflection

I would like to modify Gregsns wave simulation in a way that the waves are not reflected by the borders of the renderer.
… there must be an easy way to do this but I do not get it.
Can anybody give me a hint ?

Markus

Hi Markus!

this problem is a more heavy one than one would think at first.

the algorithm can be thought of as a 2d cellular automata. or better as a grid of those.
now each automata depends on previous wave heights on its own position in that grid, but also depends on previous wave heights on the neighbouring automatas.
the grid in this case is the texture. the automatas are the pixels in combination with their pixelshader.

to get the previous outcome of a neighbouring automata, the distance in terms of texture coordinates is calculated and then a framedelayed texture is sampled at those 4 neighbouring positions.

this is done the same way for any pixel/texel/automata/fragment…

so the problem is

  • that the algorithm doesn’t behave differently on the borders
  • that we just don’t know how it should behave when there are neighbours missing (1 at the borders, 2 at the corners)

to make the algorithm work differently at the borders, we could gamble with some sampler states in the respective shader (“pix wave.fx”).

sampler samWave1 = sampler_state
{

AddressU = put it here; //Mirror, Clamp, Border, Wrap
AddressV = and here;
//BorderColor = 0;
};

but somehow this doesn’t result in the desired effect.

now we could check the texture coords in the pixelshader to behave differently if the pixeöshader is run on one of the border pixels…
we even could think of drawing the borders with a differnt shader or to draw a gradient somehow ontop of it…

but the main problem remains:

the wave automata depends on neighbours. every try to somehow simulate the lack of data changes the behaviour of the automata in a way, that it can’t behave like an automata in the midde of that grid. we just could simulate or estimate the needed data by carefully trying some equations. (i did that once some decades ago ;) but i cant find my programming treasures of that time anymore). it somehow worked. that means that the reflection (which will always be there) was reduced by estimating the height of the neighbour automata by some formula.

however for now i would suggest

  • to show only some part of a bigger grid (therefore hiding the real borders) &
  • to increase the decay (so that the waves are not identifyable anymore, when coming back into the focused area)

Sebastian

While we are on the same subject.
Is it possible to have that shader behave like water?
Or should I say is it possible to have it react to gravity?
As of now the waves does no feather back but continues to grow outwards sort of.
Should be a matter of simply apply acceleration to the pixel downwards until you get to midpoint and then apply negative acceleration.
And then some damping to simulate energy loss.

This is with the wave2 one.

hmm…

i don’t know what you mean. in general if everything works fine it should in general look as a water surface seen from the top (more accurate: a heightmap of that surface).
is that what you see?

however try to modify decay and attack and see if you can change the behaviour in a way that it looks more like water to you. press space sometimes to reset the surface

hmm. Thats weard. On my main cop it reacts more like water by midpointing back to grey but not on my laptop.
On the laptop of you put the marker to black it slowly fills the image with black and the same with white. But on the main comp it remains grey but with a halo around the “emitter”.
So it’s now obvious it’s a bug or problem on my end.
Have to look in to that some time.

Also how large rez can one expect to render at?
10241024 works with 1 iteration/frame but not more
2048
2048 peks cpu to 100% but seems kinda smooth but not sure about framerate.

A64 3000+ with ATI 9800 pro.

Game of life seems to be limited by the gpu rendering around 35fps 10241024.
2048
2048 was about 13fps.