Support Cycles wave texture in GLSL viewport.

This commit is contained in:
2016-05-20 21:21:57 +02:00
parent d5b843ba9d
commit ecf534e4c5
2 changed files with 36 additions and 5 deletions

View File

@@ -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 */