feat(all): 迁移扩展相关功能
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
precision highp float;
|
||||
precision highp int;
|
||||
|
||||
const float PI = 3.141592653589793;
|
||||
uniform sampler2D tInput;
|
||||
uniform vec2 center;
|
||||
uniform float radius;
|
||||
uniform float strength;
|
||||
in vec2 coord;
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
void main() {
|
||||
/* Get vertex info */
|
||||
vec4 info = texture(tInput, coord);
|
||||
|
||||
/* Add the drop to the height */
|
||||
float drop = max(0.0, 1.0 - length(center * 0.5 + 0.5 - coord) / radius);
|
||||
drop = 0.5 - cos(drop * PI) * 0.5;
|
||||
info.r += drop * strength;
|
||||
|
||||
fragColor = info;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
precision highp float;
|
||||
precision highp int;
|
||||
|
||||
uniform sampler2D tInput;
|
||||
uniform vec2 delta;
|
||||
in vec2 coord;
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
void main() {
|
||||
/* get vertex info */
|
||||
vec4 info = texture(tInput, coord);
|
||||
|
||||
/* update the normal */
|
||||
vec3 dx = vec3(delta.x, texture(tInput, vec2(coord.x + delta.x, coord.y)).r - info.r, 0.0);
|
||||
vec3 dy = vec3(0.0, texture(tInput, vec2(coord.x, coord.y + delta.y)).r - info.r, delta.y);
|
||||
info.ba = normalize(cross(dy, dx)).xz;
|
||||
|
||||
fragColor = info;
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
precision highp float;
|
||||
precision highp int;
|
||||
|
||||
uniform sampler2D tInput;
|
||||
uniform vec2 delta;
|
||||
in vec2 coord;
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
void main() {
|
||||
/* get vertex info */
|
||||
vec4 info = texture(tInput, coord);
|
||||
|
||||
/* calculate average neighbor height */
|
||||
vec2 dx = vec2(delta.x, 0.0);
|
||||
vec2 dy = vec2(0.0, delta.y);
|
||||
float average = (
|
||||
texture(tInput, coord - dx).r +
|
||||
texture(tInput, coord - dy).r +
|
||||
texture(tInput, coord + dx).r +
|
||||
texture(tInput, coord + dy).r
|
||||
) * 0.25;
|
||||
|
||||
/* change the velocity to move toward the average */
|
||||
info.g += (average - info.r) * 2.0;
|
||||
|
||||
/* attenuate the velocity a little so waves do not last forever */
|
||||
info.g *= 0.995;
|
||||
|
||||
/* move the vertex along the velocity */
|
||||
info.r += info.g;
|
||||
|
||||
fragColor = info;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
in vec3 position;
|
||||
out vec2 coord;
|
||||
|
||||
|
||||
void main() {
|
||||
coord = position.xy * 0.5 + 0.5;
|
||||
|
||||
gl_Position = vec4(position.xyz, 1.0);
|
||||
}
|
||||
Reference in New Issue
Block a user