mrdoob/three.js — Issue #732: Use of Booleans as Uniform Variables in Shaders
Author: WestLangley
Created: 2011-11-07 20:00:18+00:00
State: open

I just purchased a new MacBook, replacing my 4-year-old MacBook. The first thing I wanted to do was to check out some of the "insanely great" three.js WebGL demos that would not render on my old machine. :-)

In doing so, I was surprised to find that Lambert material under WebGL would not render correctly on the new Mac. It renders completely flat -- no light shading at all. And this is in Safari, Firefox, and Chrome.

Here is one example of where it happens -- in the Lambert spheres at the bottom:

http://mrdoob.github.com/three.js/examples/webgl_materials_shaders.html

Here are my Mac specs:

RENDERER: Intel HD Graphics 3000 OpenGL Engine
VENDOR: Webkit (Intel Inc.)
VERSION: WebGL 1.0 (2.1 APPLE-7.12.9)
SHADING_LANGUAGE_VERSION: WebGL GLSL ES 1.0 (1.20)

If the GPU is not the problem, I wonder if the problem is the use of Booleans in the shader Uniforms?

The Uniform variable `enableLighting` in the Lambert vertex shader is an `int` on the Javascript side and a `bool` on the GLSL side. (On the JS side, `enableLighting` is assigned to equal the total number of lights, so it can be greater than one.)

On my new machine, the Boolean `enableLighting` is always `false` inside the shader. This is the problem.

If I change the shader code, and make `enableLighting` an integer, the problem is solved.

So the questions are:
1. Is the use of Booleans as uniform variables in GLSL a good idea?
2. Is my machine the problem?

Thanks.

WestLangley