Added: 2 years ago
From: StanfordUniversity
Views: 7,738
Sort by time | Sort by thread (beta)

Link to this comment:

Share to:

All Comments (9)

Sign In or Sign Up now to post a comment!
  • Hello very nice article!

    in my project my quads only rotate at fixed intervals (like it was sectioned), also the sprite is mirrored.

    i had a look at rotation code, but its somewhat magical and I dont know how to fix it, any hints? Thanks

  • Doesn't the iPhone have buffer objects? It still doesn't sound fast to have all those vertex/tex coord/rgba data in arrays in client memory, modify it all the time (doing all the translation/rotation computations on the client), and then uploading it over and over again.

  • He answers most of my question starting at 32:00. Sorry for not listening to all the talk before posting. It's still not clear to me why he's not using VBOs in the fireworks demo. Would the necessary transformation changes end up being too slow?

    Thanks a lot to ngmoco, and to Stanford for making all these videos available for free.

  • Good stuff for people to know. One thing tho, you are doing 4 sin and 4 cos per particle. Those are costly calls. You can do only 1:

    float sinTheta = sinf(rotation * TO_RADIANT) * size * .5f;

    float cosTheta = cosf(rotation * TO_RADIANT) * size * .5f;

    m_vertexArrayPtr[0] = x - cosTheta - sinTheta;

    m_vertexArrayPtr[1] = y + sinTheta - cosTheta;

    m_vertexArrayPtr[2] = x - cosTheta + sinTheta;

    m_vertexArrayPtr[3] = y + sinTheta + cosTheta;

    m_vertexArrayPtr[4] = x + cosTheta + sinTheta;

    ...

  • @daivuk

    tried the code: float sinTheta = sinf(angle2) * spr->height * .5f; float cosTheta = cosf(angle2) * spr->width * .5f; topLeftX = x - cosTheta - sinTheta; topLeftY = y + sinTheta - cosTheta; topRightX = x - cosTheta + sinTheta; topRightY = y + sinTheta + cosTheta; bottomLeftX = x + cosTheta + sinTheta; bottomLeftY = y - sinTheta + cosTheta; bottomRightX = x + cosTheta - sinTheta; bottomRightY = y - sinTheta - cosTheta;

    but my sprites are rotated wrong and sliced

  • In fact, since there's so much overdraw in this particular demo, you could draw this into an FBO at a smaller resolution, and then upscale using the hardware with bilinear filtering. Since the particles are fuzzy anyway, you probably wouldn't notice the difference, yet the speed should be a lot better.

  • Note that the particles can also be drawn using a single triangle instead of 2. just because the texture is square, doesn't mean that the triangle has to be too.. ... Especially since the texture itself contains a circular shape.

  • @TheLogicalError Then you will get more pixel coverage, more lag. Drawing 2 triangles is more optimized. Pixels with zero alpha are processed anyway, remember that.

  • I think you overestimate the amount of extra overdraw for a single triangle

Loading...
Alert icon
0 / 00Unsaved Playlist Return to active list
    1. Your queue is empty. Add videos to your queue using this button:
      or sign in to load a different list.
    Loading...Loading...Saving...
    • Clear all videos from this list
    • Learn more