The International Simutrans Forum

Development => Extension Requests => Topic started by: agamemnus on February 20, 2009, 10:45:41 pm

Title: 8 bit transparency
Post by: agamemnus on February 20, 2009, 10:45:41 pm
It would be nice if simutrans had 8 bit transparency . . .
Title: Re: 8 bit transparency
Post by: prissi on February 20, 2009, 11:25:32 pm
I has 6 Bit transparency. But the images are in the pak only 15 Bits (555) plus some extra colors. There is not much space for transparency left.

The only thing could be two predefined transparent colors; but this would make drawing slower, since the rendering of transparency is not copying but more difficult. (Only darkening for a shadow might be ok though.)
Title: Re: 8 bit transparency
Post by: agamemnus on February 21, 2009, 01:24:03 am
Hi prissi!

Changing the code to allow 24 bit images would be like wrestling with a giant squid underwater with your hands tied behind your back, I presume?  :(
Title: Re: 8 bit transparency
Post by: Fabio on February 21, 2009, 08:19:16 pm
what about 2 different images for each object view? one colourful, like now and one in greyscale where black is total transparency and white no transparecy at all?
Title: Re: 8 bit transparency
Post by: prissi on February 21, 2009, 08:45:55 pm
Making it 24 Bit (or rather 32 bit) double the amount the processor has to draw every frame. Can be up to about 4 times slower, since then the internal sizes leaves the cache size of some processors.

If you could give a reason, for what should be transparent and which just darkening (i.e. transparent black) ist not good enough, there is a reason we could discuss. So far, we are in the realm of things to do if I finished my evergrowing todo list.
Title: Re: 8 bit transparency
Post by: VS on February 21, 2009, 09:58:25 pm
I tried to find some tests of SDL (which is probably most used backend) speed, and there are almost none. Well...
http://kevinlocke.name/inquiry/sdlblitspeed/sdlblitspeed.php
Quite unsurprisingly sdl transparency almost always sucks mightily :(

It could help all areas, but only for some seems useless. One exception where real transparency could help are smokes. But then again, smokes could rather use more images and controllable animation speed.
Title: Re: 8 bit transparency
Post by: prissi on February 21, 2009, 10:55:19 pm
The transparency is handled by simutrans routines, which are optimized to blit simutrans pictures ... SDL or whatever backend just does the copying onto the screen.
Title: Re: 8 bit transparency
Post by: agamemnus on February 22, 2009, 07:40:26 pm
Why not just use OpenGL? Simutrans is already very good in terms of graphics framerate and memory/CPU usage..
Title: Re: 8 bit transparency
Post by: prissi on February 22, 2009, 10:43:15 pm
Could we please stay on topic: What for 8 Bit transparency would be needed? Just for a shadow?
Title: Re: 8 bit transparency
Post by: agamemnus on February 23, 2009, 12:24:39 am
Sorry, I didn't understand you the first time.

Better transparency and more colors is the reason, I guess. I see a lot of images using dithered transparency to simulate more shades. Doesn't look that great... (well, the dithering in the dust clouds from the trains helps, but not dirthering on building shadows....
Title: Re: 8 bit transparency
Post by: Fabio on February 23, 2009, 09:37:17 am
i would really like/need "coloured" transparecy for gl**** (light blue and/or grey), for such objects as stations, stops, etc...

And i would like a 50-60% transparency for the roofs of tunnels in underground mode (under project).
Finally a 50%transparecy could be a nice visual choice for cursors, as well. (and maybe for a skin for dialogs, i still remember a nice pak from vilvoh (?) posted in the old forum, but there the dithering made the text unreadable.
Title: Re: 8 bit transparency
Post by: prissi on February 23, 2009, 10:44:51 am
50% transparency of cursors is possible even now. Would just require the cursors to be drawn with 50% transparency.

A special color emulation 50% transparency is possible without much h****le (albeit needs to change the inline ****embler, shudder). Actually OpenTTD has also only this, and this is used for windows too.
Title: Re: 8 bit transparency
Post by: Fabio on February 23, 2009, 11:09:33 am
A special color emulation 50% transparency is possible without much h****le

This would be VERY interesting. But if it is 50% transparent, how to select the other 50%? Could it be possible to have a few of them (e.g. 8 greys, 4 blues and 4 browns) to have shades and maybe some dithering?
Title: Re: 8 bit transparency
Post by: Dwachs on February 23, 2009, 12:00:59 pm
the other 50% would be the objects behind the transparent thing ?
Title: Re: 8 bit transparency
Post by: Fabio on February 23, 2009, 12:25:30 pm
NOPE, 50% transparency means 50% of the object behind (transparency) and 50% of an arbitrary colour or texture.
This is the 50% i was asking about. IMHO the best would be to have a few 50% transparent colours (at least black and another 3 greys, one light blue for the gl**** and a few more).
Title: Re: 8 bit transparency
Post by: prissi on February 23, 2009, 01:40:06 pm
This will likely not come, since it will break many existing images; I think maybe three greys. But I am reluctant, as so far NOBODY has given me an example why he needs something like this. Concrete ones, please.
Title: Re: 8 bit transparency
Post by: Fabio on February 23, 2009, 02:11:41 pm
1) station roof (gl****) -> a 50% light grey (or light blue, if possible) would simulate a real gl**** roof, it would look much better than the present time 2*1 dithering transparency/light blue. Also trains would be much more visible below.

2) tunnels. in underground mode, now it is possible to select a way. I plan to make ways for tunnels having the shape of a tunnel. Seeing only 50% would give more realism to the structure of the tunnel
Title: Re: 8 bit transparency
Post by: kierongreen on March 03, 2009, 05:38:43 pm
I'd say stick with existing code. Adding transparencies means more special colours and even if that's one or two it means potentially breaking images. Dithering might not be brilliant but it does allow for any colour to be "transparent" at least.

Something like this really requires a proper graphics engine upgrade - i.e. to 24bit colour 8bit alpha, but as has been said, that means a slowdown.
Title: Re: 8 bit transparency
Post by: gauthier on March 03, 2009, 09:05:22 pm
transparency ... very interesting (in fact I was thinking to that last night :D ).

If it's possible, 4 bit 2 bit transparency would be enough to have good results ...
1) complete opacity
2) 25%
3) 50%
4) 75%

