forked from joinpursuit/FSW-Personal-Website
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwater.frag
More file actions
33 lines (26 loc) · 938 Bytes
/
water.frag
File metadata and controls
33 lines (26 loc) · 938 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/**
* 🌊 WATER FRAGMENT SHADER
*
* Basic fragment shader for water surface effects
* Handles per-pixel coloring and optical effects
*/
// Precision declaration (required for fragment shaders)
precision mediump float;
// Uniforms (shared across all fragments)
uniform float uTime; // Animation time
uniform vec2 uResolution; // Screen resolution
uniform vec3 uWaterColor; // Base water color
// Varyings (received from vertex shader)
varying vec2 vUv; // UV coordinates
varying vec3 vPosition; // World position
void main() {
// Basic water color with transparency
vec3 waterColor = uWaterColor;
// Simple transparency based on position (will be enhanced later)
float alpha = 0.4;
// Add subtle variation based on UV coordinates
float variation = sin(vUv.x * 10.0 + uTime) * 0.1 + 0.9;
waterColor *= variation;
// Output final color
gl_FragColor = vec4(waterColor, alpha);
}