User avatar
tipam
Posts: 99
Joined: Fri Dec 30, 2011 1:32 pm
Contact: Website

Pi3D ES 2.0

Tue Jul 17, 2012 8:44 pm

Pi3D ES 2.0 (or Pi3D2 for short)
========================

A new version of Pi3D is underway that works with OpenGL ES 2.0 only. That means shaders and potentially much better graphics! As usual, Pi3D2 has been designed to make programming ES2.0 very simply using just a few lines of code. There will be several useful shaders such as per-pixel texture shading, bump-mapping, fog and a host of others including post-processing (bloom for example).

:mrgreen: Once again a HUGE thank you to Peter de Rivaz who provided the base code to get things going on ES 2.0!! :mrgreen:

Here's a first shot as proof of concept and an example Pi3D2 program (below)

Tim Skillman.

Image

Code: Select all

#Hello World Example using OpenGL ES 2.0
#=================================
import pi3d2

display = pi3d2.display()
display.create(100,100,800,600)

camera = pi3d2.camera((0,0,0),(0,0,-15),(1,1000,60))        #Look at(at,from), Projection(near,far,fov)
light = pi3d2.light((100,40,-20))
scene = pi3d2.scene(camera,light)

earthshader = pi3d2.shader("basicShadeTexture",["textures/world_map.jpg"],scene)
earth = pi3d2.createSphere(5.0,32,32,0.0,"",0,0,0)

keys = scene.keys()

while True:
    display.clear()
    
    earth.draw(earthshader)
    earth.rotateIncY(0.2)

    if mykeys.read()==27:
                scene.close()
                display.close()
                                
    display.swapBuffers()
Raspberry Pi == small computer == big dreams

Norefall
Posts: 43
Joined: Sun Nov 06, 2011 12:19 pm

Re: Pi3D ES 2.0

Sat Jul 21, 2012 8:26 am

Keep up the good work! Btw, does it support normal and spec map?

User avatar
tipam
Posts: 99
Joined: Fri Dec 30, 2011 1:32 pm
Contact: Website

Re: Pi3D ES 2.0

Sat Jul 21, 2012 9:16 am

Norefall wrote:Keep up the good work! Btw, does it support normal and spec map?
... I'm hoping to implement an easy way of passing shader parameters so you can program them to have multiple textures, normal maps, matrices and so on. Pi3D2 will probably start off with some built in shaders that are commonly used plus a few fancy ones!!
Tim
Raspberry Pi == small computer == big dreams

JamesR
Posts: 78
Joined: Sun Aug 05, 2012 11:21 pm

Re: Pi3D ES 2.0

Tue Dec 11, 2012 12:05 pm

Tim,
Would it be possible to add an element of gravity to the Tiger Tank?
If from Pong we have

Code: Select all

dsy -= gravity

I suppose that the actual speed the tank travels at affects all this. Is it purely a case of adding the bouncing physics loop with a low bounce or can the tank have weight?

Can we have a quick look at how the opening doors look, so I understand it.

Code: Select all

pi3d.lodDraw3xyz(-xm,-ym,-zm,0,0,0,opendist,cor_cross,1000,cor_cross_doors)
	cor_win.draw(None,None,0,0,-spc*1.5)
	corridor.draw(None,None,0,0,-spc*2.5)
	cor_win.draw(None,None,0,0,-spc*3.5)
	pi3d.lodDraw3xyz(-xm,-ym,-zm,0,0,-spc*5,opendist,cor_cross,1000,cor_cross_doors)
code]

The first line pi3d.lodDraw3xyz positions the door itself. The next line then defines where the models are loaded in terms of a distance of the door from the camera? As the distance changes a different model is loaded? It doesn't quite makes sense in terms of reading the standard door and its movement apart from there being different door types.

User avatar
tipam
Posts: 99
Joined: Fri Dec 30, 2011 1:32 pm
Contact: Website

Re: Pi3D ES 2.0

Tue Dec 11, 2012 6:57 pm

Yes, it would great to add some physics such as gravity - I've yet to angle/pitch the tank to the ground which would also be useful.

As for the Mars station doors - I've not hinged or animated anything - I'm just replacing one model with another as I approach. In other words, the high-poly model has no door whereas the low-poly model does. This is a cheap 'trick' to speed things up by not rendering inside detail. The ideal would be to have a sliding door open as the hi-poly model is approached.
Raspberry Pi == small computer == big dreams

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

Re: Pi3D ES 2.0

Tue Dec 11, 2012 7:35 pm

Hi, I'm just in the process of working my way through the tigertank demo, converting it to the new ES 2.0 format (so appropriate thread!). It's probably a matter of transferring the functionality bit by bit and I haven't started on the level of detail stuff. However it had occurred to me that the tank demo would look much better with tilt and roll and it might be quite easy to do this with the clashTest method in the map as it returns a normal vector. So you could well be right james though I expect it will be messy to do.
also https://groups.google.com/forum/?hl=en-GB&fromgroups=#!forum/pi3d

User avatar
tipam
Posts: 99
Joined: Fri Dec 30, 2011 1:32 pm
Contact: Website

