| 1 |
#version 450 core |
| 2 |
|
| 3 |
// These includes will include the default Qt3D uniform buffers |
| 4 |
#pragma include phong.inc.frag |
| 5 |
#pragma include coordinatesystems.inc |
| 6 |
|
| 7 |
layout(location = 0) in vec3 vertexPosition; |
| 8 |
layout(location = 1) in vec3 vertexNormal; |
| 9 |
layout(location = 2) in vec2 vertexTexCoord; |
| 10 |
layout(location = 3) in vec4 vertexTangent; |
| 11 |
|
| 12 |
layout(location = 0) out vec3 worldPosition; |
| 13 |
layout(location = 1) out vec3 worldNormal; |
| 14 |
layout(location = 2) out vec4 worldTangent; |
| 15 |
layout(location = 3) out vec2 texCoord; |
| 16 |
layout(location = 4) out vec2 movtexCoord; |
| 17 |
layout(location = 5) out vec2 multexCoord; |
| 18 |
layout(location = 6) out vec2 waveTexCoord; |
| 19 |
layout(location = 7) out vec2 skyTexCoord; |
| 20 |
layout(location = 8) out vec3 vpos; |
| 21 |
|
| 22 |
layout(std140, binding = auto) uniform wave_uniforms { |
| 23 |
float offsetx; |
| 24 |
float offsety; |
| 25 |
float vertYpos; |
| 26 |
float waveheight; |
| 27 |
float waveRandom; |
| 28 |
float specularity; |
| 29 |
float waveStrenght; |
| 30 |
float normalAmount; |
| 31 |
vec3 specularColor; |
| 32 |
float shininess; |
| 33 |
vec4 ka; |
| 34 |
}; |
| 35 |
|
| 36 |
void main() |
| 37 |
{ |
| 38 |
// Scale texture coordinates for for fragment shader |
| 39 |
texCoord = vertexTexCoord * texCoordScale; |
| 40 |
movtexCoord = vertexTexCoord * texCoordScale; |
| 41 |
multexCoord = vertexTexCoord * (texCoordScale*0.5); |
| 42 |
waveTexCoord = vertexTexCoord * (texCoordScale * 6); |
| 43 |
skyTexCoord = vertexTexCoord * (texCoordScale * 0.2); |
| 44 |
|
| 45 |
// Add Animated x and y Offset to SKY, MOV and MUL texCoords |
| 46 |
movtexCoord = vec2(texCoord.x+offsetx,texCoord.y+offsety); |
| 47 |
multexCoord = vec2(texCoord.x-offsetx,texCoord.y+offsety); |
| 48 |
skyTexCoord = vec2(texCoord.x-(offsetx/2),texCoord.y-(offsety/2)); |
| 49 |
|
| 50 |
// Transform position, normal, and tangent to world coords |
| 51 |
worldPosition = vec3(modelMatrix * vec4(vertexPosition, 1.0)); |
| 52 |
worldNormal = normalize(modelNormalMatrix * vertexNormal); |
| 53 |
worldTangent.xyz = normalize(vec3(modelMatrix * vec4(vertexTangent.xyz, 0.0))); |
| 54 |
worldTangent.w = vertexTangent.w; |
| 55 |
|
| 56 |
// Calculate animated vertex positions |
| 57 |
|
| 58 |
float sinPos = (vertexPosition.z)+(vertexPosition.x); |
| 59 |
float sinPos2 = (vertexPosition.y/2)+(vertexPosition.z); |
| 60 |
vec3 vertMod = vec3(vertexPosition.x,vertexPosition.y,vertexPosition.z); |
| 61 |
|
| 62 |
vertMod = vec3(vertMod.x+=sin(vertYpos*2.2-sinPos2)*waveheight, |
| 63 |
vertMod.y=sin(vertYpos*2.2+sinPos)*waveheight, |
| 64 |
vertMod.z-=sin(vertYpos*2.2-cos(sinPos2))*waveheight); |
| 65 |
|
| 66 |
vec3 vertModCom = vec3(vertMod.x+=cos(vertYpos*2.2-cos(sinPos2))*waveheight, |
| 67 |
vertMod.y=sin(vertYpos*2.2+cos(sinPos))*waveheight, |
| 68 |
vertMod.z-=cos(vertYpos*2.2-cos(sinPos))*waveheight); |
| 69 |
|
| 70 |
|
| 71 |
// Add wave animation only to vertices above world pos.y zero |
| 72 |
if(vertexPosition.y < 0.0){vertModCom = vertexPosition;} |
| 73 |
else{vertModCom = vertModCom;} |
| 74 |
|
| 75 |
vpos = vertModCom; |
| 76 |
|
| 77 |
// Calculate vertex position in clip coordinates |
| 78 |
gl_Position = mvp * vec4(vertModCom, 1.0); |
| 79 |
} |