Page 2 of 2 FirstFirst 12
Results 11 to 12 of 12

Thread: gl_PointSize problem

  1. #11
    Member Coolcat's Avatar
    Join Date
    Oct 2009
    Location
    NRW, Germany
    Posts
    75

    Re: gl_PointSize problem

    Yes, I was successful rendering point sprites. That glEnable-thing is not required. However, point sprites can only have a size of 1 pixel, which makes them useless.

    For WGT I'm using a static VBO which is created as follows:
    Code :
    WebGLFloatArray wglVertices = WebGLFloatArray.create(pointCapacity * 3 * 4);
    for (int idx=0; idx<pointCapacity; ++idx) {
    	int i = idx*12;
    	wglVertices.set(i+ 0, -1.0); wglVertices.set(i+ 1,  1.0); wglVertices.set(i+ 2, idx);
    	wglVertices.set(i+ 3, -1.0); wglVertices.set(i+ 4, -1.0); wglVertices.set(i+ 5, idx);
    	wglVertices.set(i+ 6,  1.0); wglVertices.set(i+ 7,  1.0); wglVertices.set(i+ 8, idx);
    	wglVertices.set(i+ 9,  1.0); wglVertices.set(i+10, -1.0); wglVertices.set(i+11, idx);
    }

    These vertices are transformed in the vertexshader according to an uniform array containing the actual positions:
    Code :
    uniform mat4 uModelViewProjection;
    uniform vec2 uRadius;
    uniform vec3 uCoords[100];
     
    attribute vec3 aPosition;
    varying vec2 vTexCoord;
    void main() {
    	int index = int(aPosition.z);
    	gl_Position = uModelViewProjection * vec4(uCoords[index], 1.0);
    	gl_Position /= gl_Position.w;
    	gl_Position.xy += uRadius * aPosition.xy;
    	vTexCoord = aPosition.xy * 0.5 + 0.5;
    }

    This does work fine, the only problem is that the number of uniforms is limited. However, MAX_VERTEX_UNIFORM_VECTORS is at least 128, so it should be save to render 100 points at once. The render larger point clouds you could tried to use textures to store the coordinates. But, that's complicated because float textures are not available.

  2. #12
    Junior Member
    Join Date
    Feb 2010
    Posts
    2

    Re: gl_PointSize problem

    Oh yeah...you're right. Without the glEnable it does draw the sprites. I just couldn't see them at 1 pixel until I looked really close. Thanks for your response, Coolcat.

Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •