User avatar
paddyg
Posts: 2330
Joined: Sat Jan 28, 2012 11:57 am
Location: UK

pi3d sprites using gl point textures

Tue Mar 24, 2015 5:07 pm

vlcsnap.jpg
vlcsnap.jpg (26.8 KiB) Viewed 1372 times
This cropped up ages ago as a bit of a deficiency of pi3d but it seems to work reasonably well now.

Rather undocstringed as yet: https://github.com/pi3d/pi3d_demos/blob ... teBalls.py The real power of numpy starts to come into its own as the size the array increases. If inter-ball interactions (which scale as N squared) are toggled off and it's running on RPi2 it can cope with 1,000 balls at over 30fps!

PS just tried it at 4,000 balls, still seems to run fine
also https://groups.google.com/forum/?hl=en-GB&fromgroups=#!forum/pi3d

toxibunny
Posts: 1382
Joined: Thu Aug 18, 2011 9:21 pm

Re: pi3d sprites using gl point textures

Wed Mar 25, 2015 7:08 am

That's amazing. Would it greatly affect performance to add rotation? It's at least indirectly possible : http://stackoverflow.com/questions/1126 ... -gl-points
note: I may or may not know what I'm talking about...

User avatar
paddyg
Posts: 2330
Joined: Sat Jan 28, 2012 11:57 am
Location: UK

Re: pi3d sprites using gl point textures

Wed Mar 25, 2015 8:07 am

@toxibunny, that's a really neat solution. I had vaguely thought about this Yesterday and assumed it wouldn't be possible. The only way to see how much performance impact there will be is to try it, but I would have thought it would be fairly small. Even with 4,000 points the gpu doesn't seem to be going flat (on RPi2B but same gpu on RPiB)

At the moment I'm just passing an n x 3 array for xyz vertex location To rotate sprites independently there would need to be an additional per vertex value so I will hijack the normals and use that... which means I could rotate the sprites in three dimensions, which would be neat using autumnal leaves or snowflakes - but maybe for later!
also https://groups.google.com/forum/?hl=en-GB&fromgroups=#!forum/pi3d

User avatar
paddyg
Posts: 2330
Joined: Sat Jan 28, 2012 11:57 am
Location: UK

Re: pi3d sprites using gl point textures

Wed Mar 25, 2015 10:11 am

vlcsnap2.jpg
vlcsnap2.jpg (54 KiB) Viewed 1290 times

Well that was easy enough.

The result is quite mind boggling. In the youtube vid what I mumble is basically:
1. 100 sprites (with collision detection) ED, somehow failed to stick that bit on, take my word it's pretty much as per non-rotating uploaded full version!!
2. 1,000 sprites (no collisions as it slows it down a lot)
3. 4,000 sprites
4. 6,000 sprites.
I tried it with 8,000 but got a seg fault - maybe it overflowed something in the gpu.
also https://groups.google.com/forum/?hl=en-GB&fromgroups=#!forum/pi3d

toxibunny
Posts: 1382
Joined: Thu Aug 18, 2011 9:21 pm

Re: pi3d sprites using gl point textures

Wed Mar 25, 2015 8:57 pm

I saw the video - thanks for the shoutout, and good work! I think I'll dust the old model A off and give it a try...
note: I may or may not know what I'm talking about...

User avatar
paddyg
Posts: 2330
Joined: Sat Jan 28, 2012 11:57 am
Location: UK

Re: pi3d sprites using gl point textures

Wed Mar 25, 2015 11:04 pm

The version on github.com/pi3d/pi3d_demos develop branch called SpriteRotate.py now has default behaviour to rotate to align with the direction of travel. (toggle rotation mode with 's', interaction with 'i', other key to inc temperature) This makes it look extraordinarily like insects rushing around - quite unnerving!

There's obviously other info that could be passed to the sprites 'at no extra cost' along with, or instead of rotation.
also https://groups.google.com/forum/?hl=en-GB&fromgroups=#!forum/pi3d

User avatar
AndyD
Posts: 2331
Joined: Sat Jan 21, 2012 8:13 am
Location: Melbourne, Australia
Contact: Website

Re: pi3d sprites using gl point textures

Wed Mar 25, 2015 11:11 pm

Hi paddyg, that is good work. Sorry to interrupt your thread with a spruik to my own software. If you want to create screenshots of OpenGL ES output on the Raspberry Pi, I have written a program called raspi2png that will make a screen capture to a PNG file. Possibly easier than taking photographs of your screen. Hope that is helpful.

User avatar
paddyg
Posts: 2330
Joined: Sat Jan 28, 2012 11:57 am
Location: UK

Re: pi3d sprites using gl point textures

Thu Mar 26, 2015 7:48 am

@AndyD, Thanks, that looks very good, I will have a play with it. There is a screenshot function in pi3d but I suspect your C code will be faster.

I have made videos a couple of times by saving sequential frames to jpg then reassembling them. The problem is that the result is always really smooth and at high frame rate, however poor the animation in reality. i.e. the before and after video at the top only works if I video the screen with a camera!
also https://groups.google.com/forum/?hl=en-GB&fromgroups=#!forum/pi3d

User avatar
paddyg
Posts: 2330
Joined: Sat Jan 28, 2012 11:57 am
Location: UK

Re: pi3d sprites using gl point textures

Wed Apr 01, 2015 1:12 pm

vlcsnap3.jpg
vlcsnap3.jpg (21.68 KiB) Viewed 1077 times
NB this is on a type 1 RPi

I've added sprite sheet/atlas functionality, variable alpha and decoupled size and depth (as well as position and rotation as before). As demo SpriteMulti.py

This system should be able to support quite a complicated game in python on the RPi
also https://groups.google.com/forum/?hl=en-GB&fromgroups=#!forum/pi3d

Return to “Python”