Contact Jim +44 (0)973 732140 jim@codeworks.demon.co.uk

 

   

  First of all what you don't see....

There are two toruses in the scene.
One exactly on top of the other, one with a static texture map, the other with an environment mapped shine texture.

The trick to this one is understanding how the ordering table works.

Objects are sorted on depth and inserted into the ot, we know that much.

Ahh, you ask, but what if two objects have the same depth, who's drawn first?

Answer, whatever object is added to the ordering table last.

You'll probably understand
it better if you examine an ot carefully while constructing one.

But in a nutshell libps keeps a pointer
to the primitives in the packet area, as they're added to the scene. When a new primitive is added. It's linked to the previous primitive for that depth. When GsDrawOT is issued, libps runs down the list from the last one added way back down to the first, drawing the first one last. So in effect, reverse the order you add items to the OT to which you wish them to appear.

So for this one. I added the shine object to the OT before I added the textured donut.

How we get the smeary shine effect?

Normals my friend, Normals. But rather than using them for backface culling as they're commonly used, we also use 'em to select the texture coordinates for the object.

Don't normals take a bit to calculate, especially unit normals? That takes a square root!!

Well, first off the tmd object format used by libps precalculate the normals, so thats already done. Fortunately you can rotate unit normals the same as you rotate the object they relate to, and they remain intact and correct. So I don't have to recalculate them every frame, just rotate them, which is much much quicker.

The torus object has a normal for each vertex in it, and much like everything else on the playstation, they are held as a 14 bit fixed point numbers.

We want to use them to select texture coordinates. Well my texture is 256 X 256 and the normals could as high as 4096. So I just shift the x and y portion of the normal right by 6 to obtain a number in the correct range, and plug it into the primitive as the texture coordinates.

Behold we get something looking shiny. I also made the texture transparent to make it look more convincing.

You can also use this technique to make objects look metallic or reflect their surroundings.

...and thats how it was done.....