2 questions regarding 3D rendering

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

Moderators: cheriff, TyRaNiD

Post Reply
AnonymousTipster
Posts: 197
Joined: Fri Jul 01, 2005 2:50 am

2 questions regarding 3D rendering

Post by AnonymousTipster »

Firstly, what format are the textures in? There is no C source to the logo.o file in the cube sample which holds the texture. What I want to know is:

Code: Select all

extern unsigned char logo_start[] = {
/*what goes here to define the texture?*/
};
Is it hex like Nem's Hello world? is it ARGB or what?

Secondly, my faces are clipping too soon, and so dissappear when you are sliding past a wall, I can't seem to find how to lower the near clip variable. I have tried changing the near parameter when setting up my projection matrix

Code: Select all

matrix_identity((float*)&projection);	matrix_projection((float*)&projection,fovAmount,16.0/9.0f,0.5f,1000.0f);
sceGuSetMatrix(GU_PROJECTION,&projection);
But reducing the 0.5 to 0.05 just makes the surfaces flicker, and they still seem to dissappear when you get near (but not as near as I need it to be). Any ideas on what I might be doing wrong?

Thanks in advance.
chp
Posts: 313
Joined: Wed Jun 23, 2004 7:16 am

Post by chp »

The texture for the cube-sample is 16-bit (4444), or 4 bit R, 4 bit G, 4 bit B, 4 bit A. It's specified with sceGuTexMode(). Look at the documentation (in pspgu.h or in doxygen if you've built these docs) for which formats that are currently supported. We have not yet researched all of the formats and we know for certain that T16, T32 and DXT? should also be in there, thanks to various public sources (Breakpoint-presentation and pressreleases).

For your second question, instead of decreasing the distance of the near clip-plane (which will KILL depth on further distance), do a sceGuEnable(GU_CLIP_PLANES). This will enable frustum-clipping in addition to the scissoring, and will hopefully help. I did atleast put the eye of the camera in the cube-sample inside the cube using this, so it should work.
GE Dominator
AnonymousTipster
Posts: 197
Joined: Fri Jul 01, 2005 2:50 am

Post by AnonymousTipster »

I know which bit depth it is in, but all I really need is the logo.c file which contains the texture, because I tried:
255,255,255,255, for each pixel.
RGB16(255,255,255,255), for each pixel and
0xffff, for each pixel.
None of which gave me the right texture. All I need to know is what goes between the { }.

I have enabled GU_CLIP_PANES, but this doesn't seem to make a difference, is there a way to change the near/far view frustrum planes without changing the projection matrix; I can't find any functions that might relate to it and changing the projection matrix has the same effect as before.
chp
Posts: 313
Joined: Wed Jun 23, 2004 7:16 am

Post by chp »

Well if you want the texture in C-form, use bin2c provided by pspsdk, which will give atleast close to what you want. I never had the logo as C-source, I instead opted to put into a format that didn't occupy that much space. Each pixel in that file consists of 2 bytes, so just pair them together.

Strange. You have to alter the projection-matrix to change the clip-planes yes, because it's after this projection that the coordinate is in homogenous space and can be properly clipped.
GE Dominator
Shito
Posts: 21
Joined: Wed May 11, 2005 1:38 am

Post by Shito »

AnonymousTipster wrote:I know which bit depth it is in, but all I really need is the logo.c file which contains the texture, because I tried:
255,255,255,255, for each pixel.
RGB16(255,255,255,255), for each pixel and
0xffff, for each pixel.
None of which gave me the right texture. All I need to know is what goes between the { }.
That's an easy question : logo_start is an array of chars, thus of 8 bits entries.
Make it an array of shorts and put 0xffff to each pixel, should work better now. ^^

Now the real question is : why on earth is it working in the cube sample ? ^^
I feel like I'm either missing something, or telling an enormous stupidity here...
AnonymousTipster
Posts: 197
Joined: Fri Jul 01, 2005 2:50 am

Post by AnonymousTipster »

My code for a blank 4x4 texture is looking like this:

Code: Select all

