Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- shader_type spatial;
- uniform vec4 base_color : hint_color;
- uniform sampler2D seabed;
- uniform sampler2D dudv_map;
- uniform float wave_speed = 0.05;
- uniform vec2 wave_strength = vec2(0.05, 0.005);
- varying vec3 world_pos;
- void vertex() {
- world_pos = (WORLD_MATRIX * vec4(VERTEX, 1.0)).rgb;
- }
- void fragment() {
- float mix_value = 0.94;
- // calculate our distortion using our DuDv map
- vec2 start_uv = vec2(world_pos.x * 0.01, world_pos.z * 0.01);
- vec2 distortion = texture(dudv_map, vec2(start_uv.x + (TIME * wave_speed), start_uv.y)).rg * wave_strength.x;
- distortion = (texture(dudv_map, vec2(start_uv.x + distortion.x, start_uv.y + distortion.y + (TIME * wave_speed))).rg * 2.0 - 1.0) * wave_strength.y;
- // this need to change and not use screen texture but use a texture from a viewport with a proper clip plane
- vec3 ground_color = textureLod(seabed, start_uv + distortion, 0.0).rgb;
- ALBEDO = mix(ground_color, base_color.rgb, mix_value);
- NORMAL = (INV_CAMERA_MATRIX * WORLD_MATRIX * vec4(normalize(vec3(distortion.x, 0.01, distortion.y)), 0.0)).xyz;
- SPECULAR = 0.5;
- ROUGHNESS = 0.6;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement