Build Snapchat like face-filter working in the browser.
Expression detection library to build animoji like apps running in the browser.
Great for augmented reality!
GL.readPixels(...)
gl.readPixels(), canvas.toDataURL()
GL.readPixels()
with FLOAT/HALF FLOAT textures,
gl_FragColor
encodes 1 float in its RGBA channels,
GL = canvas.getContext("webgl",
{
antialias: false,
preserveDrawingBuffer: true
})
GL.disable(GL.DEPTH_TEST);
GL.disable(GL.DITHER);
GL.FLOAT
→ 32 bits
GL.HALF_FLOAT
→ 16 bits, enough for deep learning,
GL.UNSIGNED_BYTE
→ 8 bits, not enough,
highp float
→ 32 bits:+Inf, -Inf, NaN
+Inf, -Inf
→ can disappear (1/Inf=0
) but not NaN
!
float ELU(float x){
return mix(exp(x)-1.0, x, step(x, 0.));
}
x=100
→ ELU(100)=100
ELU(100)=
mix(exp(100)-1, 100, 1)
= (exp(100)-1) * 0 + 100
exp(100) = 2.7.1043 = +Inf
ELU(100) = +Inf * 0 + 100 = NaN + 100 = NaN
exp(), log()
,
mix()
or other GLSL interpolation function is called, make sure that all terms are not FP specials
float safe_ELU(float x){
return mix(exp(-abs(x))-1.0, x, step(x, 0.));
}
w←d*w
with d<1)
Required :
Always better :
OES_TEXTURE_FLOAT
or OES_TEXTURE_HALF_FLOAT
extension,
OES_TEXTURE_FLOAT_LINEAR
or OES_TEXTURE_HALF_FLOAT_LINEAR
,
EXT_color_buffer_float
and EXT_color_buffer_half_float
,
OES_TEXTURE_FLOAT_LINEAR
or OES_TEXTURE_HALF_FLOAT_LINEAR
for using mipmapping on float/half float textures.
OES_TEXTURE_HALF_FLOAT
→ you can use half float texture.
Problem if initialization from an array:
there is no JS Float16Array()
type.
Uint16Array()
using binary float format,
Float32Array()
, then copy it to the half float texture.
xavier@jeeliz.com - @xavierbourry
xavier@jeeliz.com - @xavierbourry