Texture padding is showing and alpha images get blurry

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

Moderators: cheriff, TyRaNiD

Post Reply
Zettablade
Posts: 71
Joined: Fri May 05, 2006 5:59 pm

Texture padding is showing and alpha images get blurry

Post by Zettablade »

When I load an image who's width or height is not to the power of 2, then I have to pad it. Problem is, the image padding is now showing when I draw the image with a u/v greater then the initial image size (regardless of whether it's sent through the 2d or 3d pipe, or if I strip blit or not.) I was wondering if anyone's had the same problem before, and if so, how did you fix it?

Secondly, alpha images seem to get blurry around the edges (between the alpha and the color), and it changes depending on their place on the screen. This only happens when I call sceGuTexFilter ( 1, 1 );

Here's how I have pspGU setup

Code: Select all

// vrelptr and valloc are from raphael's vram library
	fbp0 = ( u32* ) vrelptr ( valloc ( FRAMEBUFFER_SIZE ) );
	fbp1 = ( u32* ) vrelptr ( valloc ( FRAMEBUFFER_SIZE ) );
	zbp = ( u16* ) vrelptr ( valloc ( DEPTHBUFFER_SIZE ) );

	sceKernelDcacheWritebackAll();

	// Setup GU

	sceGuInit();
	sceGuStart ( GU_DIRECT, DList );

	sceGuDrawBuffer ( GU_PSM_8888, fbp0, BUF_WIDTH );
	sceGuDispBuffer ( SCR_WIDTH, SCR_HEIGHT, fbp1, BUF_WIDTH );
	sceGuDepthBuffer ( zbp, BUF_WIDTH );

	sceGuOffset ( 2048 - ( SCR_WIDTH / 2 ), 2048 - ( SCR_HEIGHT / 2 ) );
	sceGuViewport ( 2048, 2048, SCR_WIDTH, SCR_HEIGHT );
	sceGuDepthRange ( 65535, 0 );

	sceGuScissor ( 0, 0, SCR_WIDTH, SCR_HEIGHT );
	sceGuEnable ( GU_SCISSOR_TEST );

	sceGuDepthFunc ( GU_GEQUAL );
	//sceGuEnable ( GU_DEPTH_TEST );

	sceGuEnable ( GU_CLIP_PLANES );

	sceGuFrontFace ( GU_CW );
	sceGuEnable ( GU_CULL_FACE );

	sceGuShadeModel ( GU_SMOOTH );

	sceGuTexMode ( GU_PSM_8888, 0, 0, 1 );
	sceGuTexFunc ( GU_TFX_REPLACE, GU_TCC_RGBA );
	sceGuEnable ( GU_TEXTURE_2D );

	sceGuBlendFunc ( GU_ADD, GU_SRC_ALPHA, GU_ONE_MINUS_SRC_ALPHA, 0, 0 );
	sceGuEnable ( GU_BLEND );

	sceGuClearColor ( RGB ( 0, 0, 0 ) );
	sceGuClearDepth ( 0 );

	sceGuFinish();
	sceGuSync ( 0, 0 );

	sceDisplayWaitVblankStart();
	sceGuDisplay ( GU_TRUE );

// Custom matrix stuff, could be what's causing the bugs. If you want it posted, just ask
	vfpu_perspective_m ( &m_projection, 75.0f, 16.0f / 9.0f, 1.0f, 1000.0f );
	vfpu_ortho_m ( &m_ortho, 0.0f, 480.0f, 272.0f, 0.0f, -1.0f, 0.0f );
	vfpu_identity_m ( &m_projection_model );
	vfpu_identity_m ( &m_ortho_model );
	vfpu_identity_m ( &m_projection_view );
	vfpu_identity_m ( &m_ortho_view );

	sceKernelDcacheWritebackAll();
if you would like to see all the code, you can get it off of my svn

Code: Select all

svn co http://zettablade.0x89.org/SVN/vLib
chp
Posts: 313
Joined: Wed Jun 23, 2004 7:16 am

Post by chp »

1) Since non-pow2 textures is done by abusing the system a little bit (by setting them up as a bigger texture than they really are), you cannot use wrapping with these textures, you would have to split them at UV borders to safely wrap them around.

2) Are you sure you're not offsetting incorrectly into the texture? If you're using 2D mode the UV should be fixed, but for 3D you have to make sure that you center the texel properly so that it won't sample other pixels when using bilinear filtering.
GE Dominator
Post Reply