forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

pspGL - Skybox Problems

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
geforcefan



Joined: 08 Jun 2007
Posts: 8
Location: Frankfurt // Schaafheim

PostPosted: Fri Jun 08, 2007 10:50 pm    Post subject: pspGL - Skybox Problems Reply with quote

Hello,
I have a big problem, to make a Skybox. I can only see one Side of the Skybox, and I can't see the ground. I'm developing under Linux, and I can test my Homebrews under Linux, because I using GLUT.

This is the result of GLUT:



and here, on the PSP:



you can download the Homebrew here (for FW1.5):
http://rapidshare.com/files/35944807/Test2.rar.html

And the source code of the Skybox:

Code:
void DrawSkybox(GLenum mode, float y, float z, float x, float repeatground) {
   glDisable(GL_LIGHTING);
   glScalef(y,z,x);
   glTranslatef(0.0f, 0.95f, 0.0f);
   glBindTexture(GL_TEXTURE_2D, texture[0]);   // choose the texture to use.

   glBegin(mode);         
      // Himmel

      glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f,-1.0f);      

      glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, 1.0f,-1.0f);      

      glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, 1.0f, 1.0f);      

      glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, 1.0f, 1.0f);   
   glEnd();

   glBindTexture(GL_TEXTURE_2D, texture[6]);   // choose the texture to use.
   glBegin(mode);      
      // Boden         

      glTexCoord2f(repeatground, repeatground); glVertex3f( 1.0f,-1.0f, 1.0f);      

      glTexCoord2f(repeatground, 0.0f);             glVertex3f(-1.0f,-1.0f, 1.0f);      

      glTexCoord2f(0.0f, 0.0f);                         glVertex3f(-1.0f,-1.0f,-1.0f);      

      glTexCoord2f(0.0f, repeatground);             glVertex3f( 1.0f,-1.0f,-1.0f);   
   glEnd();

   glBindTexture(GL_TEXTURE_2D, texture[5]);   // choose the texture to use.

   // Hinten
   glBegin(mode);   

      glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, 1.0f, 1.0f);      

      glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, 1.0f, 1.0f);      

      glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f,-1.0f, 1.0f);      

      glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f,-1.0f, 1.0f);
   glEnd();

   glBindTexture(GL_TEXTURE_2D, texture[3]);   // choose the texture to use.

   // Vorne
   glBegin(mode);      

      glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f,-1.0f,-1.0f);      

      glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f,-1.0f,-1.0f);            

      glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f,-1.0f);      

      glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f,-1.0f);   
   glEnd();

   glBindTexture(GL_TEXTURE_2D, texture[2]);   // choose the texture to use.
   // Links
   glBegin(mode);   

      glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, 1.0f, 1.0f);      

      glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f,-1.0f);         

      glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f,-1.0f,-1.0f);      

      glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f,-1.0f, 1.0f);   
   glEnd();

   glBindTexture(GL_TEXTURE_2D, texture[4]);   // choose the texture to use.
   // Rechts
   glBegin(mode);   

      glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f,-1.0f);      

      glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, 1.0f, 1.0f);      

      glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f,-1.0f, 1.0f);      

      glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f,-1.0f,-1.0f);      

   glEnd();
   glScalef(-(y),-(z),-(x));
   glTranslatef(0.0f, -1.0f, 0.0f);
   glEnable(GL_LIGHTING);
}


what is wrong?

Here is the complete sourcecode:
http://rapidshare.com/files/35946120/Test2.rar.html

Please help me :'(

Sorry for my bad english...

Ercan
_________________
mi casa es su casa ^^
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Insert_witty_name



Joined: 10 May 2006
Posts: 376

PostPosted: Sat Jun 09, 2007 1:27 am    Post subject: Reply with quote

The triangles from the skybox are being clipped.

Do a search of this forum for 'clipping', there's been a few decent posts on how to remove the problem.
Back to top
View user's profile Send private message
geforcefan



Joined: 08 Jun 2007
Posts: 8
Location: Frankfurt // Schaafheim

PostPosted: Sat Jun 09, 2007 5:17 am    Post subject: Reply with quote

