• 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
vNeeki

Rendering lots of pixels 1 by 1 ?

15 posts in this topic

Hi.

I need to do a couple of heavy writes pixel by pixel and i was wondering which could've been the most efficient approach , since from what i read draw/readPixels functions are deprecated and not supported by GLES which i eventually plan to port my code to.

Any recommendations on how to handle this case?
0

Share this post


Link to post
Share on other sites
[quote name='RobinsonUK' timestamp='1334041837' post='4929800']
[url="http://en.wikipedia.org/wiki/Shader"]Shader?[/url] :-).
[/quote]

Its a part of a particle system effect which i update every frame.
IIRC i'll have to set the position for the shader uniform(?) variable every frame to achieve this which will be very slow.
0

Share this post


Link to post
Share on other sites
Setting a uniform every frame isn't going to be slow. Can you describe in more detail exactly what you're doing? There are many potentially good approaches but without the full info it's hard to give you direction.
1

Share this post


Link to post
Share on other sites
[quote]
Can you describe in more detail exactly what you're doing?
[/quote]

I have a 2d map , and im doing some effects to pixel level.ie if you destroy a part of the map , that particular part will be split into smaller particles for a small amount of time.

And the problem is that some parts are very big(512x512) that cause everything to run at 20fps from 1000(!) for a small amount of time.

[quote]
Setting a uniform every frame isn't going to be slow
[/quote]
Are you sure that setting a uniform for[b]every particle every single frame [/b]won't cause a bottleneck?
0

Share this post


Link to post
Share on other sites
[quote name='vNeeki' timestamp='1334040290' post='4929794'] Hi. I need to do a couple of heavy writes pixel by pixel and i was wondering which could've been the most efficient approach , since from what i read draw/readPixels functions are deprecated and not supported by GLES which i eventually plan to port my code to. Any recommendations on how to handle this case? [/quote]

