diff options
author | jjesswan <jessica_wan@brown.edu> | 2024-05-06 00:01:04 -0400 |
---|---|---|
committer | jjesswan <jessica_wan@brown.edu> | 2024-05-06 00:01:04 -0400 |
commit | 2ba27898535e01298ef8f0d0b9ffd4e69ce13458 (patch) | |
tree | 18dac0a37704ba9c2271f185d62ea4a6d4873b61 /resources | |
parent | 72bcf6a346dfcaeaac9520d8c524711192e77c3d (diff) |
uv mapping onto water good
Diffstat (limited to 'resources')
-rw-r--r-- | resources/images/halftone.png | bin | 0 -> 11714 bytes | |||
-rw-r--r-- | resources/images/seafoam.jpeg | bin | 0 -> 211187 bytes | |||
-rw-r--r-- | resources/shaders/foam.frag | 33 | ||||
-rw-r--r-- | resources/shaders/foam.vert | 54 |
4 files changed, 87 insertions, 0 deletions
diff --git a/resources/images/halftone.png b/resources/images/halftone.png Binary files differnew file mode 100644 index 0000000..c70e107 --- /dev/null +++ b/resources/images/halftone.png diff --git a/resources/images/seafoam.jpeg b/resources/images/seafoam.jpeg Binary files differnew file mode 100644 index 0000000..520255d --- /dev/null +++ b/resources/images/seafoam.jpeg diff --git a/resources/shaders/foam.frag b/resources/shaders/foam.frag new file mode 100644 index 0000000..86403d8 --- /dev/null +++ b/resources/shaders/foam.frag @@ -0,0 +1,33 @@ +#version 330 core + +in vec4 saturation_const; +in vec2 dir; +in vec2 tex; +in vec3 pos; + + +uniform float time; +uniform sampler2D halftone_texture; +uniform vec2 widthBounds; +uniform vec2 lengthBounds; + +out vec4 fragColor; + +float getSaturation(vec2 k, vec2 xzPos, float adjWaveLength, float phaseC){ + float result = dot(k, xzPos) * 3.14f / adjWaveLength; + result = result + phaseC*time*.5f; + result = -tan(result) + 1.57f; + result = exp(result) / 4.f; + + return result; + +} + + + +void main() { + //float saturation = getSaturation(saturation_const[0], saturation_const[1],saturation_const[2],saturation_const[3]); + vec4 color = texture(halftone_texture, tex); + + fragColor = vec4(vec3(color), 1); +} diff --git a/resources/shaders/foam.vert b/resources/shaders/foam.vert new file mode 100644 index 0000000..6192ba7 --- /dev/null +++ b/resources/shaders/foam.vert @@ -0,0 +1,54 @@ +#version 330 core + +layout(location = 0) in vec3 position; // Position of the vertex +layout(location = 1) in float wavelength; // wavelenth adjusted for ocean depth +layout(location = 2) in vec2 direction; // wave slope +layout(location = 3) in vec2 texCoords; // texture coords +layout(location = 3) in vec3 norm; // texture coords + + +out vec4 saturation_const; +out vec2 dir; +out vec2 tex; +out vec3 pos; + + + +uniform float time; +uniform float phaseC; // phase constant +uniform mat4 proj; +uniform mat4 view; +uniform mat4 model; +uniform mat4 inverseView; +uniform vec2 widthBounds; +uniform vec2 lengthBounds; + +vec2 calculateTexCoord(vec3 pos){ +// vec3 v = vec3(0,0,1); +// if (abs(norm.y) < 1.f){ +// v = normalize(vec3(0,1,0) - norm.y*norm); +// } +// vec3 u = normalize(cross(norm, v)); + +// float u_coord = dot(u, vec3(pos.x, 0, pos.z)) - widthBounds[0]/ (widthBounds[1] - widthBounds[0]); +// float v_coord = dot(v, vec3(pos.x, 0, pos.z)) - lengthBounds[0]/ (lengthBounds[1] - lengthBounds[0]); + + float u_coord = position.x / (widthBounds[1] - widthBounds[0]); + float v_coord = position.z / (lengthBounds[1] - lengthBounds[0]); + + + float offset = .5f; + return vec2(u_coord + offset, v_coord + offset); + +} + +void main() { + dir = direction; + saturation_const = vec4(wavelength, phaseC, position.x, position.z); + + gl_Position = proj * view * model * vec4(position, 1); + pos = vec3(gl_Position); + + tex = calculateTexCoord(position); + +} |