WebGL Alpha Stencil Semi Transparency

Swipe Over the Canvas to Move the Cube

This Web page demonstrates displaying a stencil over an image. Semi transparent alpha areas allow some of the background to show through the stencil.

See a portion of the background graphic, where a stencil masks part of the cube. The stencil applies transparency from a GIF image. Transparent portions of the texture mask portions of the cube, allowing the background to show through. Semi transparency is applied to the rest of the texture.

Some browsers and devices don't render correctly with this blend option. For example Windows Phone 8.1 displays solid white bars instead of transparency. The Stencil Blending Options page allows you to select and view blending options as they apply to the stencil.

Each side of the cube is texture mapped with a different color. A large quad renders behind the cube. A small stationary stencil with transparent bars masks off the cube, as the cube passes over the stencil area. See a portion of the background quad through the cube, where the stencil masks the cube. Bars from the stationary graphic display with semi transparency over the cube as well.

Render the stencil with gl.enable(gl.BLEND) and the following call to blendFunc().

gl.blendFunc(
 gl.ONE,
 gl.ONE_MINUS_CONSTANT_COLOR
);

To render the cube disable blend with gl.disable(gl.BLEND).

3D Models

If a picture's worth a thousand words, then a 3D model's worth ten thousand words! Consider 3D interactive content for learning, media, and marketing. Seven Thunder Software develops 3D models for Web design, with optimized (fast loading) 3D rendering software, from photographs, blue prints, ideas, and real objects.

Tags

Interactive media, 3D shapes, 3D models, 3D, online 3D modeling,3D viewer, Web GL, 3D Programming, 3D Development, 3D Media, 3D Web, GLSL, 3D Web Design, 3D Web Development, Web development, create 3D website, 3D Media, 3D animation, graphic design, Website design,
Learn 3D Programming Learn 3D Programming
Copyright © 2015 Seven Thunder Software. All Rights Reserved.