VBO/Point sprites/alpha


Huge thanks for your help in my other threads guys. I have another question, this time i’m trying to put some alpha values on the color of the point sprites the code is generating with a VBO. Here the code for the VBO:

	glBlendFunc(GL_SRC_ALPHA, GL_ONE);
        glBindBufferARB(GL_ARRAY_BUFFER_ARB, vboId);


        	glNormalPointer(GL_FLOAT, 0, (void*)sizeof(vertices));
        	glColorPointer(3, GL_FLOAT, 0, (void*)(sizeof(vertices)+sizeof(normals)));
        	glVertexPointer(3, GL_FLOAT, 0, 0);
		float quadratic[] =  {1.0f, 0.0f, 0.01f};
		glPointParameterfvARB(GL_POINT_DISTANCE_ATTENUATION_ARB, quadratic );
		float maxSize = 0.0f;
		glGetFloatv(GL_POINT_SIZE_MAX_ARB, &maxSize );
		if(maxSize > 100.0f)
			maxSize = 100.0f;

		glPointParameterfARB(GL_POINT_FADE_THRESHOLD_SIZE_ARB, 60.0f);
		glPointParameterfARB(GL_POINT_SIZE_MIN_ARB, 1.0f);
		glPointParameterfARB(GL_POINT_SIZE_MAX_ARB, maxSize);
			glDrawArrays(GL_POINTS, 0, numPoints);

        glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);

I tried using the GL_BLEND function, and it worked. But the alpha is not working correctly in all direction. I would like to know if it is the right way of doing it or should i load the alpha from a shader?

According to your blending settings the final color will evaluate as follows:

FramebufferColor = PointSpriteAlpha * PointSpriteColor + 1 * FramebufferColor

If this is what you intended to use then its okay.
What I don’t know from this source listing is whether you have added a texture to the point sprite that has an alpha channel and with the proper values in it.

What is actually the problem? Can you attach some screenshot of what is rendered and explain what you would like to get?

there is no texture added to the point sprites. For now i’m just using a color array with 3 elements (RGB). I’ll try posting some screenshots.

As a single point sprite can have a single color specified, you will simply get trasparent/translucent point sprites, nothing more. Also, point sprites make sense only if you apply a texture to them as otherwise if you just want some colored points then you don’t need the point sprite extension at all as they are only for applying a texture on top of a point primitive.

Note: Okay, that’s not 100% true as if you use the point sprite texture coorindates in your fragment shader to do some nifty tricks (what I suppose you’ll want to do to make them look like illuminated spheres) then they make sense even without textures.

Ok, my project is working great. For now i’m able to draw the point sprites from a .txt file, and to move in the 3D space in spectator mode. The .txt file is containing 128x128x128 coordinates. So that makes 2097152 point sprites beiing rendered. The fps is still really good, between 70 to 120 fps. What i want to do now, is to be able to apply a fragment shader to make them appear as a sphere (right now they are just 2D square). Any ideas?

Texture the point sprite with a RGBA texture : A contains alpha, so that it draws a circular shape, and RGB contains XYZ compoents of normals.
In the fragment shader, discard if alpha <0.5 and compute lighting according to RGB normal.

Ok i was able to apply a RGBA texture to all point sprites. They are now small circle with alpha. I’m still trying to find how to apply a .vert and .frag to the point sprites. Going back to google…
Any ideas?

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