Jump to content
  • Advertisement
Sign in to follow this  
Manpreet

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.

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement


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 :)

And thanks for reading!

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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!