Game Runs Slow
Blitz3D Forums/Blitz3D Beginners Area/Game Runs Slow
| ||
I have a nice little terrain, and a little player (.b3d animation) and a skybox. I made my skybox useing a modified version of the function in the "Castle" sample by mak. But, when I run the program without the skybox, it runs at about 45 fps. When I run it with the skybox, it runs at 3 or 4 fps, but only when I am in view of a corner, when I'm not, it runs at about 40. Whats going on? |
| ||
You have discovered gremlins in your PC's inner space, and they are eating your CPU cycles. You must debug them! |
| ||
Meanwhile back on planet earth, can you post some code? |
| ||
Well, yeah, that too. |
| ||
This is what I'm using as the skyboxGlobal Sky = loadskybox() EntityOrder sky,10 Then in the main loop PositionEntity sky,EntityX(player\mesh),Entity(player\mesh),EntityZ(player\mesh) The LoadSkyBox Function taken from Castle sample Function LoadSkyBox() m=CreateMesh() ;front face b=LoadBrush("media\terrain\front.jpg",49 ) s=CreateSurface( m,b ) AddVertex s,-1,+1,-1,0,0:AddVertex s,+1,+1,-1,1,0 AddVertex s,+1,-1,-1,1,1:AddVertex s,-1,-1,-1,0,1 AddTriangle s,0,1,2:AddTriangle s,0,2,3 FreeBrush b ;right face b=LoadBrush("media\terrain\right.jpg",49 ) s=CreateSurface( m,b ) AddVertex s,+1,+1,-1,0,0:AddVertex s,+1,+1,+1,1,0 AddVertex s,+1,-1,+1,1,1:AddVertex s,+1,-1,-1,0,1 AddTriangle s,0,1,2:AddTriangle s,0,2,3 FreeBrush b ;back face b=LoadBrush("media\terrain\back.jpg",49 ) s=CreateSurface( m,b ) AddVertex s,+1,+1,+1,0,0:AddVertex s,-1,+1,+1,1,0 AddVertex s,-1,-1,+1,1,1:AddVertex s,+1,-1,+1,0,1 AddTriangle s,0,1,2:AddTriangle s,0,2,3 FreeBrush b ;left face b=LoadBrush("media\terrain\left.jpg",49 ) s=CreateSurface( m,b ) AddVertex s,-1,+1,+1,0,0:AddVertex s,-1,+1,-1,1,0 AddVertex s,-1,-1,-1,1,1:AddVertex s,-1,-1,+1,0,1 AddTriangle s,0,1,2:AddTriangle s,0,2,3 FreeBrush b ;top face b=LoadBrush("media\terrain\up.jpg",49 ) s=CreateSurface( m,b ) AddVertex s,-1,+1,+1,0,1:AddVertex s,+1,+1,+1,0,0 AddVertex s,+1,+1,-1,1,0:AddVertex s,-1,+1,-1,1,1 AddTriangle s,0,1,2:AddTriangle s,0,2,3 FreeBrush b ;bottom face b=LoadBrush("media\terrain\sky.png",49 ) s=CreateSurface( m,b ) AddVertex s,-1,-1,-1,1,0:AddVertex s,+1,-1,-1,1,1 AddVertex s,+1,-1,+1,0,1:AddVertex s,-1,-1,+1,0,0 AddTriangle s,0,1,2:AddTriangle s,0,2,3 FreeBrush b ScaleMesh m,100,100,100 FlipMesh m EntityFX m,1 Return m End Function |
| ||
did you call the func in the main cycle? if yes, you have to call it out of the main cycle... ex: global a = 0 while not a > 20 LoadSkyBox() a = a + 1 wend You'll have about 20 skies... global a = 0 LoadSkyBox() while not a >20 a = a + 1 wend You'll have one sky |
| ||
Thanks everyone, it turned out I was useing to big a picture for the brushes. |
| ||
would there be a way to make a skybox without brushes? |
| ||
Gobbo - create your skybox in a 3d app as a cube, texture the insides and invert the normals, then simply load the object, and treat as a normal skybox cube. |
| ||
how do i "invert the normals" :) ? |
| ||
The flipmesh command in b3d will invert the normals. Alternatively most 3d apps you can do the same although I might go by different names. |
| ||
im having difficulties texturing... i used to know how todo this. what commands where used for texture mapping again? (repositiong the texturecordinates). |
| ||
Blitz Docs > 3D - Category > Texture > TextureCoords texture - name of texture coords - 0: UV coordinates are from first UV set in vertices (default) 1: UV coordinates are from second UV set in vertices ;) |
| ||
doh.. how come i missed that... thanks! |