Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2016-05-20 17:58:40 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2016-05-20 17:58:56 +0300
commitca8419ed6efa3a764ea1f51d745bfc0ad3e64246 (patch)
treeec352963eb3923b6e1b627225cfe565d217c9fc3 /source/blender/gpu/shaders
parenta5a05fc291ab8e024e3ff6bf9cd63733c7687f86 (diff)
Support Cycles magic texture in GLSL viewport
Diffstat (limited to 'source/blender/gpu/shaders')
-rw-r--r--source/blender/gpu/shaders/gpu_shader_material.glsl61
1 files changed, 58 insertions, 3 deletions
diff --git a/source/blender/gpu/shaders/gpu_shader_material.glsl b/source/blender/gpu/shaders/gpu_shader_material.glsl
index faeb9bb17f6..67137c63d99 100644
--- a/source/blender/gpu/shaders/gpu_shader_material.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_material.glsl
@@ -2750,10 +2750,65 @@ void node_tex_image_empty(vec3 co, out vec4 color, out float alpha)
alpha = 0.0;
}
-void node_tex_magic(vec3 p, float scale, float distortion, out vec4 color, out float fac)
+void node_tex_magic(vec3 co, float scale, float distortion, float depth, out vec4 color, out float fac)
{
- color = vec4(1.0);
- fac = 1.0;
+ 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.5f - x, 0.5f - y, 0.5f - z, 1.0);
+ fac = (color.x + color.y + color.z) / 3.0;
}
void node_tex_musgrave(vec3 co, float scale, float detail, float dimension, float lacunarity, float offset, float gain, out vec4 color, out float fac)