Author Topic: iPad 3D Speed  (Read 4940 times)

Offline Qube

  • Mr. Polyvector
  • ***
  • Posts: 157
    • View Profile
iPad 3D Speed
« on: 2010-Dec-29 »
Is there anything that can be done to speed up the 3D speed on the iPad? - Even using a simple 1500 polygon model and no background the frame rate is a mere 37fps - However if I compile for iPhone only then the same app runs at 60fps on the iPad.

There are a lot of 3D apps on the AppStore which run at higher frame rates with much more complicated scenes, like Galaxy of Fire II for example.

Is anyone else experiencing slow frame rates with 3D on the iPad (even with simple objects)? - If not then perhaps you could provide an example to compare?

*note* I have the latest GLB + iOS 4.2 + latest XCode

Offline matchy

  • Prof. Inline
  • *****
  • Posts: 1545
    • View Profile
Re: iPad 3D Speed
« Reply #1 on: 2010-Dec-29 »
Simple 1500 polygon model? That's a lot just for just a presumed spaceship.
A cube (12 tri poly) runs at 60fps on iPad.

Offline erico

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 4397
    • View Profile
    • FUED
Re: iPad 3D Speed
« Reply #2 on: 2010-Dec-29 »
There are a lot of 3D apps on the AppStore which run at higher frame rates with much more complicated scenes, like Galaxy of Fire II for example.

1500 polygons is a lot... I checked a video on Galaxy of fire II, only really low poly objects in there, most of them boxes attached together with nice maps. I like the  laser fest though...

That seems quite possible to come up with glbasic, you can also consider reducing complex objects as they are far from camera, use of squares with textures may help here and there and bump map may heal the extra polygons you may need.

Just ideas though, I programmed nothing on 3d yet...

Offline Qube

  • Mr. Polyvector
  • ***
  • Posts: 157
    • View Profile
Re: iPad 3D Speed
« Reply #3 on: 2010-Dec-29 »
I cant even get 3 cubes to spin at anything above 37fps on the iPad which is just silly :/ - Something must be wrong :'(

Offline matchy

  • Prof. Inline
  • *****
  • Posts: 1545
    • View Profile
Re: iPad 3D Speed
« Reply #4 on: 2010-Dec-29 »
There's only one way to find out if it's hardware or code...sample code to test please.

Offline Qube

  • Mr. Polyvector
  • ***
  • Posts: 157
    • View Profile
Re: iPad 3D Speed
« Reply #5 on: 2010-Dec-29 »
Well, even the cellshadding 3d example (modified code below) runs slow in the iPad yet when compiled for iPhone and ran on the iPad it runs full frame rate.

Now you can't seriously say that the ipad can't handle a simple thing like this?  :S

Code: (glbasic) [Select]

SETSCREEN 1024, 768, 1
CreateTorus(1, 5, 10, 22, 22, 2, 2)
LOADSPRITE      "image.bmp", 0

DIMDATA cheap[], .5, 1
DIMDATA nice[], .3, .6, .6, .6, .6, .6, .6, .7, 1, 1, 1, 1, 1, 1, 1, 1

WHILE TRUE
phi=phi+GETTIMER()/30
X_SETCELSHADES cheap[]
Render(phi)


dtime = GETTIMER()
fps = ((1000.0/dtime)+fps)/2
delay=delay+dtime
IF delay>1000 // 1/2 sec
delay=0
ShowFPS=fps
ENDIF
X_MAKE2D
PRINT "FPS: "+FORMAT$(0,1,ShowFPS), 100, 0 // + dtime, 0,0

SHOWSCREEN
WEND


// ------------------------------------------------------------- //
// Zeichnet einen Donut
// Renders a Donut
// ------------------------------------------------------------- //
FUNCTION Render: phi
X_MAKE3D 1, 250, 45
X_CAMERA 0, 10, 50, 0,0,0
// Licht Nr. -2 is Cel-Shading Postition / Light no -1 is cel shading position
X_SPOT_LT -2, 0, 0,0,100, 0,0,0,90
X_CULLMODE 1 // niemals 0 verwenden bei toons / Never use 0 with toon shading
X_SETTEXTURE 0, -1 // 0=Tex
X_ROTATION 80, 1,0,0
X_ROTATION phi, 0, 1, 0.1
X_DRAWOBJ 1, 0
ENDFUNCTION


