Set texture filtering for perlin Noise to linear for better results

This commit is contained in:
Julian
2020-01-26 12:10:31 +01:00
parent 564a0d43b5
commit 03467fc70b

View File

@@ -24,7 +24,10 @@ function initGL(canvas: HTMLCanvasElement) {
alert("Unable to initialize WebGL. Your browser or machine may not support it."); alert("Unable to initialize WebGL. Your browser or machine may not support it.");
} }
gl = <WebGL2RenderingContext>gltemp; gl = <WebGL2RenderingContext>gltemp;
gl.getExtension( 'EXT_color_buffer_float' ); //WebGL2 supports floating point textures by default but it does not support filtering them or rendering to them by default.
gl.getExtension( 'EXT_color_buffer_float' ); //allow 32bit texture as framebuffer target
gl.getExtension( 'OES_texture_float_linear' ); //allow linear filtering
gl.enable(gl.DEPTH_TEST); gl.enable(gl.DEPTH_TEST);
} }
@@ -220,8 +223,8 @@ function initFBO() {
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA32F, perlinNoiseFBOWidth, ferlinNoiseFBOHeight, 0, gl.RGBA, gl.FLOAT, null); gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA32F, perlinNoiseFBOWidth, ferlinNoiseFBOHeight, 0, gl.RGBA, gl.FLOAT, null);
// set the filtering so we don't need mips // set the filtering so we don't need mips
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);