• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Medo Mex

Particle Engine, Creating alot of Rain/Snow

12 posts in this topic

I have created a particle engine, basically, it create ONE single vertex using CreateVertexBuffer() and rendering it as much as particles we need.

Using the class I assign the number of particles that I want to generate at once, I am using "for() { }" statement to generate that number each time like the following:

[CODE]
void RenderParticles(...)
{
// Some other codes goes here...

for(DWORD i = 0; i < maxNumOfParticles; i++)
CreateNewParticle();

}

[/CODE]
When I create a rain usually I set a high number for maxNumOfParticles number like 150-250, so I can have alot of rains rendering (if the weather is so rainy).

However, the rendering SLOW down when 'maxNumOfParticles' is high, making the game slow even on a modern graphic card. Edited by Medo3337
0

Share this post


Link to post
Share on other sites
It's hard to tell from this sample how you're using it. Are you instantiating objects every frame? Are you drawing each particle with a separate call instead of batching? Is each particle literally one raindrop? I would think that if you had a few different rain textures (each containing a few randomly scattered raindrops with alpha), players wouldn't notice that each raindrop wasn't an individual particle.
0

Share this post


Link to post
Share on other sites
[size=4]Each time DirectX render, I create particles according to [color=#000000][left]maxNumOfParticles, here is what I use on each frame:[/left][/color][/size]
[CODE]
for(DWORD i = 0; i < maxNumOfParticles; i++)
CreateNewParticle();
[/CODE]
0

Share this post


Link to post
Share on other sites
Hmm, I don't think we're quite on the same page. Here are my questions:[list=1]
[*]Does one particle = one raindrop?
[*]How many textures are you using for your particles?
[*]What does CreateNewParticle do?
[list=1]
[*]Are you allocating new vertices or textures in CreateNewParticle?
[*]Is each particle rendered as a separate batch? One thread on here concerned a developer who was drawing a circle using approximately 100 line segments. With begin and end after each line segment the speed was terrible. As one batch it was very fast.
[*]Does CreateNewParticle just perform rendering of an existing particle, or create a particle?
[*]Where is the code for moving a particle?
[/list]
[/list]
0

Share this post


Link to post
Share on other sites
1. Yes, one particle = one raindrop.
2. I am using only one texture for the rain, each particle (raindrop) set the same texture.
3.
1. Only ONE single vertex created at loading time, and used in rendering to create different raindrops.
3. [color=#282828][font=helvetica, arial, verdana, tahoma, sans-serif][size=3][left][background=rgb(250, 251, 252)]CreateNewParticle() ONLY create new particles and it does that only during rendering process.[/background][/left][/size][/font][/color]
[color=#282828][font=helvetica, arial, verdana, tahoma, sans-serif][size=3][left][background=rgb(250, 251, 252)] 4. The code for moving particles is inside RenderParticles() method[/background][/left][/size][/font][/color]
[color=#282828][font=helvetica, arial, verdana, tahoma, sans-serif][size=3][left][background=rgb(250, 251, 252)]Basically, I ONLY create ONE single vertex for ALL the particles, this vertex is rendered as many as the particles with different matrix world so I can get the particles to move in different positions, I am using point sprite.[/background][/left][/size][/font][/color]
0

Share this post


Link to post
Share on other sites
The key question being asked here is how many draw calls do you have? Do you have one draw call that handles all of your particles, or do you have one draw call per-particle? The fact that you have a different matrix for each particle suggests the latter, in which case - yes - it's going to perform terribly. You really need to post the code you have for CreateNewParticle and RenderParticle here - and the full code, not just an excerpt. It's not enough to describe what they do as it's not possible to correctly analyse why you're running slow based on a mere description - hence all the questions.
0

Share this post


Link to post
Share on other sites
As pointed out above, it seems as though you are rendering and updating for each particle! Think about that and you will see why it will slow down. If you have 10,000 particles, each one has to create a new transformation matrix (10,000+ operations) and each one will render itself separately(10,000+ draw calls).

Most modern particle systems use the GPU for both rendering and calculating positions. And then some sort of particle collision system on the CPU. Using the GPU , you will then batch alot of particles together, in a DynamicVertexBuffer which will be sent to the graphics card at once! Turning 10,000 draw calls into maybe 2 or 3!
You should post both the CreateNewParticle and RenderParticle methods. Edited by dAND3h
1

Share this post


Link to post
Share on other sites
I'm confused because in your other post (that I just repied to) you stated you were using Point Sprites. In this post your refering to vertices, implying quads. In any event, like the above posts, we'll need to see your render function at the very least. Performing a transformation and a draw call for each particle is highly inefficient.
0

Share this post


Link to post
Share on other sites
So I'm reading this and wondering. Would the best way to do this be to have 1 particle and instance it with separate transformation matrices? Sorry if I just hijacked your thread.
0

Share this post


Link to post
Share on other sites
[quote name='Hornsj3' timestamp='1339175324' post='4947418']
So I'm reading this and wondering. Would the best way to do this be to have 1 particle and instance it with separate transformation matrices? Sorry if I just hijacked your thread.
[/quote]

I'd use a list of particles, updating their positions in a dynamic vertex buffer, calculate the world matrix once and then draw with the D3DDevice->DrawIndexedPrimitive (triangle list) method. But depending on your target hardware and version of DX, you can do almost all of it on the GPU these days. Edited by DJTN
0

Share this post


Link to post
Share on other sites
I personally use one vertex (containing initial position, velocity, gravity factors, acceleration, time-since-spawn, etc) with forward/left/up values as shader constants, combined with instancing - everything is computed on the GPU from there and up to 16384 (arbitrary choice) particles are drawn per draw-call. There's no need whatsoever for any matrix changes and it runs faster than a slippery snot on a slope. :)

Again - show some more code, and how many draw calls?
0

Share this post


Link to post
Share on other sites
I think the other posters are on the same page as me. You may be making savings on the CPU by using a single vertex, but you're punishing the GPU by making many separate draw calls. It would probably run better if you had 200 vertices but pushed them through in a single batch.
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0