Erglegrue: Could you possible post the project file? I have something that resembles ripples expanding and bouncing, but they eventually turn the entire screen white, and they have a lot of artifacts in them. I'm not sure if your HLSL code is all right, and I'm sure I'm getting tripped up elsewhere.
I have spent a good amount of time tuning my spring field - it is not easy - I have written a graphical ui just for tweaking the parameters
But I got results fast - once I could tune it interactively
I have got better results than I hope for with code below
but am now still trying to solve "microvibrations"
When it "turns white" I think that is because a spring force alone will pull everything in one direction
You will also find working EXE and HLSL here: http://www.humus.name/index.php?page=3D&&start=32
humus technique is very simple but I can not replicate his beautiful results
i get the impression his water only displaces upwards - because I can get the same results by "booting" my texture to all zeros and using no wave force
but I want proper waves
(also packing height and velocity into 16 bits each will give better results)
here is my current attempt:
//
// SAMPLE TEXTURE (remember these values are between 0 and 1)
//
float4 p0 = tex2D(smpSpringField, Input.TexCoord0); p0.xy -= 0.5; // remap to -0.5 to +0.5
float4 p1 = tex2D(smpSpringField, Input.TexCoord1); p1.x -= 0.5;
float4 p2 = tex2D(smpSpringField, Input.TexCoord2); p2.x -= 0.5;
float4 p3 = tex2D(smpSpringField, Input.TexCoord3); p3.x -= 0.5;
float4 p4 = tex2D(smpSpringField, Input.TexCoord4); p4.x -= 0.5;
//
// ADD DROP
//
float2 offset = abs(Input.TexCoord0 - dropLocation);
if (dropLocation.x != 0 && dropLocation.y != 0) {
if (dropRadius > offset.x * offset.x + offset.y * offset.y) {
//
// THIS IS NEW DROP
//
p0.x = 1.0;
p0.y = -0.1;
}//if
}//if
//
// CALCULATE SPRING FORCE
//
float springForce =
p1.x +
p2.x +
p3.x +
p4.x -
p0.x * 4.0;
//
// CALCULATE WAVE FORCE
//
float waveForce = pow(abs(p0.x), waveExponent) * sign(p0.x) * -1.0;
//
// ADD ACCELERATION TO DAMPED VELOCITY
//
p0.y =
p0.y * velocityDamping
+ waveForce * waveScale * elapsedTime
+ springForce * springScale * elapsedTime;
//
// CLAMP VELOCITY (experimental)
//
p0.y = clamp(p0.y, -0.2, 0.2);
//
// ADD VELOCITY TO HEIGHT
//
p0.x += p0.y * elapsedTime; // add velocity to height
//
// MAP BACK TO COLOR RANGE (remember this will clamp values)
//
p0.xy += 0.5;
//
// RETURN UPDATED PARTICLE FOR RENDER TARGET
//
return p0;