Recent Posts

Pages: [1] 2 3 ... 10
1
Project announcement / Re: Sonic Z-Treme
« Last post by XL2 on April 20, 2018, 05:14:51 pm »
Just a small update to show the Sonic R-style fade in/out.

https://youtu.be/r4Gkgqitv44
2
Jo Engine Wish List / Re: 3D Textured Mesh Sample
« Last post by XL2 on April 16, 2018, 10:50:24 pm »
No demo yet, so make sure you follow the explanations (text I posted earlier today at Segaxtreme) :

I got the model converter I promised you working at pretty much 70-80%, but I didn't have time to test it nor write a demo.
It seems to be ok, but since I didn't test it, I can't guarantee it.
IT'S ALSO REALLY QUICKLY CODED! I made it in like 2 hours and only did small tests, so it might not work properly.

I'm sharing it with you now, but I guess without a demo it might be a bit hard to use.
The file starts with a header portion of 36 bytes, then writes the texture data, then the polygon data.
I added the header and the code to know how I write to the binary file so that you know what to load.
You can use the image converter I posted elsewhere to know how to load the paletted textures.
The program also outputs a text file including all the PDATA, but no textures, so you can also play with that.
Please note that it only supports textures, so if you want to load a flat shaded polygon, you can use something such as a 8x1 texture with 1 color. I guess it would be a bit slower than using a real flat shaded quad, but I don't think I will have time to modify my code to allow it for now.

Code: [Select]
//HEADER
typedef struct
{
    unsigned short  TOTAL_MESH; //total amount of PDATA
    short            TOT_TEXT;  //total amount of textures
    unsigned int    TEXT_SIZE;  //to quickly load from disk, that's the size of the textures in bytes
    unsigned int    PDATA_SIZE; //to quickly load from disk, total size of pdata in bytes
    vector3 Origin; //Origin point used to "center" the culling/collision data and your model's position. Should be 0,0,0 unless you have an offset
    vector3 Length;  //Lenght along the x,y z axis. Together with the origin, that gives you the bounding box for quick broad collision testing
} _MOD_DATA;

//TEXTURE DATA
unsigned short convert_to_4bpp(unsigned short a, unsigned short b){    return (((a&0xffff)<<4) | (b));}

void WRITES_TEXTURES(ofstream * binFile)
{
    cout << "Writing the textures to binary file...\n\n";
    unsigned short buf16;

    for (short i=0; i<MODEL_DATA.TOT_TEXT; i++)
    {
        unsigned short w = swap_endian_ushort(pimg[i].width);  //pimg == paletted image
        unsigned short h = swap_endian_ushort(pimg[i].height);
        binFile->write((char*)&w, sizeof(unsigned short));
        binFile->write((char*)&h, sizeof(unsigned short));
        binFile->write((char*)&MODEL_DATA.TEXT_SIZE, sizeof(int));

        for (short ii=0; ii< (pimg[i].width * pimg[i].height);)
        {
            unsigned char buf = 0;
            buf =  (unsigned char) convert_to_4bpp(pimg[i].palette_id[ii], pimg[i].palette_id[ii+1]);
            binFile->write((char*)&buf, sizeof(unsigned char));
            ii+=2;
        }

    }
    for (short i=0; i<MODEL_DATA.TOT_TEXT; i++)
    {
        for (unsigned int ii=0; ii<16; ii++)
        {
           buf16 = swap_endian_ushort(pimg[i].palette[ii]);
           binFile->write((char*)(&buf16), sizeof(unsigned short));
        }
    }
}