unsigned short logo2_start[] = {
		0xffff,
		0xffff,
		0xffff,
		0xffff,
		0xffff,
		0xffff,
		0xffff,
		0xffff,
		0xffff,
		0xffff,
		0xffff,
		0xffff,
		0xffff,
		0xffff,
		0xffff,
		0xffff
};
(I've tried it with 0xffffff and in 32bit mode as well as the default 16bit mode)
But I get a texure that is half white and half black, when it should all be white. The reason I want to declare a texture in-code is that I can animate the textures on-the-fly if I know what format they are in (0xffff,255,255,255 or whatever).

The problem with the frustrum culling may be unsolvable, because it seems to be culling the entire face until all the vertices are on-screen, rather than one or more are on-screen. This means that when the player is sliding past a wall, the segment of wall nearest the player seems to appear and dissapear, rather than there being a clear cut frustrum where the face is being clipped to.

EDIT: The texture stuff isn't THAT important, I could just use a stream of .o files instead, but if there is a solution to the clipping problem, I'd like to know about it.
SANiK
Posts: 29
Joined: Tue Jul 05, 2005 5:25 am

Post by SANiK »

Try matrix_projection((float*)&projection,75.0f,16.0/9.0f,0.0001f,1000.0f);
That's for the znear, but as for the polygon sorting, it seems like the PSP sorts polygons by using the average of the Z axis, then checking if the averaged out Z position fits in the screen and then it draws.
ector
Posts: 195
Joined: Thu May 12, 2005 10:22 pm

Post by ector »

SaNIK, i think it's more likely that your ratio between far and near is WAY too high. try 0.1 and 500 or something.
chp
Posts: 313
Joined: Wed Jun 23, 2004 7:16 am

Post by chp »

Eh, the PSP doesn't sort polygons. It does what every other hardware solution do these days, it uses a z-buffer to make sure rendering comes out in the correct order. This buffer is filled with 1/screenspace z (homogenous Z projected into screenspace) (if it's anything like the zbuffer solution on PS2 that is) which allocates a lot more entries for objects nearby, and less as you progress away from the camera. Setting the nearplane as close as 0.0001 will really slaughter the zbuffer-precision from just a few millimeters away, as all that range is lost dealing with a very short space. You should always make sure that your near plane is as far away from the camera as possible.
GE Dominator
AnonymousTipster
Posts: 197
Joined: Fri Jul 01, 2005 2:50 am

Post by AnonymousTipster »

I fiddled with the settings (with your advice), and after changing the MinClip pane to 1.5, it all looks much better - only a few floor tiles flicker, but that's excusable. It works great now.
You really are the GPU master, chp. Thanks.

Also, has anybody got MipMapping working yet, because changing the mip level to anything other than 0 stops polygons from being displayed.
ector
Posts: 195
Joined: Thu May 12, 2005 10:22 pm

Post by ector »

Mipmapping with trilinear filtering and everything works fine but you have to generate and supply your own mipmaps. My texture tool can help you with this. http://www.dtek.chalmers.se/~tronic/PSPTexTool.zip.
Last edited by ector on Thu Jul 28, 2005 5:42 am, edited 1 time in total.
AnonymousTipster
Posts: 197
Joined: Fri Jul 01, 2005 2:50 am

Post by AnonymousTipster »

Thx. It's down ATM, so I'll try later.
(I thought you might have to do your own, but I dissmissed the thought, because DirectX (or OGl I think) calculate them for you.) Oh well.

Edit: Wait, I've got it - you typed the adress as .xip, not .zip.
AnonymousTipster
Posts: 197
Joined: Fri Jul 01, 2005 2:50 am

Post by AnonymousTipster »

Ok, I've been trying to get the MipMaps to work, the images are loading, but I can't get the MipMaps to map, I just end up with the full res texture all along the Z. I assume this is how it should be done:

Code: Select all

sceGuTexImage(0,64,64,64,grassTex_temp);
sceGuTexImage(1,32,32,32,grassTex32_temp);
/*then manipulate matrix+draw*/
With 0 being the full res texture and 1 being the half res texture. I have also set the TexFilter to a mipmap mode, but that doesn't change it.
ector
Posts: 195
Joined: Thu May 12, 2005 10:22 pm

Post by ector »

You didn't forget to set max mip level?
and make sure that it's the minification filter you set to a mip filter.
AnonymousTipster
Posts: 197
Joined: Fri Jul 01, 2005 2:50 am

Post by AnonymousTipster »

Current filter codeline:

Code: Select all

sceGuTexFilter(GU_LINEAR_MIPMAP_LINEAR,GU_LINEAR_MIPMAP_LINEAR);
And it doesn't have an effect.
Post Reply