Can you show me a Thread? I found some, but they was not realy helpfuly :(
What do you mean with "clipping" ?

I cant use by pspGL sceGuDsiable(GU_CLIPPING...);
What can I use in pspGL ?

Ercan
_________________
mi casa es su casa ^^
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Insert_witty_name



Joined: 10 May 2006
Posts: 376

PostPosted: Sat Jun 09, 2007 6:27 am    Post subject: Reply with quote

Subdivision of the triangles will help a lot, or implement a clipping algorithm yourself to clip them before rendering.
Back to top
View user's profile Send private message
geforcefan



Joined: 08 Jun 2007
Posts: 8
Location: Frankfurt // Schaafheim

PostPosted: Sat Jun 09, 2007 7:19 pm    Post subject: Reply with quote

I 'm not a openGL guru, I'm giving up.. Do you have some examples... ?

Ercan
_________________
mi casa es su casa ^^
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Jim



Joined: 02 Jul 2005
Posts: 487
Location: Sydney

PostPosted: Sat Jun 09, 2007 7:55 pm    Post subject: Reply with quote

What's happening is that after OpenGL does the perspective calculation, the 2d coordinates are going outside the maximum resolution of the psp triangle hardware - I think it can only do -1024 to 1023. So, you can either render smaller triangles (poor solution in this case) by making the skybox out of way more polygons, or you can arrange it so that the values don't go out of range by chopping the 3D skybox up at runtime, so that the bits that are left are only the visible bits. This is called 3D clipping - noone here's going to help you with a clipping algorithm unless you're very lucky, but google has hundreds of links on the subject.

Jim
_________________
http://www.dbfinteractive.com
Back to top
View user's profile Send private message Visit poster's website
geforcefan



Joined: 08 Jun 2007
Posts: 8
Location: Frankfurt // Schaafheim

PostPosted: Sat Jun 09, 2007 8:06 pm    Post subject: Reply with quote

You are right, but I wrote at my first post, that I'm not a english guru, too.
There are too many things, that i cant understand.

But i understood, what you mean, but I think, i read PSP can do over -2000 to 2000. And my Triangles arent going outside the maximum:

Code:
float repeatground = 200.0f;

float maphight = 300.0f;
float trackhight = 150.0f;

float mapx = 700.0f;
float trackx = 150.0f;

float mapy = 700.0f;
float tracky = 150.0f;


You can see here, the maximum is -700 to 700.

Do you mean this part? :

Code:
gluPerspective(45.0f,(float)Width/(float)Height,0.1f,2000.0f);   // Berechnet den Längenverhältniss von dem Fenster


Ercan
_________________
mi casa es su casa ^^
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
rapso



Joined: 28 Mar 2005
Posts: 147

PostPosted: Sat Jun 09, 2007 9:05 pm    Post subject: Reply with quote

it's not about the 3D coordinate size, but the 2D coordinate size of the triangles on the screen. if it's greather than 2000 in any direction the triangle is to big to be drawn.
Back to top
View user's profile Send private message
geforcefan



Joined: 08 Jun 2007
Posts: 8
Location: Frankfurt // Schaafheim

PostPosted: Sat Jun 09, 2007 9:13 pm    Post subject: Reply with quote

But it inst greater than 2000. The maximum is 700 ....
_________________
mi casa es su casa ^^
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
TraxNet



Joined: 04 Jun 2007
Posts: 1

PostPosted: Sat Jun 09, 2007 9:51 pm    Post subject: Reply with quote

*Sorry for the spanish ahead.

Cuando los vertices del cubo que forma el skybox son proyectados a la camara, toman valores mayores de 2000. Por ejemplo el poligono de la derecha en la imagen que muestras en tu primer post, es tan grande que incluso quedaria muy "a la derecha" de la camara, cuando eso se proyecta al plano donde esta situada la camara, esas cordenadas sobre el plano (coordenadas 2d) son mayores de lo que el hardware permite, y el propio hardware descarta hacer el render de ese poligono. Necesitas hacer clipping de ese poligono de tal manera que cuando se proyecte sobre la camara, se quede justo en el borde. Mirate algun libro de 3d o los miles de manuales de Perspective Projection que habra por inet, y luego busca clipping. Tendras que hacerte alguna rutina para recortar esos poligonos lo justo (clipping).
Back to top
View user's profile Send private message
rapso



Joined: 28 Mar 2005
Posts: 147

PostPosted: Sat Jun 09, 2007 10:34 pm    Post subject: Reply with quote

geforcefan wrote:
But it inst greater than 2000. The maximum is 700 ....
on the screen it is greater than 2000 pixels

pixel != worldunits

u'r from frankfurt, so maybe in german?

wenn du ein dreieck auf den screen projezierst, haengt seine groesse von der entfernung zum dreieck ab. ist eine box weit weg, hat sie vielleicht 10 pixel, ist sie nah dran vielleicht 100 und wenn du ne grosse skybox hast, ist ein dreieck auf dem screen eventuell groesser als 2000 pixel, dabei aendert sich die objektgroesse nie! hat aber auch nichts mit der pixelanzahl zu tun.
Back to top
View user's profile Send private message
Jim



Joined: 02 Jul 2005
Posts: 487
Location: Sydney

PostPosted: Sat Jun 09, 2007 10:49 pm    Post subject: Reply with quote

700/0.1=7000. Way out of range.

Jim
_________________
http://www.dbfinteractive.com
Back to top
View user's profile Send private message Visit poster's website
geforcefan



Joined: 08 Jun 2007
Posts: 8
Location: Frankfurt // Schaafheim

PostPosted: Sun Jun 10, 2007 2:17 am    Post subject: Reply with quote

rapso wrote:
geforcefan wrote:
But it inst greater than 2000. The maximum is 700 ....
on the screen it is greater than 2000 pixels

pixel != worldunits

u'r from frankfurt, so maybe in german?

wenn du ein dreieck auf den screen projezierst, haengt seine groesse von der entfernung zum dreieck ab. ist eine box weit weg, hat sie vielleicht 10 pixel, ist sie nah dran vielleicht 100 und wenn du ne grosse skybox hast, ist ein dreieck auf dem screen eventuell groesser als 2000 pixel, dabei aendert sich die objektgroesse nie! hat aber auch nichts mit der pixelanzahl zu tun.


hmm ich habe soweit kapiert, kein Problem, aber WIE kann ich dieses Problem beheben? Gibt es eine andere möglichkeit einen Skybox zu machen? am besten werde ich ohne skybox arbeite, vielleicht wird es besser aussehen...

I can understand you, its not a problem, but I have to know, hot to solve this problem... Is there any other posibilitys to make a Skybox? I think, I will develop my homebrew withou skybox, I will generate dynamic clouds ;)