and the complete transparency is given by the current special color (strange light blue :D ).

(If a such extension is made, do it quickly because I'll soon work on my stations again ;D )
Title: Re: 8 bit transparency
Post by: knightly on March 04, 2009, 06:47:03 pm
Pls correct me if I am wrong, Gauthier, but I guess you only need 2 bits to represent your 4 choices of transparency/opacity.  ;)
Title: Re: 8 bit transparency
Post by: gauthier on March 04, 2009, 06:52:13 pm
oops ^^
Title: Re: 8 bit transparency
Post by: gauthier on March 05, 2009, 06:49:02 pm
I have a much better idea but don't know if it's possible :/
Remove the basic night colors and put something other to the transparency picture that would also have night colors but really improved.

For example : a 5 bit picture :
color 1) 100% opacity (white)
2) 95 %
3) 90 %
[...]
20) 5 % (the complete transparency is given by the light blue color on the main picture)
21) non darkening color (the corresponding pixel on the main picture won't get darker with night)
22) 25% darkening only
23) 50%
24) 75%
(all next colors will completely change the color of the main picture to the color of THIS picture)
25) yellow1
26) yellow2
27) yellow3
28) very light grey (near from white)
29) light blue
30) dark blue
31) red
32) green

the different yellows mean some variation of yellow light of windows in night. (... see the main special colors, I'm meaning the daily black colors which get yellow in night).

Is it possible ???