Dealing with multiple primitives


I have a scene containing a 3d texture cube and a few basic primitives (lines, squares…). I have no problem in rendering each primitive individually. What is the best way to render all the primitive in the scene in shaders? Is the following fragment shader possible?


uniform float Primitive_Id;
varying float LightIntensity;

void main()                                                                       
 if (Primitive_Id == 0)                                         
  vec4 color = texture1D(oPalette3d,   texture3D(oTexture3d, gl_TexCoord[0].xyz));
  gl_FragColor = vec4(vec3(color) * (LightIntensity),color[3]);                 
 gl_FragColor = (1.0,0.0,0.0,1.0);                                              


Where the Primitive_ID is passed before drawing each primitive.

whilst u could do that (but use a int instead of a float for an id)
youre prolly better off by making 2 seperate shaders and drawing all objects with shader A first and then all objects with shader B

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.