# Strange problem in Circular sine wave( ripples) implementation

This topic is 2809 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

hey everyone!

I'm trying to make a basic ripple effect in HLSL. So I'm using the following equation(please correct me if I'm wrong)

Current Vertex Height = A * sin( kr - wt)

with this equation , i am able to generate basic sin waves along x and z axes.

For generating ripples i replaced r with
r = sqrt(x2 + z2) , where x and z are the respective x & z coordinates of the point.

The problem is that when i use this value of r (ie the sqrt one), im getting strange random oscillations which clearly do not look like circular waves , but when i remove the sqrt and instead write this

r = x2 + z2

i get, with some adjustment to the value k , perfect circular waves , although now i have to adjust the value of k with a increment/decrement factor of 0.000001 !!!!(earlier with sqrt it was 0.0001)

the values that i use are(all floats)
A = 25
K = 8
w = pi/2

and one more thing , im incrementing the time t by 0.01 every iteration

and heres the code outline (using HLSL ,by the way)
	.....	ConvertToradians(t);		float term = input.position.x * input.position.x + input.position.z * input.position.z;		float amp = 25.0f;		input.position.y = amp * sin(k*term - (w * t));		output.position  = multiply(input.position,ViewProjectionMatrix);	        .....

Can anyone please explain why is this happening? I've seen a similar example in the DX SDK Samples and in there they have used the length() function , which i think still calculates squareroot.Even in many other samples that i checked on the net , sqrt is used.

Is this due to the values that I've used??

thanks!

##### Share on other sites

well it seems that the problem was in the value of the angular wave number(ie k) that i had chosen. I had initially set it values like 4.0f , 8.0f etc . But it turns out that choosing 0.1f and then adjusting with a factor of 0.001 is working

Sorry for wasting your time again ,gamedev people :)

If you have anything else you would like to add/comment please do so.

1. 1
2. 2
3. 3
Rutin
22
4. 4
JoeJ
16
5. 5

• 14
• 30
• 13
• 11
• 11
• ### Forum Statistics

• Total Topics
631774
• Total Posts
3002295
×