How to change the color of a sprite or texture

I've a technical problem with my ongoing "karate" game projet.

There are 12 players, I can't design different sprites for each player. For now, all player are white and can be distinguished only by a colored sprite located at their feet, but it is often confusing when player are close from eachother.

I plan to have numerous movements and they'll be the same for each player. Now my sprites are using only two colors, and I think it is possible to change the color of this sprite to adapt to the color of the player to be displayed.

So do you think it would be possible to

1. change the color offset stored in the SGL sprite attribute structure in real time ? or

2. change the sprite palette adress between two sprites display, in a single slSynch() ? or

3. use some gouraud and use the two color sprite as a mask ?

Do you have other idea ?

thanks.
 

RockinB

Staff member
Sorry, but I haven't investigated the similarities between sprites (SPR_ATTR) and polygons (ATTR) enough.

But you could assign a different palette to every player.

And it's not difficult to change the whole animation in GIMP or something, giving different animations for players to choose from.

If you think you're running out of VDP1 VRAM (448 kB), just use the DMA method with 12 dummy textures ( one for each player) in texture table, as can be taken from the demo in SaturnGameTutorial_050701.rar.

About making it look different by applying gouraud colors or other attributes, this is sure an option, too.
 

slinga

Established Member
I'm in the same boat as you. I have a number of identical sprites that only differ by color. So I did things the stupid way, I just defined each as a different sprite. It's horribly inefficient memory usage, but it works for my needs.
 
1.

I tried the gouraud solution, and It kind of works ...

gour1.png


on satourne. Sprites are incorrectly displayed on the real saturn (I must have done something wrong).

2.

I tried to change the color, using the SPR_ATTR structure passed to the sldispsprite. Does not work.

Code:
typedef struct {

  Uint16    texno

  Uint16 atrb;    

  Uint16 colno;

  Uint16 gstb;

  Uint16 dir;	

} SPR_ATTR

How comes changing the colno before displaying does not change anything ?
 

RockinB

Staff member
Originally posted by vreuzon@Fri, 2005-07-15 @ 08:24 AM

2.

I tried to change the color, using the SPR_ATTR structure passed to the sldispsprite. Does not work.

Code:
typedef struct {

   Uint16        texno

   Uint16  atrb;        

   Uint16  colno;

   Uint16  gstb;

    Uint16  dir;	

} SPR_ATTR

How comes changing the colno before displaying does not change anything ?

[post=136753]Quoted post[/post]​


Because sprites are not polygons. Sprites are supposed to be a bitmap image. The only way to effect it's color is thus the gouraud method. But things like half-transparency, half-brightness, shadow and mesh should work, too.

Remember these different sprite types the VDP1 can do?
 
1.

Because sprites are not polygons. Sprites are supposed to be a bitmap image.

The SPR_ATTR structure is for sprites, not polygons, isn't it ? I believed the col attribute was the palette offset.

Remember these different sprite types the VDP1 can do?

Do you think of something special ?

For the gouraud shading, I cannot figure out what is wrong. Could you please have a look at this code ?

Code:
static	Uint16	GourTbl[12*4] = {

	GRTBL( 0, 16, 16 ),

	GRTBL( 1, 16, 16 ),

...

	GRTBL( 11, 16, 16 ),

}

then : 

slDMACopy(GourTbl,(void*)(SpriteVRAM+0x70000),sizeof(GourTbl));

and finally : 

#define GRaddr 0xe000

attr[foo].gstb = GRaddr + 5;

slPutSprite(pos, (SPR_ATTR *)(&attr[foo]),ang);

Using this code, some sprite won't display, and the rest is ugly.

2.



Can you make the animations exchangeable to enable mods?

I'll try program something playable and funny first.

I don't like skins and mods very much, and I won't code something for sprites to be easily exchangeable for now because I believe nobody will ever use it. If someone want to paint sprites, he just tells me.
 
I still need some help with gouraud shading on sprites.

