pspGL - Skybox Problems

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
User avatar
geforcefan
Posts: 8
Joined: Fri Jun 08, 2007 10:28 pm
Location: Frankfurt // Schaafheim
Contact:

pspGL - Skybox Problems

Post by geforcefan »

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:

Image

and here, on the PSP:

Image

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: Select all

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 ^^
Insert_witty_name
Posts: 376
Joined: Wed May 10, 2006 11:31 pm

Post by Insert_witty_name »

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.
User avatar
geforcefan
Posts: 8
Joined: Fri Jun 08, 2007 10:28 pm
Location: Frankfurt // Schaafheim
Contact:

Post by geforcefan »

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 ^^
Insert_witty_name
Posts: 376
Joined: Wed May 10, 2006 11:31 pm

Post by Insert_witty_name »

Subdivision of the triangles will help a lot, or implement a clipping algorithm yourself to clip them before rendering.
User avatar
geforcefan
Posts: 8
Joined: Fri Jun 08, 2007 10:28 pm
Location: Frankfurt // Schaafheim
Contact:

Post by geforcefan »

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

Ercan
mi casa es su casa ^^
User avatar
Jim
Posts: 476
Joined: Sat Jul 02, 2005 10:06 pm
Location: Sydney
Contact:

Post by Jim »

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
User avatar
geforcefan
Posts: 8
Joined: Fri Jun 08, 2007 10:28 pm
Location: Frankfurt // Schaafheim
Contact:

Post by geforcefan »

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: Select all

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: Select all

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 ^^
rapso
Posts: 140
Joined: Mon Mar 28, 2005 6:35 am

Post by rapso »

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.
User avatar
geforcefan
Posts: 8
Joined: Fri Jun 08, 2007 10:28 pm
Location: Frankfurt // Schaafheim
Contact:

Post by geforcefan »

But it inst greater than 2000. The maximum is 700 ....
mi casa es su casa ^^
TraxNet
Posts: 1
Joined: Mon Jun 04, 2007 6:39 pm

Post by TraxNet »

*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).
rapso
Posts: 140
Joined: Mon Mar 28, 2005 6:35 am

Post by rapso »

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.
User avatar
Jim
Posts: 476
Joined: Sat Jul 02, 2005 10:06 pm
Location: Sydney
Contact:

Post by Jim »

700/0.1=7000. Way out of range.

Jim
User avatar
geforcefan
Posts: 8
Joined: Fri Jun 08, 2007 10:28 pm
Location: Frankfurt // Schaafheim
Contact:

Post by geforcefan »

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 ;)
700/0.1=7000. Way out of range.
I cant understand! 700/0.1 = 70. Why 7000?

Ercan
mi casa es su casa ^^
Insert_witty_name
Posts: 376
Joined: Wed May 10, 2006 11:31 pm

Post by Insert_witty_name »

700/10 = 70
700/0.1 = 7000
User avatar
geforcefan
Posts: 8
Joined: Fri Jun 08, 2007 10:28 pm
Location: Frankfurt // Schaafheim
Contact:

Post by geforcefan »

Insert_witty_name wrote:700/10 = 70
700/0.1 = 7000
oh, my mistake, I saw a multiply chracter ^^
mi casa es su casa ^^
Ghoti
Posts: 288
Joined: Sat Dec 31, 2005 11:06 pm

Post by Ghoti »

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.
rapso
Posts: 140
Joined: Mon Mar 28, 2005 6:35 am

Post by rapso »

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;)
User avatar
geforcefan
Posts: 8
Joined: Fri Jun 08, 2007 10:28 pm
Location: Frankfurt // Schaafheim
Contact:

Post by geforcefan »

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 ^^
User avatar
dot_blank
Posts: 498
Joined: Wed Sep 28, 2005 8:47 am
Location: Brasil

Post by dot_blank »

mi casa es su casa
10011011 00101010 11010111 10001001 10111010
Post Reply