[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Public WebGL] Strange behaviour in Firefox


WebGL is trying to draw something via:

<script id="shader-fs" type="x-shader/x-fragment">
  #ifdef GL_ES
  precision highp float;
  varying vec3 vLightWeighting;
  varying vec3 customColor; 
  void main(void) {
    gl_FragColor = vec4(customColor * vLightWeighting, 1.0);
<script id="shader-vs" type="x-shader/x-vertex">
  attribute vec3 aVertexPosition;
  attribute vec3 aVertexNormal;
  attribute vec3 myAttributeColor;
  uniform mat4 uMVMatrix;
  uniform mat4 uPMatrix;
  uniform mat4 uNMatrix;

  uniform vec3 uPointLightingColor;
  uniform bool uUseLighting;
  varying vec2 vTextureCoord;
  varying vec3 vLightWeighting;
  varying vec3 customColor;
  void main(void) {
    vec4 mvPosition = uMVMatrix * vec4(aVertexPosition, 1.0);
    gl_Position = uPMatrix * mvPosition;
    vec3 directionalVector = vec3(-0.7, -0.7, 0.9);
    if (!uUseLighting) {
      vLightWeighting = vec3(1.0, 1.0, 1.0);
    } else {
      vec3 lightDirection=normalize(directionalVector - mvPosition.xyz);
      vec4 transformedNormal = uNMatrix * vec4(aVertexNormal, 0.0);
      customColor = uPointLightingColor;
      float directionalLightWeighting = max(dot(transformedNormal.xyz, lightDirection), 0.0);
      vLightWeighting = vec3(0.4,0.4,0.4) + directionalLightWeighting;
This is working for Firefox 4.0b6, Minefield 4.0b8pre and Chromium 9.0.564.0 (63713). But the appearence of the objects is different between Chromium and Firefox, so i tried to change some lightening calculations like something simple like this: vLightWeighting = vec3(0.4,0.4,0.4); //just removed the additional term. Or just doing stuff like
vec3 lightDirection=directionalVector;
But this is weirdly leading all Firefox versions to that error that I once had: Nothing is drawn and "UniformMatrix4fv: location: null object passed as argument" is coming again.  Chromium is doing his job properly without such an error.

Why the hell such little caculations should cause these ugly stuff?

I'm going crazy with that...