// ------------------------------------------------------------- //
// -=#  CREATETORUS  #=-
// Donut Objekt machen / Make a donut object
//
// By Samuel R. Buss
// http://math.ucsd.edu/~sbuss/MathCG
// ------------------------------------------------------------- //
FUNCTION CreateTorus: num, MinorRadius, MajorRadius, NumWraps, NumPerWrap, TextureWrapVert, TextureWrapHoriz
LOCAL i, di, j, wrapFrac, wrapFracTex, phi, thetaFrac, thetaFracTex, theta
LOCAL x, y, z, r

X_AUTONORMALS 2 // smooth
X_OBJSTART num
FOR di=0 TO NumWraps-1
FOR j=0 TO NumPerWrap
FOR i=di+1 TO di STEP -1
wrapFrac = MOD(j, NumPerWrap)/NumPerWrap
wrapFracTex = j/NumPerWrap
phi = 360*wrapFrac
thetaFrac = (MOD(i, NumWraps)+wrapFracTex)/NumWraps
thetaFracTex = (i+wrapFracTex)/NumWraps
theta = 360*thetaFrac
r = MajorRadius + MinorRadius*COS(phi)
x = SIN(theta)*r
z = COS(theta)*r
y = MinorRadius*SIN(phi)
X_OBJADDVERTEX x,y,z,  thetaFracTex*TextureWrapVert, 1-wrapFracTex*TextureWrapHoriz, _
RGB(0xff,0xff,0xff)
NEXT
NEXT
X_OBJNEWGROUP
NEXT
X_OBJEND
ENDFUNCTION // y

Offline Leginus

  • Dr. Type
  • ****
  • Posts: 288
    • View Profile
Re: iPad 3D Speed
« Reply #6 on: 2010-Dec-29 »
Are you running the latest version of glbasic??  And does the 2d stuff run at full speed?
I know the 2d used to run about 30ish frames per second, but was recently fixed to run at full speed, so I wondered if that was still ok or something that needed looking at


Offline Qube

  • Mr. Polyvector
  • ***
  • Posts: 157
    • View Profile
Re: iPad 3D Speed
« Reply #7 on: 2010-Dec-29 »
As stated in my first post  :P I am running the latest version of GLB & Xcode & iOS :)

Yes, 2D runs fine and I have no problems with speed. It's just the 3D side that is slow and there seems to be something wrong especially as I can compile for iPhone and run it on the iPad at full speed (even x2 mode).

Offline matchy

  • Prof. Inline
  • *****
  • Posts: 1545
    • View Profile
Re: iPad 3D Speed
« Reply #8 on: 2010-Dec-30 »
Thanks for the test code and I'll test it later. Do you really need your first iPad game to require shaders? 
« Last Edit: 2010-Dec-30 by matchy »

Offline Qube

  • Mr. Polyvector
  • ***
  • Posts: 157
    • View Profile
Re: iPad 3D Speed
« Reply #9 on: 2010-Dec-30 »
I'll not be using shaders, no, but the example was the easiest one to come up with from the GLB examples folder and shows that compiling for iPad runs slow but compiling for iPhone and running on iPad (or iPhone) runs full speed.


Offline Qube

  • Mr. Polyvector
  • ***
  • Posts: 157
    • View Profile
Re: iPad 3D Speed
« Reply #10 on: 2011-Jan-01 »
Has anyone tried the above example yet and confirmed 3D slowness on iPad :whistle: - Or you can even stick a few spinning boxes on the iPad and frame rate drops :rant:

p.s. Happy New Year  :booze:

Offline Leginus

  • Dr. Type
  • ****
  • Posts: 288
    • View Profile
