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

Re: [Public WebGL] After installing latest Minefield : VertexAttribPointer: index out of range



Okay, here it is:


<script id="shader-fs" type="x-shader/x-fragment">

   #ifdef GL_ES
   precision highp float;
   #endif
  
   varying vec3 vLightWeighting;
   varying vec3 myColor;

   void main(void) {
    gl_FragColor = vec4(myColor * vLightWeighting, 1.0);
   }
</script>

<script id="shader-vs" type="x-shader/x-vertex">
  attribute vec3 vertexPosition;
  attribute vec3 vertexNormale;
  attribute vec3 vertexColor;

  uniform mat4 modelViewMatrix;
  uniform mat4 projektionsMatrix;
  uniform mat4 normalenMatrix;
  uniform vec3 ambientLight;
 
  uniform vec3 constantColor; 
  uniform bool useUniformColor;
  uniform bool selecting;

  varying vec3 vLightWeighting;
  varying vec3 myColor;

  void main(void) {

      vec4 mvPosition=modelViewMatrix*vec4(vertexPosition,1.0); 
      gl_Position = projektionsMatrix * mvPosition;

      vec3 ambientColor = ambientLight;
      vec3 directionalLightColor = vec3(0.6, 0.6, 0.6);
      vec3 directionalVector = vec3(-0.7, -0.7, 0.9);

      // if(useUniformColor){
          myColor=constantColor;
      //}
      //else{ myColor=vertexColor;} 
      
      if(selecting){
          vLightWeighting=vec3(1.0,1.0,1.0);
      }else{
          vec3 lightDirection=normalize(directionalVector - mvPosition.xyz); 
            vec4 transformedNormal = normalenMatrix * vec4(vertexNormale, 1.0);

          float directionalLightWeighting = max(dot(transformedNormal.xyz, lightDirection), 0.0);    
          vLightWeighting = ambientLight + (directionalLightColor * directionalLightWeighting);
      }
  }

</script>

I think there is nothing odd with that? Again: It work's with Firefox 4.0b3 and Chromium. 
-----------

Then I've got another question: In case I remove the comments  

      // if(useUniformColor){
           myColor=constantColor;
      //}
      //else{ myColor=vertexColor;} 

Nothing is working with Chromium any more. That means there are no visible objects on screen, only the ones drawn via "vertexColor" . In my application there are 3 objects that uses this color-Attribute. Then I want to draw some objects via color that is sent with uniform to the shader (uniform vec3 constantColor; ) . Of course I first do     gl.disableVertexAttribArray(shaderProgram.vertexColorAttribute);  but still all of a sudden chromium is not drawing these objects.. 

Maybe you know why?

2010/10/24 Vladimir Vukicevic <vladimir@mozilla.com>


----- Original Message -----
> That is the shader program code:

I meant the GLSL code -- that is, whatever's in your shader-fs and shader-vs blocks.

   - Vlad