Quote:
700/0.1=7000. Way out of range.

I cant understand! 700/0.1 = 70. Why 7000?

Ercan
_________________
mi casa es su casa ^^
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Insert_witty_name



Joined: 10 May 2006
Posts: 376

PostPosted: Sun Jun 10, 2007 4:27 am    Post subject: Reply with quote

700/10 = 70
700/0.1 = 7000
Back to top
View user's profile Send private message
geforcefan



Joined: 08 Jun 2007
Posts: 8
Location: Frankfurt // Schaafheim

PostPosted: Sun Jun 10, 2007 5:18 am    Post subject: Reply with quote

Insert_witty_name wrote:
700/10 = 70
700/0.1 = 7000


oh, my mistake, I saw a multiply chracter ^^
_________________
mi casa es su casa ^^
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Ghoti



Joined: 31 Dec 2005
Posts: 288

PostPosted: Sun Jun 10, 2007 6:50 am    Post subject: Reply with quote

Hi,

I have not used the pspGL but I have made a skybox in the game I am making. I have made 6 qauds(made out of triangles) and then render it as a box close around my camera. BUT to ensure that everything else is rendered over de skybox so that it appears far is that i have disabled the depth-test so there is not data of the skybox when the hardware checks if an object is behind an object. this way every element in the game is rendered over the skybox because the hardware does not know that it is there. :D

so you could make it alot smaller and disable the depth test. that might work for you.
_________________
My PSP games:

Boxy II: http://www.ghoti.nl/boxyii.php
Elementals: http://www.ghoti.nl/Elementals.php
Back to top
View user's profile Send private message
rapso



Joined: 28 Mar 2005
Posts: 147

PostPosted: Sun Jun 10, 2007 8:12 am    Post subject: Reply with quote

geforcefan wrote:

hmm ich habe soweit kapiert, kein Problem, aber WIE kann ich dieses Problem beheben? Gibt es eine andere möglichkeit einen Skybox zu machen? am besten werde ich ohne skybox arbeite, vielleicht wird es besser aussehen...

I can understand you, its not a problem, but I have to know, hot to solve this problem... Is there any other posibilitys to make a Skybox? I think, I will develop my homebrew withou skybox, I will generate dynamic clouds ;)


either you tesselate the skybox into smaller pices so non of them ever fall out of range while visible or you clip the triangles to the viewport everytime u draw them.

entweder to zerteilst die dreiecke in sokleine, dass keines mehr nach der projektino zu gross ist fuer den bildschirm oder du schneidest/clipst sie immer auf die groesse des viewports... btw. wirst du das problem bei vielen objekten haben, nicht nur bei der skybox, sobald sie einigermassen grosse dreiecke auf dem bildschirm haben. du solltest das problem also loesen;)
Back to top
View user's profile Send private message
geforcefan



Joined: 08 Jun 2007
Posts: 8
Location: Frankfurt // Schaafheim

PostPosted: Sun Jun 10, 2007 7:48 pm    Post subject: Reply with quote

rapso wrote:
geforcefan wrote:

hmm ich habe soweit kapiert, kein Problem, aber WIE kann ich dieses Problem beheben? Gibt es eine andere möglichkeit einen Skybox zu machen? am besten werde ich ohne skybox arbeite, vielleicht wird es besser aussehen...

I can understand you, its not a problem, but I have to know, hot to solve this problem... Is there any other posibilitys to make a Skybox? I think, I will develop my homebrew withou skybox, I will generate dynamic clouds ;)


either you tesselate the skybox into smaller pices so non of them ever fall out of range while visible or you clip the triangles to the viewport everytime u draw them.

entweder to zerteilst die dreiecke in sokleine, dass keines mehr nach der projektino zu gross ist fuer den bildschirm oder du schneidest/clipst sie immer auf die groesse des viewports... btw. wirst du das problem bei vielen objekten haben, nicht nur bei der skybox, sobald sie einigermassen grosse dreiecke auf dem bildschirm haben. du solltest das problem also loesen;)


thank you for your tipps, I will tryin' it in few minutes ;)
Now I have understand, why I have this problem... Maybe, I can develop an algorthm for this problem ;)

Ercan
_________________
mi casa es su casa ^^
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
dot_blank



Joined: 28 Sep 2005
Posts: 498
Location: Brasil

PostPosted: Sun Jun 10, 2007 8:46 pm    Post subject: Reply with quote

mi casa es su casa
_________________
10011011 00101010 11010111 10001001 10111010
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group