Skip to content

Instantly share code, notes, and snippets.

@lucasvanmol
Last active November 14, 2020 12:41
Show Gist options
  • Select an option

  • Save lucasvanmol/f720175e2219b15ebffbfa96ddb57369 to your computer and use it in GitHub Desktop.

Select an option

Save lucasvanmol/f720175e2219b15ebffbfa96ddb57369 to your computer and use it in GitHub Desktop.
shader_type spatial;
uniform float strength_x = 0.0;
uniform float strength_y = 0.0;
uniform float strength_z = 0.0;
uniform vec3 center = vec3(0.0, 0.0, 1.0);
void vertex() {
vec3 v = VERTEX - center;
float delta = v.y * 0.1;
float theta = strength_x * delta;
mat3 rot_x = mat3(
vec3(1, 0, 0),
vec3(0, cos(theta), -sin(theta)),
vec3(0, sin(theta), cos(theta))
);
float phi = strength_y * delta;
mat3 rot_y = mat3(
vec3(cos(phi), 0, sin(phi)),
vec3(0, 1, 0),
vec3(-sin(phi), 0, cos(phi))
);
float psi = strength_z * delta;
mat3 rot_z = mat3(
vec3(cos(psi), -sin(psi), 0),
vec3(sin(psi), cos(psi), 0),
vec3(0, 0, 1)
);
VERTEX = v * rot_y * rot_x * rot_z + center;
NORMAL = NORMAL * rot_y * rot_x * rot_z;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment