View Full Version : Dealing with multiple primitives

08-28-2005, 02:17 AM

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.

08-29-2005, 11:24 AM
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