The best way would probably be to make a texture the size of your framebuffer, keep one copy of it in RAM and one on the GPU, make the changes to the in RAM texture and then update the texture on the GPU ( using [url="http://www.opengl.org/sdk/docs/man/xhtml/glTexSubImage2D.xml"]http://www.opengl.or...xSubImage2D.xml[/url] ) Updating the texture is fairly slow so you don't want to do it once per pixel, make all the changes first, mark the changed regions as dirty and only update the dirty regions. (you'll need to decide how to create the regions, one region per changed pixel will be extremely slow but if you have 1 pixel in the top left corner and one in the bottom right that is changed you probably don't want to put them in the same region as that region would become incredibly large)

Now since you are making a particle system you might want to consider increasing the size of the particles, reducing their numbers and just setting uniforms for them instead.

If you do need an insane number of particles then you pretty much have to run the entire particle simulation on the GPU (to avoid the transmission costs)
1

Share this post


Link to post
Share on other sites
[quote name='SimonForsman' timestamp='1334047280' post='4929817']
[quote name='vNeeki' timestamp='1334040290' post='4929794'] Hi. I need to do a couple of heavy writes pixel by pixel and i was wondering which could've been the most efficient approach , since from what i read draw/readPixels functions are deprecated and not supported by GLES which i eventually plan to port my code to. Any recommendations on how to handle this case? [/quote]

The best way would probably be to make a texture the size of your framebuffer, keep one copy of it in RAM and one on the GPU, make the changes to the in RAM texture and then update the texture on the GPU ( using [url="http://www.opengl.org/sdk/docs/man/xhtml/glTexSubImage2D.xml"]http://www.opengl.or...xSubImage2D.xml[/url] ) Updating the texture is fairly slow so you don't want to do it once per pixel, make all the changes first, mark the changed regions as dirty and only update the dirty regions. (you'll need to decide how to create the regions, one region per changed pixel will be extremely slow but if you have 1 pixel in the top left corner and one in the bottom right that is changed you probably don't want to put them in the same region as that region would become incredibly large)

Now since you are making a particle system you might want to consider increasing the size of the particles, reducing their numbers and just setting uniforms for them instead.

If you do need an insane number of particles then you pretty much have to run the entire particle simulation on the GPU (to avoid the transmission costs)
[/quote]

Oh wow those sound really great ideas , thanks ! ..Now atleast i've got something to try out [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]
0

Share this post


Link to post
Share on other sites
[quote name='vNeeki' timestamp='1334046929' post='4929813']
Are you sure that setting a uniform for[b]every particle every single frame [/b]won't cause a bottleneck?
[/quote]

Well you didn't say that first time round. [img]http://public.gamedev.net//public/style_emoticons/default/wink.png[/img]
But yeah, that will be slow.
1

Share this post


Link to post
Share on other sites
[quote][color=#282828][font=helvetica, arial, verdana, tahoma, sans-serif][size=3][left]Are you sure that setting a uniform for[/left][/size][/font][/color][b]every particle every single frame [/b][color=#282828][font=helvetica, arial, verdana, tahoma, sans-serif][size=3][left]won't cause a bottleneck? [/left][/size][/font][/color][/quote]

I'm kind-of wondering why this parameter needs to be a uniform at all. Perhaps it could be an element in your or a vertex stream?
1

Share this post


Link to post
Share on other sites
Yeah, if I were you I'd be using attributes, not uniforms.

I'd use the vertex shader to position the particles (just draw each particle as a triangle or a quad). Then if post processing was needed I'd use the fragment shader.

But of course, I might be drawing a different particle effect than you. So far you haven't described what kind of particle effect you're implementing, and some effects may be better implemented in different ways than other effects.
2

Share this post


Link to post
Share on other sites
[quote name='Cornstalks' timestamp='1334073739' post='4929925']
I'd use the vertex shader to position the particles (just draw each particle as a triangle or a quad). Then if post processing was needed I'd use the fragment shader.
[/quote]

This is more or less the way I'd do it too (the only thing I might change would be to add a geometry shader for the initial positioning and expand to a quad from there, but admittedly this won't fit with the requirement to move to GL ES).

The way I'd then set it up would be to calculate a bunch of properties for each particle in an emitter when the emitter is spawned; these might include initial position, velocity, direction, gravity, etc. They're stored out as vertex attributes one-time only here. Then for each emitter you would send a delta between the time now and the time when it was spawned as a uniform, using a combination of this delta and the properties (i.e. vertex attribs) to determine the particles current position. That should work well enough if you're not doing anything too fancy with them.
2

Share this post


Link to post
Share on other sites
I have implemented the buffer texture and it improved speed by over 40.00% which is great.There is a little flickering though but
i think that i will improve it over with a shader effect;)

[quote]
I'm kind-of wondering why this parameter needs to be a uniform at all. Perhaps it could be an element in your or a vertex stream?
[/quote]

[quote]

But of course, I might be drawing a different particle effect than you. So far you haven't described what kind of particle effect you're implementing, and some effects may be better implemented in different ways than other effects.
[/quote]

Some particle effects that i need , are :

-Building explosions
-Power up type that follow the player
-Item pick up type that follow the player

And i don't think that using a shader is a good idea , unless of course if its possible to texture map points(gl_points) since then i would
need 1point/particle and my vertice array would have 1/6 or 1/4 the size of my old implementation(1quad or 2tris / texture) (Would work with GLES too!) or not use vertices at all and use a client side array if that's possible?
0

Share this post


Link to post
Share on other sites
Instancing might help. At least it will cut down the number of draw calls. Have a google for it.
1

Share this post


Link to post
Share on other sites
[quote name='RobinsonUK' timestamp='1334130274' post='4930164']
Instancing might help. At least it will cut down the number of draw calls. Have a google for it.
[/quote]

Very interesting but won't work with GLES unless there are portable implementations.
0

Share this post


Link to post
Share on other sites
There's a [url="http://www.khronos.org/registry/gles/extensions/OES/OES_point_sprite.txt"]GL_OES_point_sprite[/url] extension which may be available, and looks like it can coexist relatively peacefully with regular point sprites. Personally I'd still just use textured quads, at least initially, and not worry too much about size of geometry and/or vertex shader ops until such a time as I had determined for certain that it would be a problem. Reason why is because in a particle system your primary bottleneck is far more likely to be fillrate, so focussing on the other stuff is a case of micro-optimizing something that probably isn't even a huge problem to begin with.
1

Share this post


Link to post
Share on other sites
[quote name='mhagain' timestamp='1334141531' post='4930199']
There's a [url="http://www.khronos.org/registry/gles/extensions/OES/OES_point_sprite.txt"]GL_OES_point_sprite[/url] extension which may be available, and looks like it can coexist relatively peacefully with regular point sprites. Personally I'd still just use textured quads, at least initially, and not worry too much about size of geometry and/or vertex shader ops until such a time as I had determined for certain that it would be a problem. Reason why is because in a particle system your primary bottleneck is far more likely to be fillrate, so focussing on the other stuff is a case of micro-optimizing something that probably isn't even a huge problem to begin with.
[/quote]

Thanks i'll have a look.
[img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]
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