diff options
author | Thomas Dinges <blender@dingto.org> | 2016-05-20 22:21:57 +0300 |
---|---|---|
committer | Thomas Dinges <blender@dingto.org> | 2016-05-20 22:21:57 +0300 |
commit | ecf534e4c588254f6d8f8c9e5b1688f6556dec19 (patch) | |
tree | 54ee0e94b6f4df3875e1185e5724872ac29580e7 /source/blender/gpu | |
parent | d5b843ba9d2d560010c921fcdbd9838fd3b6ef5c (diff) |
Support Cycles wave texture in GLSL viewport.
Diffstat (limited to 'source/blender/gpu')
-rw-r--r-- | source/blender/gpu/shaders/gpu_shader_material.glsl | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/source/blender/gpu/shaders/gpu_shader_material.glsl b/source/blender/gpu/shaders/gpu_shader_material.glsl index 7e815f1b5c5..6197b6fe7fb 100644 --- a/source/blender/gpu/shaders/gpu_shader_material.glsl +++ b/source/blender/gpu/shaders/gpu_shader_material.glsl @@ -3057,10 +3057,35 @@ void node_tex_voronoi(vec3 co, float scale, float coloring, out vec4 color, out } } -void node_tex_wave(vec3 co, float scale, float distortion, float detail, float detail_scale, out vec4 color, out float fac) +float calc_wave(vec3 p, float distortion, float detail, float detail_scale, int wave_type, int wave_profile) { - color = vec4(1.0); - fac = 1.0; + float n; + + if(wave_type == 0) /* type bands */ + n = (p.x + p.y + p.z) * 10.0; + else /* type rings */ + n = length(p) * 20.0; + + if(distortion != 0.0) + n += distortion * noise_turbulence(p*detail_scale, detail, 0); + + if(wave_profile == 0) { /* profile sin */ + return 0.5 + 0.5 * sin(n); + } + else { /* profile saw */ + n /= 2.0 * M_PI; + n -= int(n); + return (n < 0.0)? n + 1.0: n; + } +} + +void node_tex_wave(vec3 co, float scale, float distortion, float detail, float detail_scale, float wave_type, float wave_profile, out vec4 color, out float fac) +{ + float f; + f = calc_wave(co*scale, distortion, detail, detail_scale, int(wave_type), int(wave_profile)); + + color = vec4(f, f, f, 1.0); + fac = f; } /* light path */ |