Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


DemonDar

Member Since 08 Dec 2011
Offline Last Active Private

Posts I've Made

In Topic: Triangles can't keep up?

16 January 2015 - 05:02 PM

Updating particles:

Read from buffer A and feedback to buffer B

Render partices:

Read from buffer B and feedback to buffer C

Render Quads from buffer C

 

- Next time update from B to A.

 

 

yes you'll use 3 buffers instead of 2,  wasting few KB to save your mind sanity for no performance hit I thnik is worth


In Topic: Triangles can't keep up?

15 January 2015 - 07:29 PM

 

returns inside the shader the index of the currently vertex beign processed, since the 4 vertices are "interleaved" you render inside feedback buffer with "Option1" and you use the index information ( modulo by 4) to discriminate wich vertex you are processing (A,B,C or D) so that you can finally apply some offset even if you see only 1 vertex at a time


That part I understood, I was already doing that for a stateless version of my particle system before I changed to the state saving one.
I never understood the actually buffer setup part, the part where 4 points placed in the feedback buffer got read and turned into a single quad during the render method but...

I took a nap, ate some oranges, thought about it some more and got it working. I ended up just making my buffer think that an entire quad was a single point in my render method. Then when the buffer was used in my update method it saw things as normal

 

That's exactly what I meant, since the buffer are just 4 same vertices you just need to render it as  Quads :D


In Topic: Triangles can't keep up?

15 January 2015 - 01:55 PM

gl_VertexID

returns inside the shader the index of the currently vertex beign processed, since the 4 vertices are "interleaved" you render inside feedback buffer with "Option1" and you use the index information ( modulo by 4) to discriminate wich vertex you are processing (A,B,C or D) so that you can finally apply some offset even if you see only 1 vertex at a time


In Topic: Triangles can't keep up?

12 January 2015 - 03:49 AM

@noodle, in my last code snippet I figured a way, basically you have to use the feedback of particles 4 times. Instead of having the 4 positions for each vertex, you write the same position 4 times (at least this is how I interpreted Hodgman suggestion).

 

_______

Option1 (interleaved)

const GLchar* vertexShaderSrc = "
    in vec2 inValue;
    out vec2 outVertexA;
    out vec2 outVertexB;
    out vec2 outVertexC;
    out vec2 outVertexD;

    void main() {
        vec2 pos = (MVP*vec4(inValue)).xy;
        outVertexA = pos;
        outVertexB = pos;
        outVertexC = pos;
        outVertexD = pos;
    }
);"
glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, tbo);
glBeginTransformFeedback(GL_POINTS);
glDrawArrays(GL_POINTS, 0, particleCount);
glEndTransformFeedback();

//...
GLshort *indices[particleCount*6] = { 0,1,2, 1,2,3,  4,5,6,  5,6,7 /*...*/};

________________

Option2 (not-interleaved):

const GLchar* vertexShaderSrc = "
    in vec2 inValue;
    out vec2 outVertex;


    void main() {
        vec2 pos = (MVP*vec4(inValue)).xy;
        outVertex = pos;
    }
);"
glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, tbo);
glBeginTransformFeedback(GL_POINTS);
glDrawArrays(GL_POINTS, 0, particleCount);
glDrawArrays(GL_POINTS, 0, particleCount);
glDrawArrays(GL_POINTS, 0, particleCount);
glDrawArrays(GL_POINTS, 0, particleCount);
glEndTransformFeedback();

//...
GLshort *indices[particleCount*6] = { 0,particleCount,particleCount*2,     particleCount,particleCount*2,particleCount*3,
                                                             1,1+particleCount,1+particleCount*2,     2+particleCount,2+particleCount*2,2+particleCount*3,};

In Topic: Triangles can't keep up?

11 January 2015 - 07:22 PM

Don't know If you were replying to me, but I forgot I can just get Index and then do %4.. thanks! That way there's no need for "offsetLookup" component: )


PARTNERS