Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions lightgl.js
Original file line number Diff line number Diff line change
Expand Up @@ -1905,6 +1905,13 @@ Texture.canUseFloatingPointLinearFiltering = function() {
return !!gl.getExtension('OES_texture_float_linear');
};

// ### GL.Texture.canUseFloatingPointRTT()
//
// Returns false if float32 textures can't be rendered to.
Texture.canUseFloatingPointRTT = function() {
return !!gl.getExtension('WEBGL_color_buffer_float');
};

// ### GL.Texture.canUseFloatingPointTextures()
//
// Returns false if `gl.HALF_FLOAT_OES` is not supported as a texture type.
Expand All @@ -1922,6 +1929,13 @@ Texture.canUseHalfFloatingPointLinearFiltering = function() {
return !!gl.getExtension('OES_texture_half_float_linear');
};

// ### GL.Texture.canUseHalfFloatingPointRTT()
//
// Returns false if float16 textures can't be rendered to.
Texture.canUseHalfFloatingPointRTT = function() {
return !!gl.getExtension('EXT_color_buffer_half_float');
};

// src/vector.js
// Provides a simple 3D vector class. Vector operations can be done using member
// functions, which return new vectors, or static functions, which reuse
Expand Down
7 changes: 4 additions & 3 deletions water.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,18 @@ function Water() {
}\
';
this.plane = GL.Mesh.plane();
if (!GL.Texture.canUseFloatingPointTextures()) {
throw new Error('This demo requires the OES_texture_float extension');
if (!GL.Texture.canUseFloatingPointRTT() && !GL.Texture.canUseHalfFloatingPointRTT()) {
throw new Error('This demo requires either the WEBGL_color_buffer_float or the EXT_color_buffer_half_float extension');
}
var filter = GL.Texture.canUseFloatingPointLinearFiltering() ? gl.LINEAR : gl.NEAREST;
this.textureA = new GL.Texture(256, 256, { type: gl.FLOAT, filter: filter });
this.textureB = new GL.Texture(256, 256, { type: gl.FLOAT, filter: filter });
if ((!this.textureA.canDrawTo() || !this.textureB.canDrawTo()) && GL.Texture.canUseHalfFloatingPointTextures()) {
if ((!this.textureA.canDrawTo() || !this.textureB.canDrawTo()) && GL.Texture.canUseHalfFloatingPointRTT()) {
filter = GL.Texture.canUseHalfFloatingPointLinearFiltering() ? gl.LINEAR : gl.NEAREST;
this.textureA = new GL.Texture(256, 256, { type: gl.HALF_FLOAT_OES, filter: filter });
this.textureB = new GL.Texture(256, 256, { type: gl.HALF_FLOAT_OES, filter: filter });
}

this.dropShader = new GL.Shader(vertexShader, '\
const float PI = 3.141592653589793;\
uniform sampler2D texture;\
Expand Down