From cb868acadcae4e3f497ecdabeca507f3e73e01c7 Mon Sep 17 00:00:00 2001 From: jjesswan Date: Tue, 7 May 2024 01:32:02 -0400 Subject: add more accurate foam height saturation, poppping bubble effect --- resources/images/foam3.png | Bin 2042062 -> 4000051 bytes resources/images/halftone.png | Bin 30448 -> 219172 bytes resources/shaders/foam.frag | 12 ++++++------ 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'resources') diff --git a/resources/images/foam3.png b/resources/images/foam3.png index ab48f97..1113912 100644 Binary files a/resources/images/foam3.png and b/resources/images/foam3.png differ diff --git a/resources/images/halftone.png b/resources/images/halftone.png index e059862..cc11eba 100644 Binary files a/resources/images/halftone.png and b/resources/images/halftone.png differ diff --git a/resources/shaders/foam.frag b/resources/shaders/foam.frag index af0cf4c..be95183 100644 --- a/resources/shaders/foam.frag +++ b/resources/shaders/foam.frag @@ -33,21 +33,21 @@ float getSaturation(vec2 k, vec2 xzPos, float adjWaveLength, float phaseC){ 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); - float m_threshold = m_uv.r * m_uv.g * m_uv.b; + 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(.5*saturation - m_threshold, 0, 1) * h; + vec4 g = clamp(saturation - m_threshold, 0, 1) * h; // apply foam texture - vec4 foam = texture(foam_texture, tex*3); + vec4 foam = texture(foam_texture, tex + time*.0003); vec4 j = vec4(0,0,0,0); - if (saturation > m_threshold) j = vec4(g*foam); + if (saturation > m_threshold) j = g*foam*1.8; - fragColor = vec4(vec3(j), saturation); + fragColor = j; //vec4(vec3(g), 1); } -- cgit v1.2.3-70-g09d2