Re: iPad 3D Speed
« Reply #11 on: 2011-Jan-01 »
Blame santa (in a wife's dress), alas no ipad :(
mmm....not sure that came out right....but i think you get the idea.

Offline Qube

  • Mr. Polyvector
  • ***
  • Posts: 157
    • View Profile
Re: iPad 3D Speed
« Reply #12 on: 2011-Jan-02 »
I think the best course if action here will be to do a super simple 3D sample for iPhone and iPad (no textures or anything) to show the vast difference and post the results as an iPad bug in the bugs report forum.

Must get the iPad 3d side sorted out  :'(

Offline Qube

  • Mr. Polyvector
  • ***
  • Posts: 157
    • View Profile
Re: iPad 3D Speed
« Reply #13 on: 2011-Jan-03 »
I've posted this in the bug reports forum as this proves that when it comes to 3D speed on the iPhone / iPad, the iPad is dropping to almost half it's frame rate.

Tested with latest iOS + XCode + GLB versions.

The simple one spinning cube below works at 60FPS on iPhone & iPhone mode on the iPad but when compiled for iPad alone the frame rate drops to a mere 35FPS.

Code: (glbasic) [Select]
SETSCREEN 1024, 768, 1
LIMITFPS 60

GLOBAL colWhite =RGB(255,255,255)

X_AUTONORMALS 1

CreateCube(1, 3, colWhite)

LOCAL angle#
LOCAL timeThen% = GETTIMERALL()
LOCAL timeNow%  = GETTIMERALL()
LOCAL FPSCounter%
LOCAL FPS%


WHILE TRUE
timeNow = GETTIMERALL()
IF timeNow >= timeThen + 1000
FPS = FPSCounter
timeThen = timeNow
FPSCounter = 0
ENDIF

X_MAKE3D 1, 40, 65
X_CAMERA 0, 0, 0, 0, 0, 40
X_CULLMODE 1
X_SPOT_LT 1, colWhite, 0, 0, 0, 0, 0, 40, 50

X_MOVEMENT 0, 0, 17
X_SCALING 1, 1, 1
X_ROTATION angle, -1, 0, -1
X_DRAWOBJ 1,  0

X_MAKE2D
PRINT FPS, 0,0

INC angle
INC FPSCounter

SHOWSCREEN
WEND

FUNCTION CreateCube: num, size, col
X_OBJSTART num
// Front Face
X_OBJADDVERTEX  size, -size,  size, 1, 0, col
X_OBJADDVERTEX -size, -size,  size, 0, 0, col
X_OBJADDVERTEX  size,  size,  size, 1, 1, col
X_OBJADDVERTEX -size,  size,  size, 0, 1, col
X_OBJNEWGROUP
// Back Face
X_OBJADDVERTEX -size,  size, -size, 1, 1, col
X_OBJADDVERTEX -size, -size, -size, 1, 0, col
X_OBJADDVERTEX  size,  size, -size, 0, 1, col
X_OBJADDVERTEX  size, -size, -size, 0, 0, col
X_OBJNEWGROUP
// Top Face
X_OBJADDVERTEX -size,  size,  size, 0, 0, col
X_OBJADDVERTEX -size,  size, -size, 0, 1, col
X_OBJADDVERTEX  size,  size,  size, 1, 0, col
X_OBJADDVERTEX  size,  size, -size, 1, 1, col
X_OBJNEWGROUP
// Bottom Face
X_OBJADDVERTEX  size, -size, -size, 0, 1, col
X_OBJADDVERTEX -size, -size, -size, 1, 1, col
X_OBJADDVERTEX  size, -size,  size, 0, 0, col
X_OBJADDVERTEX -size, -size,  size, 1, 0, col
X_OBJNEWGROUP
// Right face
X_OBJADDVERTEX  size,  size, -size, 1, 1, col
X_OBJADDVERTEX  size, -size, -size, 1, 0, col
X_OBJADDVERTEX  size,  size,  size, 0, 1, col
X_OBJADDVERTEX  size, -size,  size, 0, 0, col
X_OBJNEWGROUP
// Left Face
X_OBJADDVERTEX -size, -size,  size, 1, 0, col
X_OBJADDVERTEX -size, -size, -size, 0, 0, col
X_OBJADDVERTEX -size,  size,  size, 1, 1, col
X_OBJADDVERTEX -size,  size, -size, 0, 1, col
X_OBJNEWGROUP
X_OBJEND

ENDFUNCTION

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10817
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Re: iPad 3D Speed
« Reply #14 on: 2011-Jan-04 »
Are you using the very latest SDK from Apple? There was a great speed boost with that.