An important variable is "object_space_pos". It is the variable we can use for setting the position.
We will use the x and y components but will use 0 instead of z.
Here is the result:
Creating a plane
water = d3d_model_create();
cells = 64;//Number of cells
cell = 8;//Cell width
height = 32;//Water max height
for(var X = -cells/2;X<cells/2;X++)
for(var Y = -cells/2;Y<cells/2-1;Y++)
This generates a plane model with many vertices to create higher quality water.
Apply your shader to this model instead of the basic shapes using "d3d_model_draw()".
float height = noise(in_Position.xy/64.0)*0.4+noise(in_Position.xy/32.0)*0.3+noise(in_Position.xy/16.0)*0.2+noise(in_Position.xy/8.0)*0.1;
That code generates a perlin noise pattern to make waves in the water.
Instead of setting the z position to 0 we'll set it to "height * in_Position.z". This makes it so we can determine the wave height by setting z position. And now finally we'll make a varying float called "v_vHeight" and pass our height variable through it. Now set the color in the fragment shader:
gl_FragColor = vec4(mix(vec3(0.1,0.2,0.4),vec3(0.1,0.1,0.3),v_vHeight),1.0);
This is the result: