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 

Texture coordinates generation, projection. Unknown states.

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



Joined: 04 Apr 2004
Posts: 25
Location: Lithuania, Vilnius

PostPosted: Thu Jul 21, 2005 11:08 pm    Post subject: Texture coordinates generation, projection. Unknown states. Reply with quote

Hi,


Recently, while playing with texture projection, I've discovered the following things:

1) sceGuEnable( 19 )
does flipping of the normal, which affects both lighting ant texture projection

2) sceGuTexMapMode( arg0, arg1, arg2 )
arg0 (0-3?):
0 - disables texture projection, enables sceGuTexOffset/Scale.
1 - enables texture coordinates generation. Uses matrix (spcified as GU_TEXTURE) to transform source 2d/3d vector. Source vector is a vertex component specified using sceGuTexProjMapMode. Disables sceGuOffset/Scale. Strangely enough, source vectors are in object space, _not_ post-transformed ones.
2 - ? (sampled texels seems to be uniform other the poly, but somewhat darker than pure white)
3 - ?
arg1, arg2: ??? (no effect)

sceGuTexProjMapMode( arg0 )
arg0 (0-3) source for texture coord calculation, is multiplied by GU_TEXTURE and projected into 2d if necessary:
0 - position in object space, resulting 3d vector is projected into 2d
1 - object UV
2 - normalized normal, resulting 3d vector is projected into 2d
3 - not-normalized normal, resulting 3d vector is projected into 2d

3) sceGuEnable( 15 )
uses post-transformed and projected object position as a 2d texture coordinates. Omits both UV specified in vertices and generated texture coordinates. Is not affected by sceGuTexOffset/Scale or GU_TEXTURE.

4) sceGuEnable( 21 )
seems to multiply resulting fragment (after applying texture function) by 2.


Hope that provides some usefull information.
Back to top
View user's profile Send private message Visit poster's website
adresd



Joined: 17 Jan 2004
Posts: 43

PostPosted: Fri Jul 22, 2005 12:12 am    Post subject: Reply with quote

Quote:

2) sceGuTexMapMode( arg0, arg1, arg2 )
arg0 (0-3?):


arg0 = 2 seems to be envmap mode

still playing with it
Back to top
View user's profile Send private message
ReJ



Joined: 04 Apr 2004
Posts: 25
Location: Lithuania, Vilnius

PostPosted: Fri Jul 22, 2005 9:17 pm    Post subject: Reply with quote

adresd wrote:

arg0 = 2 seems to be envmap mode


Yeah, seems to be the envmap mode. Although the envmap matrix setup is a bit strange, that's what I've figured out:

The envmap matrix (2x3) is specified as a combination of 2 columns. Columns can be set using sceGuLight() [sic!] as a light position (maybe it's some kind of error in pspgulib?). So 4 different columns can be specified. The actual envmap matrix is assembled specifying column indices using sceGuTexMapMode().
The UV coordinates (calculated by GU/GE from normals) are multiplied by the envmap matrix (2x3) to generate actual texture UV coords.

sceGuTexMapMode( arg0, arg1, arg2 )
arg0: 2 - envmap mode
arg1 (0-3): index of the 1st column for the envmap matrix (2x3)
arg2 (0-3): index of the 2nd column


it may look abit strange, but it works:
Code:
   ScePspFVector3 columns[4] = {
      { 0.707f, 0.707f, 0.0f },   // cos(a), sin(a), tx
      { -0.707f, 0.707f, 0.0f },  // -sin(a), cos(a), ty
      { 0.86f, 0.5f, 0.0f },
      { -0.5f, 0.86f, 0.0f }
   };
   sceGuLight( 0, GU_DIRECTIONAL, GU_DIFFUSE, &columns[0] );
   sceGuLight( 1, GU_DIRECTIONAL, GU_DIFFUSE, &columns[1] );
   sceGuLight( 2, GU_DIRECTIONAL, GU_DIFFUSE, &columns[2] );
   sceGuLight( 3, GU_DIRECTIONAL, GU_DIFFUSE, &columns[3] );

   sceGuTexProjMapMode( 0 );
   sceGuTexMapMode( 2, 0, 1 ); // rotate envmap 45 degrees
   //sceGuTexMapMode( 2, 2, 3 ); // rotate envmap 30 degrees
Back to top
View user's profile Send private message Visit poster's website
adresd



Joined: 17 Jan 2004
Posts: 43

PostPosted: Fri Jul 22, 2005 11:14 pm    Post subject: Reply with quote

Nice work, that works nicely :)
Back to top
View user's profile Send private message
ReJ



Joined: 04 Apr 2004
Posts: 25
Location: Lithuania, Vilnius

PostPosted: Sat Jul 23, 2005 7:11 pm    Post subject: Reply with quote

Thanks :)

I did a sample showing environment mapping:
http://rej.50megs.com/psp/envmap


Last edited by ReJ on Sat Jul 23, 2005 10:54 pm; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website
chp



Joined: 23 Jun 2004
Posts: 313

PostPosted: Sat Jul 23, 2005 10:29 pm    Post subject: Reply with quote

Good work! I'll update GU right away with this information, and I'll update your sample to use these new defines aswell.

The new defines will be:

Code:

/* States*/
#define GU_FACE_NORMAL_REVERSE  (19)
#define GU_FRAGMENT_2X          (21)

/* Texture Map Mode */
#define GU_TEXTURE_COORDS       (0)
#define GU_TEXTURE_MATRIX       (1)
#define GU_ENVIRONMENT_MAP      (2)

/* Texture Projection Map Mode */
#define GU_POSITION             (0)
#define GU_UV                   (1)
#define GU_NORMALIZED_NORMAL    (2)
#define GU_NORMAL               (3)


If you think they should be named differently, let me know.
_________________
GE Dominator
Back to top
View user's profile Send private message
jsgf



Joined: 12 Jul 2005
Posts: 254

PostPosted: Mon Aug 01, 2005 4:21 pm    Post subject: Re: Texture coordinates generation, projection. Unknown stat Reply with quote

ReJ wrote:

2 - ? (sampled texels seems to be uniform other the poly, but somewhat darker than pure white)


Could it be some other lighting thing? Shadows? I don't suppose there's any support for depth textures?
Back to top
View user's profile Send private message Visit poster's website
ReJ



Joined: 04 Apr 2004
Posts: 25
Location: Lithuania, Vilnius

PostPosted: Sun Aug 07, 2005 6:35 pm    Post subject: Re: Texture coordinates generation, projection. Unknown stat Reply with quote

jsgf wrote:
ReJ wrote:

2 - ? (sampled texels seems to be uniform other the poly, but somewhat darker than pure white)


Could it be some other lighting thing? Shadows? I don't suppose there's any support for depth textures?


As it is already discovered, 2 is an environment mapping mode.
Back to top
View user's profile Send private message Visit poster's website
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