paysages3d/src/render/opengl/shaders/noise.frag

20 lines
554 B
GLSL
Raw Normal View History

2014-01-21 20:41:15 +00:00
uniform sampler2D simplexSampler;
vec3 noiseNormal2d(float[4] data, vec2 location, float detail)
2014-01-21 20:41:15 +00:00
{
vec3 normal = vec3(0.0, 0.0, 0.0);
float scaling = data[0];
float height = data[1];
float step_scaling = data[2];
float step_height = data[3];
while (height > detail)
2014-01-21 20:41:15 +00:00
{
// TODO offsets
2016-01-04 19:26:40 +00:00
// TODO parametrized texture scaling
normal += texture(simplexSampler, location * scaling / 15.0).xyz - vec3(0.5);
scaling *= step_scaling;
height *= step_height;
2014-01-21 20:41:15 +00:00
}
return normalize(normal);
}