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

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



I don't think your problem can be that simple.  I use vector constants
like that all the time in literally dozens of shaders, using both Chrome
and Firefox - on five different GPU's and under two different OS's, both
with and without the validator - and I don't see any problems as a result!
 If this was really the problem, surely I'd be seeing anomalous results on
at least one of those setups...and I'm not.

At a guess, I'd say that your JavaScript code for binding and setting the
uniforms and/or linking the shader program is broken somehow.

Adding more uniforms to replace those constants is re-ordering where the
uniforms are bound - and probably shaking up the underlying bug into a
different and less obviously harmful pattern.  I don't think you've fixed
your problem by replacing the vector constants with uniforms...I bet it
comes back on some other combination of GPU/OS/browser.

  -- Steve


> 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...
>>
>>
>



-----------------------------------------------------------
You are currently subscribed to public_webgl@khronos.org.
To unsubscribe, send an email to majordomo@khronos.org with
the following command in the body of your email: