How to make a goodlooking wave

Hello,

I just wanted to get some hints and tips on how to make a good looking wave. at the moment I just have this kind of ugly wave in my kite-game.
http://img233.imageshack.us/img233/3053/wavevx.jpg

Basically, it is just an object which is increasing the size and moving forwards with animations. However, this would be a wave that does not break. Any ideas how to make a breaking wave like in this game?

Is it possible to animate the mesh itself? the vertices?

In that surfgame the wave seems to be the same object as the water itself. You can’t see any border between the wave and the rest of the water. It is one fluent transition…

Thanks for all help!

Greetings!

I initially thought of a Script/Module that SolarLune once made, though my second Thought is this one, and I would probably prefer it…


# Blender Game Engine 2.55 Resource Kit: Energy Wave
# Shader by Martins Uptitis and Mike Pan
#
# The GLSL vertex shader is responsible for
# animated displacement of the wave
# The GLSL fragment shader is responsible for
# the coloring
# Run the game,
# then click anywhere on the screen :)

from bge import logic
cont = logic.getCurrentController()
own = cont.owner
VertexShader = """
uniform sampler2D noiseMap;
uniform float timer;
varying vec3 normal, lightDir, eyeVec;
#define amplitude 0.01
#define speed 1.0
void main()
{
//get the first UV layout
gl_TexCoord[0] = gl_MultiTexCoord0;
// pass lighting information to fragment shader
normal = gl_NormalMatrix * gl_Normal;
vec3 vVertex = vec3(gl_ModelViewMatrix * gl_Vertex);
eyeVec = -vVertex;
// deform
vec4 v = gl_Vertex;
<b><i>v.z = sin(timer*speed+v.x*0.5+v.y*1.0)*0.3+v.z*amplitude;
</i></b>v.z += texture2D(noiseMap, gl_TexCoord[0].st+timer*(0.01*speed)).r*0.3;
gl_Position = gl_ModelViewProjectionMatrix * v;
}
"""
FragmentShader = """
uniform sampler2D noiseMap;
uniform float timer;
varying vec3 normal, eyeVec;
void main(void)
{
vec3 N = normalize(normal);
vec3 E = normalize(eyeVec);
float fresnelTerm = pow( max(1.0-dot(N,E), 0.0), 2.0);
vec3 color1 = gl_FrontMaterial.diffuse.rgb;
vec3 color2 = gl_FrontMaterial.specular.rgb;
gl_FragColor.rgb = mix(color1 ,color2 ,fresnelTerm);
gl_FragColor.a = fresnelTerm*2.0;
}
"""

mesh = own.meshes[0]
for mat in mesh.materials:
 shader = mat.getShader()
 if shader != None:
  if not shader.isValid():
   shader.setSource(VertexShader, FragmentShader, 1)
  shader.setSampler('noiseMap',0)
  shader.setUniform1f('timer',own["timer"])

Apply this to an Object like you would apply a Python Script. It will deform your Mesh into a moving Wave Function.
Look at the bold-italic Line: It is the Function itself. Play around with that Function, maybe you get an adequate Breakin’ Wave?

How?? I tried to use that script but it doesn’t work! I’m a noob, so step by step would help if possible

Post #3 is not “Surfing Game!”'s first post to this forum. This is ridiculous.

There has been a time waster on this forum for months posting under different names, a new one every few weeks or even days, sometimes even hours.

It might not be technically against the rules of the forum but the person doing this, for whatever reason, is deceiving.

What? I only made this user because i’m been looking for ways to make waves. I’m an avid surfer. That too was the only reason why I got blender. To make a surfing game. Thanks alot Equip that really nice. A time waster.

In what Kind of Way doesn’t it work? Simply doin’ nothin’?
Have you tried it with a pulsed Sensor as well?
Always (pulsed), connected with a Script Controller.

Ô, a very important Thing: Add a Timer Property named “timer” to the Logic Bricks! Otherwise it cannot work – that is most probably the Problem here. I am sorry for not havin’ pointed that out in my earlier Post!

Thanks! youda man! I’ll try it now. Your not like that other guy… Equip!

It worked!!! Now… getting it to break…

@Surfing Game! you are getting the wave to break?! Please tell me how?

no, no. Not breaking unfortunatly. but moving! But I can’t work out how to make it surfable. Is it possible? I tried mutiple mesh’s but… It didn’t work. Any ideas… anyone?

Yo Surfing Game! You tried the script, didn’t work, you’re an avid surfer, added a timer property, tried multiple meshes, still doesn’t work but still an avid surfer, etc.

Post the blend.

Nah. It worked. just not surfable.

You say you got the script to work to some point. Post the blend and we might then see how we might apply it to an object that appears to shape itself to a breaking wave.

Or are you a sock puppet troll?

Equip, maybe he is new to the Forum and hasn’t even got told about how to share a .blend File.

(((Go Advanced > File Manager)))

Hi Caligari. Yeah, I challenged him in #4. He says that he is a noob, posting for the first time on this board and then says that he was able to paste a shader script into a working blend. Yeah right!

I didn’t believe his first post, much less do I believe him now.

Didn’t akm start this thread because he got a project that he’s been working on for a while and he’s seriously interested in what he does? You’re an OK guy, didn’t you reply because you are seriously interested in helping out likeminded people when you can? It helps you while it helps them.

He knows that if he pops up again without a blend that I’ll challenge him. What’s he going to do? wtf he’s on the board already under other names.

The above Python code injects a Shader.
By it’s nature a Shader is for display only. You can’t influence the Physics with a Shader.

What you can do is, to update the physics mesh with reinstanciatePyhsicsMesh.
But you need to modify it first to give you a wave mesh.

Or calculate the wave in python to for the position the surfboard are in and put appropriate forces to the surfboard. Hard but probably doable!

Heres a picture of a wave that I quickly molded:

EPIC!!! but hard.

how did you get the awesome water?