Changeset View
Changeset View
Standalone View
Standalone View
source/blender/gpu/shaders/gpu_shader_material_magic.glsl
- This file was added.
| void node_tex_magic( | |||||
| vec3 co, float scale, float distortion, float depth, out vec4 color, out float fac) | |||||
| { | |||||
| vec3 p = co * scale; | |||||
| float x = sin((p.x + p.y + p.z) * 5.0); | |||||
| float y = cos((-p.x + p.y - p.z) * 5.0); | |||||
| float z = -cos((-p.x - p.y + p.z) * 5.0); | |||||
| if (depth > 0) { | |||||
| x *= distortion; | |||||
| y *= distortion; | |||||
| z *= distortion; | |||||
| y = -cos(x - y + z); | |||||
| y *= distortion; | |||||
| if (depth > 1) { | |||||
| x = cos(x - y - z); | |||||
| x *= distortion; | |||||
| if (depth > 2) { | |||||
| z = sin(-x - y - z); | |||||
| z *= distortion; | |||||
| if (depth > 3) { | |||||
| x = -cos(-x + y - z); | |||||
| x *= distortion; | |||||
| if (depth > 4) { | |||||
| y = -sin(-x + y + z); | |||||
| y *= distortion; | |||||
| if (depth > 5) { | |||||
| y = -cos(-x + y + z); | |||||
| y *= distortion; | |||||
| if (depth > 6) { | |||||
| x = cos(x + y + z); | |||||
| x *= distortion; | |||||
| if (depth > 7) { | |||||
| z = sin(x + y - z); | |||||
| z *= distortion; | |||||
| if (depth > 8) { | |||||
| x = -cos(-x - y + z); | |||||
| x *= distortion; | |||||
| if (depth > 9) { | |||||
| y = -sin(x - y + z); | |||||
| y *= distortion; | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| if (distortion != 0.0) { | |||||
| distortion *= 2.0; | |||||
| x /= distortion; | |||||
| y /= distortion; | |||||
| z /= distortion; | |||||
| } | |||||
| color = vec4(0.5 - x, 0.5 - y, 0.5 - z, 1.0); | |||||
| fac = (color.x + color.y + color.z) / 3.0; | |||||
| } | |||||