//PDATA
/*****
This writes all the PDATA in a sequential order
*****/
void WRITE_PDATA(ofstream * file)
{
    unsigned short bUint16;
    unsigned int bUint32;
    int bSint32;

    for (unsigned int i=0; i<MODEL_DATA.TOTAL_MESH; i++)
    {
        //PDATA, including buffers for the pointers
        bUint32 = 0;
            file->write((char*)&bUint32, sizeof(unsigned int));
        bUint32 = swap_endian_uint(mesh_array[i].nbPoint);
            file->write((char*)&bUint32, sizeof(unsigned int));
        bUint32 = 0;
            file->write((char*)&bUint32, sizeof(unsigned int));
        bUint32 = swap_endian_uint(mesh_array[i].nbPolygon);
            file->write((char*)&bUint32, sizeof(unsigned int));
        bUint32 = 0;
            file->write((char*)&bUint32, sizeof(unsigned int));

        //POINT (vertices), 12 bytes each
        for (unsigned int ii=0; ii<mesh_array[i].nbPoint; ii++)
        {
            for (unsigned int j=0; j<3; j++)
            {
                bSint32 = swap_endian_sint(mesh_array[i].pntbl[ii][j]);
                file->write((char*)&bSint32, sizeof(int));
            }
        }
        //POLYGON, 12 bytes for normals and 8 bytes for vertices
        for (unsigned int ii=0; ii<mesh_array[i].nbPolygon; ii++)
        {
            //Normals
            for (unsigned int j=0; j<3; j++)
            {
                bSint32 = swap_endian_sint(mesh_array[i].pltbl[ii].norm[j]);
                file->write((char*)&bSint32, sizeof(int));
            }
            //Vertices
            for (unsigned int j=0; j<4; j++)
            {
                bUint16 = swap_endian_ushort(mesh_array[i].pltbl[ii].Vertices[j]);
                file->write((char*)&bUint16, sizeof(unsigned short));
            }
        }
        //ATTRIBUTES, 12 bytes each
        for (unsigned int ii=0; ii<mesh_array[i].nbPolygon; ii++)
        {
            file->write((char*)&TextureAttributeArray[mesh_array[i].attbl[ii].texno].flag, sizeof(unsigned char));
            file->write((char*)&TextureAttributeArray[mesh_array[i].attbl[ii].texno].sorting, sizeof(unsigned char));
            bUint16=swap_endian_ushort(TextureAttributeArray[mesh_array[i].attbl[ii].texno].texno);
                file->write((char*)&bUint16, sizeof(unsigned short));
            bUint16=swap_endian_ushort(TextureAttributeArray[mesh_array[i].attbl[ii].texno].atrb);
                file->write((char*)&bUint16, sizeof(unsigned short));
            bUint16=swap_endian_ushort(TextureAttributeArray[mesh_array[i].attbl[ii].texno].colno);
                file->write((char*)&bUint16, sizeof(unsigned short));
            bUint16=swap_endian_ushort(TextureAttributeArray[mesh_array[i].attbl[ii].texno].gstb);
                file->write((char*)&bUint16, sizeof(unsigned short));
            bUint16=swap_endian_ushort(TextureAttributeArray[mesh_array[i].attbl[ii].texno].dir);
                file->write((char*)&bUint16, sizeof(unsigned short));
        }
    }
}

So, you can use something such as GFS_LOAD starting with 36 bytes to know what the file contains, then read the textures (just put it in low-work RAM), DMA everything to VRAM where it belongs and then overwrite the data in low-work RAM with the PDATA (since the textures are transfered, you don't need them in work-RAM, so just overwrite them).
For the textures, make sure you do it per face instead of using texture coordinates.
The converter I wrote only supports 16 colors per texture, but save your TGA files as 32 bits files. The alpha channel is treated as transparent.
I'll see what I can do for the demo, but I'm a bit busy with work so I might not have time. Let me know if you encounter bugs!
I added the title map from Quake as a demo, but this tool isn't meant for maps since it doesn't do map partition nor does it hold data for culling!

3
Project announcement / Re: Sonic Z-Treme
« Last post by XL2 on April 14, 2018, 10:56:08 pm »
These games use the color calculation  (with ratios) to make a smooth fade in and fade out. It's what I'm doing now. It might be possible with CLUT sprites too, but I have to try a few more things first. But the only way to do actual gouraud shading on color bank sprites requires a ton of color RAM, but you only have 4 KB shared for all the background layers and the color bank sprites.
High res mode is attractive, but you can't simply flip a switch and make it work. You really need to setup everything in a specific way and there are many limitations.
I could try it for menus and such, but even for that I don't want to waste time on it.
4
Project announcement / Re: Sonic Z-Treme
« Last post by corvusd on April 14, 2018, 10:42:01 pm »
The flat shaded quads in SGL can use flat lightning both in RGB and palette format.
Perfect! :D

I'm not using the SCU DSP yet, so it's SH2 only.
Not mention SCU in the next two years. I promise XD

I can't do realtime light with color bank sprites, but I'm now doing like in Sonic R and Bulk Slash.
Why not? What refer exatly that doing like this games?

I can't use the high res mode, it's super hard to setup, so I don't want to waste time on it.
It is possible, the requirements are many and both VDPs. It is normal that you choose not to get involved in this. But is very attractive, have it full resolution SS in a Sonic game. :)
5
Project announcement / Re: Sonic Z-Treme
« Last post by XL2 on April 14, 2018, 05:24:09 pm »
The flat shaded quads in SGL can use flat lightning both in RGB and palette format.
I'm not using the SCU DSP yet, so it's SH2 only.
I can't do realtime light with color bank sprites, but I'm now doing like in Sonic R and Bulk Slash.

