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

Re: [Public WebGL] Re: Strange behaviour in Firefox



Hi,

Does it make a difference when you go to about:config and set webgl.shader_validator to false?

I am thinking that you might be hitting this ANGLE bug (fixed upstream but we havent synced yet):
https://bugzilla.mozilla.org/show_bug.cgi?id=594489

In short: if you are using a non-US locale that uses the comma as decimal separator, then ANGLE used to truncate floating point values specified in shaders. The easiest fix would be to replace 0.4 by 4/10.

Benoit


Hi, I think I found the solution: 
Webgl is obviously having troubles with stuff like

vLightWeighting = vec3(0.4,0.4,0.4);  or calculation based on these in shader defined values: vLightWeighting = vec3(0.4,0.4,0.4) * otherValues

but when I transfer 0.4,0.4,0.4 via an uniform-variable it works fine. So if the values are coming from outside/an uniform there is no problem:

vLightWeighting =myVec3UniformShaderValue* otherValues.

I don't know why it is like that..maybe it is a common phenomenon that I haven't noticed?




2010/10/30 M.Sirin <m.sirin07@googlemail.com>
Helllo!

WebGL is trying to draw something via:

<script id="shader-fs" type="x-shader/x-fragment">
  #ifdef GL_ES
  precision highp float;
  #endif
 
  varying vec3 vLightWeighting;
  varying vec3 customColor; 
  void main(void) {
   
    gl_FragColor = vec4(customColor * vLightWeighting, 1.0);
  }
</script>
 
<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);
      customColor=myAttributeColor;
    } 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;
      
    }
  }
</script>
 
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...