Stunts Forum

Stunts - the Game => Custom Cars with Stressed => Topic started by: Ryoma on August 21, 2021, 06:23:05 PM

Title: Lancia LC1
Post by: Ryoma on August 21, 2021, 06:23:05 PM
3 victories too...but in one season !!!!
Title: Re: Lancia LC1
Post by: KyLiE on August 22, 2021, 03:15:09 AM
Excellent work, the dashboard looks great!  Petrolicious made a nice video (https://www.youtube.com/watch?v=30o_lPCcuxs) on the Lancia LC1 last year.
Title: Re: Lancia LC1
Post by: alanrotoi on August 22, 2021, 04:30:39 AM
What color is transparent? 🤔
Title: Re: Lancia LC1
Post by: KyLiE on August 22, 2021, 05:55:12 AM
Stunts uses alpha masks rather than a specific colour to define transparency.  This is mentioned in the Stunts Wiki (http://wiki.stunts.hu/index.php?title=Car_files#Dashboard_static_parts_.28stda.2A.pvs.29), but having a look at the dashboard graphics of an existing car in stressed will help you better understand how they work.
Title: Re: Lancia LC1
Post by: alanrotoi on August 22, 2021, 06:35:48 AM
Thanks but I dont understand how to put transparencies. Could you explain me? In steps o or just " do this and that".
Title: Re: Lancia LC1
Post by: KyLiE on August 22, 2021, 08:58:26 AM
Using Ryoma's Lancia LC1 as an example, if we open STDALLC1.VSH in stressed, we can see that the top section of the dash that has transparency is defined by the dast and dasm resources.  dast contains the main graphical elements and dasm is the transparency mask.  When viewing the mask, stressed automatically applies the transparency so it appears the same colour as the background, which is grey.  However, you can see what the actual mask image looks like by unchecking the "Alpha" option, which allows you to see the colours used:
The same method is used for transparency on other dashboard elements.  To practice, try the following exercise:
Now take the car for a drive in Stunts and see what it looks like! 8)
Title: Re: Lancia LC1
Post by: Ryoma on August 22, 2021, 09:53:29 AM
Good explanation KyLiE. I will try but if dash.bmp = dast.bmp and after you put white mask only on jauge for dasm.bmp...the needle color would may change.

Edit : not working. Only with ins1 and inm1 (and associated ins3 inm3)

Title: Re: Lancia LC1
Post by: alanrotoi on August 22, 2021, 08:05:21 PM
Yeah! Thank you KyLiE! I'll try it with Dodge Monaco Highway Patrol :D
Title: Re: Lancia LC1
Post by: Ryoma on August 22, 2021, 09:37:15 PM
You can see the Viper too. It's a school case using mask.
Title: Re: Lancia LC1
Post by: KyLiE on August 23, 2021, 04:22:09 AM
Quote from: alanrotoi on August 22, 2021, 08:05:21 PM
Yeah! Thank you KyLiE!

You're welcome! :)
Title: Re: Lancia LC1
Post by: Cas on August 24, 2021, 03:46:30 AM
Not sure if this will help in any way, but this is what I know about classic 8bit-per-pixel transparency masks:

With classical computers and 8bpp graphics, the mask was usually selected to use 0 for the pixels that will display the foreground image and 255 for the pixels that will display the background image. This may appear weird, because we tend to associate 0 with black and 255 maybe with white, so it looks like the mask has its colours inverted, but there's a good reason for this.

Older computer were slow and it was important to use as few instructions as possible to produce transparency. Comparing pixel colours and including conditional jumps in the assembly code was prohibitively slow. I remember when I had to face this problem myself and I ended up solving it exactly this way because it really is the only way to make it fast with classical instructions. What the code does, and I guess this with a lot of certainty, is for every pixel...

1. AND the current background pixel against the mask pixel
2. OR the resulting screen pixel with the foreground image pixel

Only two instructions per pixel!  Nowadays, with MMX and more advance instructions, a modern alpha channel with partial transparency can even be faster than this classical trick.

I'm explaining this because I think knowing this algorithm can tell us how to exploit it to get some special effects. I'm talking about using values other than 0 and 255 in some parts of a mask. Mostly everything will look awful when doing this, but if the pixel in question is selected carefully, this can be useful. Unfortunately, one thing that cannot be done with this is changing the needle colour, as this is drawn after the instruments and surely does not use any transparency algorithm.