I can't use the high res mode, it's super hard to setup, so I don't want to waste time on it.
6
Project announcement / Re: Sonic Z-Treme
« Last post by corvusd on April 14, 2018, 10:52:32 am »
I just did a small video (it's not public as there isn't much to show) for the split screen mode and the removal of gouraud shading/use of CRAM sprites.

https://youtu.be/jHaXoe9lfMc

Really nice improvements!! Congratulations.

We can see source lighting in models no? Yo are calculate level of luminance or brightness, by VDP1 CC or change color palette for this face??

For calculate lighting use SH2 or SCU-DSP?

And finally. You can apply this lighting to scenery faces?

If you can all this without use CC, is possible you can use Full HiRes mode in VDP1 and VDP2.

Greetings!
7
Project announcement / Re: Sonic Z-Treme
« Last post by itsstillthinking1999 on April 13, 2018, 09:12:10 pm »
Love it! Models kinda remind me of Wolf from VF
8
General Jo Engine Help / Re: Audio issues - repeating/skipping
« Last post by Apolis on April 12, 2018, 11:02:30 pm »
I hope you didn't give up on your project, but using the tone editor on a mac emulator you could load your audio to the audio RAM, avoiding the PCM DMA transfer, which should fix your issues.
It's quite complicated to setup, but I can help you with it.

Hi XL2,
No no, I didn't give up. I carried on working on it and just playing it in NTSC via an emulator. It would be really nice to get it working on a real PAL system. Unfortunately I'm not too confident I understand your solution but I'll give it a go if you're willing help, or at least get me started! :D
9
Project announcement / Re: Sonic Z-Treme
« Last post by XL2 on April 12, 2018, 03:12:18 pm »
I just did a small video (it's not public as there isn't much to show) for the split screen mode and the removal of gouraud shading/use of CRAM sprites.

https://youtu.be/jHaXoe9lfMc
10
Project announcement / Re: Sonic Z-Treme
« Last post by XL2 on April 11, 2018, 03:08:26 pm »
The way they did it in the Chrome demo is that they use a palette of different luminances.
The VDP1 does the gouraud shading processing, but when it's using paletted sprites it just offsets an index instead of the actual RGB color.
So the result is that by using only red gouraud processing you will exactly offset +- 1 to 16 in each direction for each verticle.
You could do it with 16 colors banks, but then you could only do it with one color and only 7-8 different luminances, else it will overflow.

I could do like Sonic R, but I could also just put static lightning on the textures.
The issue with Sonic R is that you have gouraud on quads close to the camera, then you lose that luminance as it starts disappearing.
I have enough VRAM left to generate other textures for luminance.
From the videos of Saturn Shenmue, it seems to be what they did.
Speaking of Saturn Shenmue video, I noticed lots of triangles in the background (they get clipped out). So I'm not sure if it's running on a real Saturn or if it's using software rendering for backgrounds.
Pages: [1] 2 3 ... 10
SMF spam blocked by CleanTalk