Again, here is my problem : how to apply (non realtime) gouraud shading on a paletted sprite ? The way I coded it works perfectly with satourne; with the saturn, nothing is correctly displayed. So it looks like an initialisation problem.

I tried to read the vdp documentation about color calculation, but, in short, I did'nt even understood the page numbers...

Does someone here knows how color calculation is done, and how it can be configured with or without SGL ?

thanks
 

RockinB

Staff member
Again, here is my problem : how to apply (non realtime) gouraud shading on a paletted sprite ?

You know from the CHROME example that (red) gouraud shading on paletted sprites does interpolate the palette index and not the RGB color.

If you are using paletted sprites because of limited texture RAM, you could alternatively use 4-bit-per-texel LUT format with RGB entries in the table. This would allow gouraud shading (and all other color calculations) to behave like with normal RGB textures.

I think Piratero used LUT sprites in his bday.bin demo.

The way I coded it works perfectly with satourne; with the saturn, nothing is correctly displayed. So it looks like an initialisation problem.

Is the gouraud table loaded to the same place that the sprites do reference to?

slDMACopy(GourTbl,(void*)(SpriteVRAM+0x70000),sizeof(GourTbl));

and finally :

#define  GRaddr  0xe000

 
thanks, rb.

Originally posted by Rockin'-B+Fri, 2005-09-23 @ 07:42 PM--><div class='quotetop'>QUOTE(Rockin'-B @ Fri, 2005-09-23 @ 07:42 PM)</div><div class='quotemain'>You know from the CHROME example that (red) gouraud shading on paletted sprites does interpolate the palette index and not the RGB color.

[/b]


Do you know how this interpolation is calculated ?

<!--QuoteBegin-Rockin'-B
@Fri, 2005-09-23 @ 07:42 PM

If you are using paletted sprites because of limited texture RAM, you could alternatively use 4-bit-per-texel LUT format with RGB entries in the table. This would allow gouraud shading (and all other color calculations) to behave like with normal RGB textures.

[/quote]

If I use 16 colors sprites, it will allow gouraud shading, right ?
 

RockinB

Staff member
Originally posted by vreuzon+Tue, 2005-09-27 @ 11:20 AM--><div class='quotetop'>QUOTE(vreuzon @ Tue, 2005-09-27 @ 11:20 AM)</div><div class='quotemain'>Do you know how this interpolation is calculated ?

[post=139985]Quoted post[/post]​

[/b]


For each pixel of a sprite on screen:

Depending on the distance of the pixel to the vertices (in screen space), the gouraud color components (red, green and blue, 32 values each) of the vertices are bilinear interpolated to give a per-pixel gouraud color.

This color is added (?) to the polygon color or textured polygon color.

In the CHROME demo, the red component of the gouraud color changes the palette index by +/-16. Note that it's pallete got 256 entries.

<!--QuoteBegin-vreuzon
@Tue, 2005-09-27 @ 11:20 AM

If I use 16 colors sprites, it will allow gouraud shading, right ?

[post=139985]Quoted post[/post]​

[/quote]

Yes. If the LUT contains 15bit RGB color values, there is no difference to using RGB sprites.
 
It works now.

The gouraud on paletted sprites gives very strange results. I can post a binary if you want to do some testing. Note than satourne calculates as if it was non paletted sprites; ssf does some other stuff, and the real saturn someting else on color paleete offsets.

thanks.
 

RockinB

Staff member
Originally posted by vreuzon+Thu, 2005-09-29 @ 08:26 AM--><div class='quotetop'>QUOTE(vreuzon @ Thu, 2005-09-29 @ 08:26 AM)</div><div class='quotemain'>It works now.

[post=140045]Quoted post[/post]​

[/b]


Great! :D

<!--QuoteBegin-vreuzon
@Thu, 2005-09-29 @ 08:26 AM

The gouraud on paletted sprites gives very strange results. I can post a binary if you want to do some testing.

[post=140045]Quoted post[/post]​

[/quote]

I do test everything that is released for Saturn. But I can't until next week. Feel free to post a binary, I'll gladly try it out.
 
Top