opengl: Decrease water detail with distance

This commit is contained in:
Michaël Lemaire 2016-01-04 22:46:40 +01:00
parent 02a026116d
commit 17fbaf5fce

View file

@ -6,10 +6,13 @@ uniform float waterReflection;
uniform float[4] waterNoise; uniform float[4] waterNoise;
out vec4 final_color; out vec4 final_color;
float getDetail(vec3 location) {
return max(min(pow(length(location - cameraLocation) * 0.002, 2.0), 0.01), 0.000001);
}
void main(void) void main(void)
{ {
// TODO Increased detail near camera vec3 normal = noiseNormal2d(waterNoise, unprojected.xz, getDetail(unprojected));
vec3 normal = noiseNormal2d(waterNoise, unprojected.xz, 0.00001);
final_color = applyLighting(unprojected, normal, waterMaterialColor, waterMaterialReflection, waterMaterialShininess, waterMaterialHardness); final_color = applyLighting(unprojected, normal, waterMaterialColor, waterMaterialReflection, waterMaterialShininess, waterMaterialHardness);