Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Drawing VertexArrays using Textures or Without  (Read 3022 times)

0 Members and 1 Guest are viewing this topic.

13bgarli

  • Newbie
  • *
  • Posts: 3
    • View Profile
Drawing VertexArrays using Textures or Without
« on: October 28, 2013, 07:37:03 pm »
So I'm working on a Particle system for my game, and it works great for the most part until I added the feature for passing a texture to the VertexArray, at which point if the Vertices are scaled to sizes such as 5x the texture size with 30,000 "particles" the game will use 100% GPU (I have an AMD 7870xt which is good enough for almost anything on Ultra) while not passing a texture works great with up to nearly one-million particles at which point the step for each particle takes more time than the render does. I'm using SFML 2.1

The way it works is when the particle "system" tells a particle to step it will add its vertices with the transformations such as scale and color transitions to the particle system's VertexArray. Then after everything was sent to the Particle System's array it is rendered to the screen using "window.draw(vArray, &texture);"

Thanks guys!

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Drawing VertexArrays using Textures or Without
« Reply #1 on: October 28, 2013, 07:55:26 pm »
If particles are not scaled, i.e. if less pixels are drawn, do you get the same performances with and without texture?
Laurent Gomila - SFML developer

13bgarli

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Drawing VertexArrays using Textures or Without
« Reply #2 on: October 28, 2013, 08:10:00 pm »
Yeah exactly, the way my test code is set up is it bursts 30,000 particles that start on size Vector2f(1.f, 1.f) then slowly transition to the next size if there was another size assigned to it, I noticed that if I go smaller like Vector2f(0.5f, 0.5f) it works alright fine, but the large scaling (5x and above) causes horrible performance.
There is slightly more performance using no texture over using a texture at these smaller sizes but not a whole lot of impact.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Drawing VertexArrays using Textures or Without
« Reply #3 on: October 28, 2013, 09:05:43 pm »
Ok, so it seems like you're limited by the amount of textured pixels that you draw. I guess you could reduce it by not drawing hidden pixels (you must have a lot of overdraw with 30000 big particles), but I'm not sure how you would do it with SFML; it may not be possible.

Another option is to avoid drawing particles that are out of the view, if you have some.
Laurent Gomila - SFML developer

13bgarli

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Drawing VertexArrays using Textures or Without
« Reply #4 on: October 28, 2013, 09:55:13 pm »
Yeah I've been thinking about the overdraw with that many particles, half the time I barely get like 2,000 on screen at one time and those are the smaller ones Haha. Thanks for the feedback!