Re: Pi3D ES 2.0

Tue Dec 11, 2012 7:46 pm

JamesR wrote: Can we have a quick look at how the opening doors look, so I understand it.

Code: Select all

pi3d.lodDraw3xyz(-xm,-ym,-zm,0,0,0,opendist,cor_cross,1000,cor_cross_doors)
	cor_win.draw(None,None,0,0,-spc*1.5)
	corridor.draw(None,None,0,0,-spc*2.5)
	cor_win.draw(None,None,0,0,-spc*3.5)
	pi3d.lodDraw3xyz(-xm,-ym,-zm,0,0,-spc*5,opendist,cor_cross,1000,cor_cross_doors)
code]

The first line pi3d.lodDraw3xyz positions the door itself. The next line then defines where the models are loaded in terms of a distance of the door from the camera? As the distance changes a different model is loaded? It doesn't quite makes sense in terms of reading the standard door and its movement apart from there being different door types.[/quote]

... uh! I just finished editing the last post when it said 'you can no longer reply' losing all my text!  Here goes again ...

[b]lodDraw3xyz[/b] works by supplying 2-3 models with viewing distances that define which model (of differing Level's Of Detail - LOD) is displayed.  The parameters of lodDraw3xyz are as follow;

xm,ym,zm (eye position)
x,y,z (model position )
distance1 (model1 is drawn until this distance is exceeded)
model1 (Hi-poly model - as its the closest)
distance2 (model2 is drawn until this distance is exceeded)
model2 (Medium-poly model)
distance3(optional) (model3 is drawn until this distance is exceeded)
model3(optional) (Low-poly model)

The other models, that don't have LOD equivalents, are simply drawn.

Hope that helps!

Tim
Raspberry Pi == small computer == big dreams

JamesR
Posts: 78
Joined: Sun Aug 05, 2012 11:21 pm

Re: Pi3D ES 2.0

Tue Dec 11, 2012 10:23 pm

It does, although I'm sure I'll still be scratching my head when I one to utilise these things. But I'm sure people can help.

Thanks

User avatar
tipam
Posts: 99
Joined: Fri Dec 30, 2011 1:32 pm
Contact: Website

Re: Pi3D ES 2.0

Wed Dec 12, 2012 12:00 am

Just updated Pi3D with a few new features and cleanups! You can add a splash screen to the TK window and the TigerTank demo has a sniper view, target, FPS readout and map. You can get the zip download at http://www.github.com/tipam/pi3d

Image

Image

Image
Raspberry Pi == small computer == big dreams

JamesR
Posts: 78
Joined: Sun Aug 05, 2012 11:21 pm

Re: Pi3D ES 2.0

Wed Dec 12, 2012 8:16 am

:D
Looks interesting. New features to a game are just the thing. Brilliant stuff. I have managed to update my Piom game to gl2 and hopefully I can add a few bits so I can commit to my repro.

JamesR
Posts: 78
Joined: Sun Aug 05, 2012 11:21 pm

Re: Pi3D ES 2.0

Wed Dec 12, 2012 9:00 am

I've tried an update of python imaging, but I'm up to date.
There seems to be an issue regarding imageTK

Line 36
Import Error: No module named ImageTK.

I'll try to double check through the files.

User avatar
tipam
Posts: 99
Joined: Fri Dec 30, 2011 1:32 pm
Contact: Website

Re: Pi3D ES 2.0

Wed Dec 12, 2012 8:07 pm

Sorry, forgot to mention that this update requires a python-imaging extension. Install it with ...

sudo apt-get install python-imaging-tk

So, for first time users of Pi3D, the overalll required installation is;

sudo apt-get install python-imaging python-imaging-tk

... this loads PIL and it's extension. Basically, the TK extension makes images compatible with TKinter (particularly for the splash screen feature)

Tim
Raspberry Pi == small computer == big dreams

JamesR
Posts: 78
Joined: Sun Aug 05, 2012 11:21 pm

Re: Pi3D ES 2.0

Wed Dec 12, 2012 8:11 pm

Ahh.. I looked through the files I had to a loss, but luckily I had a load of accounting today anyway. Rich reward.

JamesR
Posts: 78
Joined: Sun Aug 05, 2012 11:21 pm

Re: Pi3D ES 2.0

Wed Dec 12, 2012 11:34 pm

I got it all up and running when I had a chance. Works nicely
The fps count is fascinating. I think that the highest fps i got was 16fps, but it runs smoothly in regards how well the tank manoeuvres.

however i put the fps code into Pong, but it doesn't show.
i have the 3 pieces of code, i'm presuming it will be the positioning.
Enjoyed the hello world, food for thought.

User avatar
tipam
Posts: 99
Joined: Fri Dec 30, 2011 1:32 pm
Contact: Website

Re: Pi3D ES 2.0

Thu Dec 13, 2012 3:21 am

... the more people play with Pi3D, the better we can improve and make fixes!!

I've been playing with baked texture environments which make the RPi look pretty powerful! ...

Image
Raspberry Pi == small computer == big dreams

portets
Posts: 186
Joined: Sat Oct 29, 2011 6:24 am

Re: Pi3D ES 2.0

Thu Dec 13, 2012 6:57 am

Wow, amazing job. Gonna have to bring my Pi back out for this.

JamesR
Posts: 78
Joined: Sun Aug 05, 2012 11:21 pm

Re: Pi3D ES 2.0

Thu Dec 13, 2012 10:39 am

Low poly baking is plainly a necessity. Your doing a brilliant job at making things work and look pretty.

Do have a look Portets. It normally takes me 3 hours to sort some pi issue out. I've worked out the update function now. And about 20mins with Pi3d.
The code works pretty simply. You've just got to find the coherent code snippets.

So it was useful to see 2nd entry of code written for fps.

User avatar
rurwin
Forum Moderator
Forum Moderator
Posts: 4258
Joined: Mon Jan 09, 2012 3:16 pm
Contact: Website

Re: Pi3D ES 2.0

Thu Dec 13, 2012 11:16 am

If I want to git into this, which git do I git from the github? Would it be tipam/pi3d/integration?

I assume the [strike]cake[/strike] manual is a lie?
git readme wrote:A short 'manual' on using pi3d can be found on this github. Please note that Pi3D functions may change significantly during it's development.

User avatar
tipam
Posts: 99
Joined: Fri Dec 30, 2011 1:32 pm
Contact: Website

Re: Pi3D ES 2.0

Thu Dec 13, 2012 11:56 am

rurwin wrote:If I want to git into this, which git do I git from the github? Would it be tipam/pi3d/integration?

I assume the [strike]cake[/strike] manual is a lie?
git readme wrote:A short 'manual' on using pi3d can be found on this github. Please note that Pi3D functions may change significantly during it's development.
Yes, sorry about that - the manual was a 'truthful' representation at some point! However, as Pi3D is moving rapidly, I will update it as soon as the dust settles. If you want to git into Pi3D, Paddy Gaunt and Tom Swirly are working on the gles2 branch whilst I make bug-fixes and minor changes on master. Please contact them if you want to get into the cutting edge of Pi3D in ES2!
Raspberry Pi == small computer == big dreams

JamesR
Posts: 78
Joined: Sun Aug 05, 2012 11:21 pm

Re: Pi3D ES 2.0

Thu Dec 13, 2012 12:47 pm

I've used Tim's update for now. But my advice if it's worth anything, is to look at both as essentially the base code is the same. And decide what you need from things to get your project going or add to the code.

People's experience varies obviously. Although a stable integration version might be the better option if they make vast changes. Although you always learn a little more by seeing how things differ. A new bunch of code to the eye isn't that simple to get the head around.

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

Re: Pi3D ES 2.0

Thu Dec 13, 2012 2:41 pm

Or maybe you just couldn't find the manual. It's rather obscure, under wiki on the github page. A lot of the explanations are still relevant and will apply for the most part to the GLES 2.0 version.

It is useful to us if people to try out the half baked version from time to time and find things that don't work on their setup though they do on ours etc.

Here's a picture showing one advantage of ES2 using shaders to give texture to nearby objects by using normal maps. At the moment this version (in tipam/integration) doesn't have the latest of Tim's improvements and it's still a bit slower (about 10fps) but hopefully will improve.
Attachments
TigerTanksm.jpg
TigerTanksm.jpg (57.87 KiB) Viewed 7857 times
also https://groups.google.com/forum/?hl=en-GB&fromgroups=#!forum/pi3d

User avatar
tipam
Posts: 99
Joined: Fri Dec 30, 2011 1:32 pm
Contact: Website

Re: Pi3D ES 2.0

Thu Dec 13, 2012 3:00 pm

Looking good!
Raspberry Pi == small computer == big dreams

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

Re: Pi3D ES 2.0

Thu Dec 13, 2012 6:13 pm

pitch_roll() method in ElevationMap working at last! Should patch back into the non-gles2.0 version
Attachments
TigerTank.jpg
TigerTank.jpg (38.18 KiB) Viewed 7833 times
also https://groups.google.com/forum/?hl=en-GB&fromgroups=#!forum/pi3d

JamesR
Posts: 78
Joined: Sun Aug 05, 2012 11:21 pm

Re: Pi3D ES 2.0

Thu Dec 13, 2012 6:53 pm

Brilliant. That's what I meant about gravity and then realised it was in effect, but was probably the pitch roll.
I can't be too sure on the fps front. It will be interesting to see this project to span out into playable games. I guess simple high res and complex low res games kind of thing.
It then bothers me that I'm no modelling artist whatever. But I think playability is that more interesting a target, it's not the end of the world.

User avatar
tipam
Posts: 99
Joined: Fri Dec 30, 2011 1:32 pm
Contact: Website

Re: Pi3D ES 2.0

Thu Dec 13, 2012 7:12 pm

paddyg wrote:pitch_roll() method in ElevationMap working at last! Should patch back into the non-gles2.0 version
Well done! Can't wait to see the amend in vsn 1!

Tim
Raspberry Pi == small computer == big dreams

Return to “Python”