News:

Simutrans Forum Archive
A complete record of the old Simutrans Forum.

8 bit transparency

Started by agamemnus, February 20, 2009, 10:45:41 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

agamemnus

It would be nice if simutrans had 8 bit transparency . . .

prissi

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.)

agamemnus

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?  :(

Fabio

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?

prissi

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.

VS

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.

My projects... Tools for messing with Simutrans graphics. Graphic archive - templates and some other stuff for painters. Development logs for most recent information on what is going on. And of course pak128!

prissi

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.

agamemnus

Why not just use OpenGL? Simutrans is already very good in terms of graphics framerate and memory/CPU usage..

prissi

Could we please stay on topic: What for 8 Bit transparency would be needed? Just for a shadow?

agamemnus

#9
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....

Fabio

i would really like/need "coloured" transparecy for glass (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.

prissi

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 hassle (albeit needs to change the inline assembler, shudder). Actually OpenTTD has also only this, and this is used for windows too.

Fabio

Quote from: prissi on February 23, 2009, 10:44:51 AM
A special color emulation 50% transparency is possible without much hassle

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?

Dwachs

the other 50% would be the objects behind the transparent thing ?
Parsley, sage, rosemary, and maggikraut.

Fabio

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 glass and a few more).

prissi

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.

Fabio

1) station roof (glass) -> a 50% light grey (or light blue, if possible) would simulate a real glass 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

kierongreen

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.

gauthier

#18
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 )

knightly

Pls correct me if I am wrong, Gauthier, but I guess you only need 2 bits to represent your 4 choices of transparency/opacity.  ;)


gauthier

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 ???