Hello,
I have been developing a simple ocean wave "heightfield" composed out of 6 sine waves. Now, I need to find the normal of each vertex, and I am stuck basically. How I calculate my waves:
[source lang="cpp"]float2 dir = float2(1.0f, 0.0f);float dir_vertex = dot(dir, wave_vertex.xz); float wave1 = 25.0f * pow(sin( (2 * PI / 800) * dir_vertex - time * 2 * PI / 45.0f - 105.0f),2);// .... and so on for the others ...vertex.y = wave1 + wave2 + wave3 + wave4 + wave5 + wave6;[/source]
(I know looks ugly, but it works)
Is there a computationally cheap way to find the normal (this is for an iOS game).
Thanks a bunch!
Show differencesHistory of post edits
#2alkisbkn
Posted 09 August 2012 - 08:15 PM
Hello,
I have been developing a simple ocean wave "heightfield" composed out of 6 sine waves. Now, I need to find the normal of each vertex, and I am stuck basically. How I calculate my waves:
[source lang="cpp"]float2 dir = float2(1.0f, 0.0f);float dir_vertex = dot(dir, wave_vertex.xz); float wave1 = 25.0f * pow(sin( (2 * PI / 800) * dir_vertex - time * 2 * PI / 45.0f - 105.0f),2);// .... and so on for the others ...vertex.y = wave1 + wave2 + wave3 + wave4 + wave5 + wave6;[/source]
(I know looks ugly, but it works)
Is there a computationally cheap way to find the normal (this is for an iOS game).
Thanks a bunch!
I have been developing a simple ocean wave "heightfield" composed out of 6 sine waves. Now, I need to find the normal of each vertex, and I am stuck basically. How I calculate my waves:
[source lang="cpp"]float2 dir = float2(1.0f, 0.0f);float dir_vertex = dot(dir, wave_vertex.xz); float wave1 = 25.0f * pow(sin( (2 * PI / 800) * dir_vertex - time * 2 * PI / 45.0f - 105.0f),2);// .... and so on for the others ...vertex.y = wave1 + wave2 + wave3 + wave4 + wave5 + wave6;[/source]
(I know looks ugly, but it works)
Is there a computationally cheap way to find the normal (this is for an iOS game).
Thanks a bunch!
#1alkisbkn
Posted 09 August 2012 - 08:15 PM
Hello,
I have been developing a simple ocean wave "heightfield" composed out of 6 sine waves. Now, I need to find the normal of each vertex, and I am stuck basically. How I calculate my waves:
[source lang="cpp"]float2 dir = float2(1.0f, 0.0f);float dir_vertex = dot(dir, wave_vertex.xz); float wave1 = 25.0f * pow(sin( (2 * PI / 800) * dir_vertex - time * 2 * PI / 45.0f - 105.0f),2);// .... and so on for the others ...vertex.y = wave1 + wave2 + wave3 + wave4 + wave5 + wave6;[/source]
(I know looks ugly, but it works)
Is there a computationally cheap way to find the normal (this is for an iOS game).
Thanks a bunch!
I have been developing a simple ocean wave "heightfield" composed out of 6 sine waves. Now, I need to find the normal of each vertex, and I am stuck basically. How I calculate my waves:
[source lang="cpp"]float2 dir = float2(1.0f, 0.0f);float dir_vertex = dot(dir, wave_vertex.xz); float wave1 = 25.0f * pow(sin( (2 * PI / 800) * dir_vertex - time * 2 * PI / 45.0f - 105.0f),2);// .... and so on for the others ...vertex.y = wave1 + wave2 + wave3 + wave4 + wave5 + wave6;[/source]
(I know looks ugly, but it works)
Is there a computationally cheap way to find the normal (this is for an iOS game).
Thanks a bunch!