Tag: #webgl
Why is my WebGL texture upside-down?
WebGL’s
texImage2D
function expects pixels in bottom-to-top order, while browsers provide them top-to-bottom. UNPACK_FLIP_Y_WEBGL
fixes this behavior. 2020-10-22Use varyings for texture2D coordinates!
Using a
varying
to pass the texture coordinates to the fragment shader avoids the need to perform divisions in the fragment shader, improving performance. 2020-10-21How to make a floating head
Creating a “floating head” effect using WebGL and the BodyPix machine learning model to segment the face from a webcam feed. 2020-10-06
Using BodyPix segmentation in a WebGL shader
A WebGL shader that uses BodyPix segmentation to set the alpha channel. 2020-09-24
Step-away background removal
A step-away background removal technique using WebGL, which compares both chrominance and luminance differences between the webcam feed and a captured background image to create a transparent mask. 2020-09-20
Edge detection with Sobel filters
A WebGL fragment shader that implements the Sobel filter, a method for detecting edges in an image. A demo processes your webcam video stream. 2020-08-31
Why does my WebGL alpha-transparency look wrong?
WebGL alpha-transparency may appear wrong because of premultiplied alpha. Fix it by setting
premultipliedAlpha: false
when creating the WebGL context. 2020-08-12Production-ready green screen in the browser
A green screen implementation in the browser using WebGL and chroma key. Includes a live demo. 2020-08-11
How to implement green screen in WebGL
An green screen implementation in the browser using WebGL and a chroma key shader. Includes a demo that replaces sufficiently green pixels with magenta. 2020-08-10
How to implement green screen in the browser
A green screen implementation in the browser using WebGL and chroma key. Includes a live demo. 2020-08-09
Simulating epidemics with WebGL
A spatial SIR model for simulating epidemics, implemented using WebGL fragment shaders. Tracks susceptible, infected, and recovered populations in a 2D grid. 2020-02-23
WebGL shading: both diffuse and specular
A WebGL shader that combines diffuse and specular lighting, allowing the user to adjust the relative contribution of each using keyboard controls. Guest post by Luís Fonseca. 2017-10-28
Giant Game of Life
Implements a 1024x1024 grid of Conway’s Game of Life using WebGL fragment shaders. 2017-10-23
Game of Life implemented with a fragment shader
A Conway’s Game of Life simulation implemented using WebGL fragment shaders, with rendering to texture and a Gosper Glider Gun initial state. 2017-10-22
Drawing a cube in WebGL
Rendering an animated 3D cube in WebGL using a vertex shader, face color uniforms, and matrix transformations for rotating the cube. 2017-10-21
Generated normal-mapped ripples
Generating dynamic normal-mapped ripple effects using WebGL, with the mouse position controlling the light source. 2017-10-20
GLSL varying variables
GLSL
varying
allows vertex shader outputs to be passed to fragment shaders. A WebGL demo with colors interpolated between vertices. 2017-10-19Drawing a clock face with WebGL
A WebGL clock face with moving hands that updates every second, using a vertex shader to convert polar coordinates to 3D positions. 2017-10-07
All content copyright James Fisher.