diff options
author | jjesswan <90643397+jjesswan@users.noreply.github.com> | 2024-05-09 15:13:41 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-09 15:13:41 -0400 |
commit | f846ddba00aee29675f0bd4f5dbc87a94a422368 (patch) | |
tree | 65a857125b91502974bceb40e24c1c7eff4bad59 /resources | |
parent | 72bcf6a346dfcaeaac9520d8c524711192e77c3d (diff) | |
parent | 675391d07f50d0067e7bab983433c6d86f5f8256 (diff) |
Merge pull request #3 from Seb-Park/foam2
Foam2 merge -- foam, skybox
Diffstat (limited to 'resources')
-rw-r--r-- | resources/images/cupertin-lake_bk.png | bin | 0 -> 333350 bytes | |||
-rw-r--r-- | resources/images/cupertin-lake_dn.png | bin | 0 -> 296096 bytes | |||
-rw-r--r-- | resources/images/cupertin-lake_ft.png | bin | 0 -> 340432 bytes | |||
-rw-r--r-- | resources/images/cupertin-lake_lf.png | bin | 0 -> 330551 bytes | |||
-rw-r--r-- | resources/images/cupertin-lake_rt.png | bin | 0 -> 309096 bytes | |||
-rw-r--r-- | resources/images/cupertin-lake_up.png | bin | 0 -> 280744 bytes | |||
-rw-r--r-- | resources/images/foam.png | bin | 0 -> 653157 bytes | |||
-rw-r--r-- | resources/images/foam2.jpeg | bin | 0 -> 101489 bytes | |||
-rw-r--r-- | resources/images/foam3.png | bin | 0 -> 4000051 bytes | |||
-rw-r--r-- | resources/images/foam4.png | bin | 0 -> 10850158 bytes | |||
-rw-r--r-- | resources/images/halftone.png | bin | 0 -> 219172 bytes | |||
-rw-r--r-- | resources/images/seafoam.jpeg | bin | 0 -> 211187 bytes | |||
-rw-r--r-- | resources/shaders/foam.frag | 53 | ||||
-rw-r--r-- | resources/shaders/foam.vert | 56 | ||||
-rw-r--r-- | resources/shaders/skybox.frag | 24 | ||||
-rw-r--r-- | resources/shaders/skybox.vert | 21 |
16 files changed, 154 insertions, 0 deletions
diff --git a/resources/images/cupertin-lake_bk.png b/resources/images/cupertin-lake_bk.png Binary files differnew file mode 100644 index 0000000..32ab079 --- /dev/null +++ b/resources/images/cupertin-lake_bk.png diff --git a/resources/images/cupertin-lake_dn.png b/resources/images/cupertin-lake_dn.png Binary files differnew file mode 100644 index 0000000..d742ac6 --- /dev/null +++ b/resources/images/cupertin-lake_dn.png diff --git a/resources/images/cupertin-lake_ft.png b/resources/images/cupertin-lake_ft.png Binary files differnew file mode 100644 index 0000000..2710ff0 --- /dev/null +++ b/resources/images/cupertin-lake_ft.png diff --git a/resources/images/cupertin-lake_lf.png b/resources/images/cupertin-lake_lf.png Binary files differnew file mode 100644 index 0000000..96a55e8 --- /dev/null +++ b/resources/images/cupertin-lake_lf.png diff --git a/resources/images/cupertin-lake_rt.png b/resources/images/cupertin-lake_rt.png Binary files differnew file mode 100644 index 0000000..f383c09 --- /dev/null +++ b/resources/images/cupertin-lake_rt.png diff --git a/resources/images/cupertin-lake_up.png b/resources/images/cupertin-lake_up.png Binary files differnew file mode 100644 index 0000000..1e05235 --- /dev/null +++ b/resources/images/cupertin-lake_up.png diff --git a/resources/images/foam.png b/resources/images/foam.png Binary files differnew file mode 100644 index 0000000..ff7404b --- /dev/null +++ b/resources/images/foam.png diff --git a/resources/images/foam2.jpeg b/resources/images/foam2.jpeg Binary files differnew file mode 100644 index 0000000..e8f2e8c --- /dev/null +++ b/resources/images/foam2.jpeg diff --git a/resources/images/foam3.png b/resources/images/foam3.png Binary files differnew file mode 100644 index 0000000..1113912 --- /dev/null +++ b/resources/images/foam3.png diff --git a/resources/images/foam4.png b/resources/images/foam4.png Binary files differnew file mode 100644 index 0000000..0b91836 --- /dev/null +++ b/resources/images/foam4.png diff --git a/resources/images/halftone.png b/resources/images/halftone.png Binary files differnew file mode 100644 index 0000000..cc11eba --- /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..be95183 --- /dev/null +++ b/resources/shaders/foam.frag @@ -0,0 +1,53 @@ +#version 330 core + +in vec2 constants; +in vec2 dir; +in vec2 tex; +in vec3 pos; + + +uniform float time; +uniform float phaseC; // phase constant + +uniform sampler2D halftone_texture; +uniform sampler2D foam_texture; + +uniform vec2 widthBounds; +uniform vec2 lengthBounds; + +out vec4 fragColor; + +float getSaturation(vec2 k, vec2 xzPos, float adjWaveLength, float phaseC){ + //k = normalize(k); + float result = dot(k, xzPos) * 3.14f / adjWaveLength; + result = result + phaseC*time*.5f; + result = -tan(result + 1.57f); + result = exp(result) / 20.f; + + return result; + +} + + + +void main() { + float height = pos.y; + float saturation = constants[0];//getSaturation(dir, vec2(pos.x, pos.z), 200.f, constants[0]); + vec4 m_uv = texture(halftone_texture, tex*2); + float m_threshold = (m_uv.r + m_uv.g + m_uv.b) / 3; + + // final rgba color at x,z pos + vec4 h = vec4(0,0,1,1); + if (saturation > m_threshold) h = vec4(1,1,1, 1); + + // add fading effect to bubble popping + vec4 g = clamp(saturation - m_threshold, 0, 1) * h; + + // apply foam texture + vec4 foam = texture(foam_texture, tex + time*.0003); + vec4 j = vec4(0,0,0,0); + if (saturation > m_threshold) j = g*foam*1.8; + + + fragColor = j; //vec4(vec3(g), 1); +} diff --git a/resources/shaders/foam.vert b/resources/shaders/foam.vert new file mode 100644 index 0000000..f27c589 --- /dev/null +++ b/resources/shaders/foam.vert @@ -0,0 +1,56 @@ +#version 330 core + +layout(location = 0) in vec3 position; // Position of the vertex +layout(location = 1) in vec3 wavelength; // wavelenth adjusted for ocean depth +layout(location = 2) in vec3 wavedirs; // 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 vec2 constants; +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 2*vec2(u_coord + offset, v_coord + offset); + +} + +void main() { + dir = vec2(wavedirs[0],wavedirs[1]); + constants = vec2(wavelength[0], phaseC); + + gl_Position = proj * view * model * vec4(position, 1); + pos = vec3(gl_Position); + + tex = calculateTexCoord(position); + +} diff --git a/resources/shaders/skybox.frag b/resources/shaders/skybox.frag new file mode 100644 index 0000000..926807e --- /dev/null +++ b/resources/shaders/skybox.frag @@ -0,0 +1,24 @@ + +#version 330 core + +in vec3 tex_coord; + +uniform samplerCube cubeMap; +uniform vec3 skyColor; + +out vec4 fragColor; + +const float lowerLimit = -50000.f; +const float upperLimit = 50000.f; + + +void main() { + + //fragColor = vec4(1.f); + vec4 finalColor = texture(cubeMap, tex_coord); + + // blending bottom of skybox to skyColor + float factor = (tex_coord.y - lowerLimit) / (upperLimit - lowerLimit); + factor = clamp(factor, 0.f, 1.f); + fragColor = finalColor; // mix(vec4(skyColor, 1.f), finalColor, factor); +} diff --git a/resources/shaders/skybox.vert b/resources/shaders/skybox.vert new file mode 100644 index 0000000..edf50e4 --- /dev/null +++ b/resources/shaders/skybox.vert @@ -0,0 +1,21 @@ +#version 330 core + +layout(location = 0) in vec3 pos; // Position of the vertex +//layout(location = 1) in vec3 normal; // Normal of the vertex +//layout(location = 3) in vec3 texCoords; + +uniform mat4 view, projection, rotation; + +out vec3 tex_coord; + + + +void main() { + + tex_coord = vec3(pos.x, pos.y, -pos.z); + vec4 world_pos = projection*view*rotation*vec4(pos, 1.0); + gl_Position = vec4(world_pos.x, world_pos.y, world_pos.w, world_pos.w); + +// tex_coord = pos; + // gl_Position = projection*view*vec4(pos, 1.0); +} |