Made a 32bpp patch - need help

Forum for technical discussions regarding development. If you have a general suggestion, problem or comment, please use one of the other forums.

Moderator: OpenTTD Developers

Post Reply
boekabart
Transport Coordinator
Transport Coordinator
Posts: 333
Joined: 25 Aug 2005 09:44
Location: Eindhoven, Netherlands

Made a 32bpp patch - need help

Post by boekabart »

I made a 32bpp patch, just to be able to use 32bpp to create effects, not to support new graphics. (I'll leave that to the devs...)

But I need some help on the gfx engine, and mainly on the thing with the ctab's / color tables. What are they exactly used for.

Because I don't know, I cannot replace them with a 32bpp variant, and have to to something like:

dst = i2p(ctab[p2i(dst)])

where
* dst is the 32bpp screen pixel (PIXEL32)
* i2p converts INDEXEDCOLOR to PIXEL32
* p2i converts PIXEL32 to INDEXEDCOLOR (using the initial palette)
This last function is either slow (too slow) or uses 16 mb of memory and is not very accurate, so I want to replace the ctab functionality with a function, basically. I suppose so far it has something to do with shadows, but I can't really get the real meaning and of all uses. (smth about 3 blit modes?)

If anyone who has useful info on this, let me know.

Thread about the patch: Here
Image
User avatar
prissi
Chief Executive
Chief Executive
Posts: 647
Joined: 15 Nov 2004 19:46
Location: Berlin, Germany
Contact:

Post by prissi »

If you want to convert pixel back from 24 Bit to 8 Bit I suggest using hashes. Or Use 16 bit, then the tables do not get too large. Or use the upper 8 Bit transparency values (which you can set to ignore) to store the palette value, ... Many possibilities there.

(I would like to see this patch with the nightfall patch, so we could have a non-darkening interface with 32 Bit.)
boekabart
Transport Coordinator
Transport Coordinator
Posts: 333
Joined: 25 Aug 2005 09:44
Location: Eindhoven, Netherlands

Post by boekabart »

prissi wrote:If you want to convert pixel back from 24 Bit to 8 Bit I suggest using hashes. Or Use 16 bit, then the tables do not get too large. Or use the upper 8 Bit transparency values (which you can set to ignore) to store the palette value, ... Many possibilities there.
No longer an issue, I don't need the color2index lookup anymore at all: The only thing I had to assume for this is that when we do a colormapping on a actual screen pixel, it's meant to 'shadow' that pixel. And we don't need a lookup for that in 32bpp now do we?
prissi wrote:(I would like to see this patch with the nightfall patch, so we could have a non-darkening interface with 32 Bit.)
Good idea, where can I find the patch? Or should I add this myself?
User avatar
prissi
Chief Executive
Chief Executive
Posts: 647
Joined: 15 Nov 2004 19:46
Location: Berlin, Germany
Contact:

Post by prissi »

I made this one, though did not work on it for some time (but work against some 4.0.0.1 later nightly). Since you seem to use a different palette for the UI than for the rest, maybe excluding the UI would be easy.

http://www.tt-forums.net/viewtopic.php? ... c&start=38 Ask me, if you have any questions.
boekabart
Transport Coordinator
Transport Coordinator
Posts: 333
Joined: 25 Aug 2005 09:44
Location: Eindhoven, Netherlands

Post by boekabart »

Well the only thing necesarry is to know in the graphics routines if the object being drawn is part of the world, or part of the UI. At this point I have no idea how to figure that out, I need to look into the games main loop / draw loop I guess. I figure it shouldn't be hard: probably the game draws FIRST the world THEN the UI. Right? So in between there, I should be able to put a switch. Right? Something global or so.

I took a look at that patch, but it seems to be very old no? What was the approach, changing the palette?
With this patch, we could just go for a 'multiplier' color with which everything in the world (not the UI) is multiplied, blit-time. Disadvantage is that once you change this multiplier, you have to redraw the whole screen. I tried the palette scroll this way for 32bpp, but especially when zoomed out, not a good idea. Of course, this change is only once per...? Or do you want it constantly, synced with the OTTD time? (I guess would be kind of annoying. Season would be OK i guess).
I'll try to take a look at it tomorrow.
boekabart
Transport Coordinator
Transport Coordinator
Posts: 333
Joined: 25 Aug 2005 09:44
Location: Eindhoven, Netherlands

v0.3 + diff

Post by boekabart »

Last one for today, is stable and without artifacts. Actually very usable, I think.

I call it v0.3, the exe you can find HERE

Fullscreen mode works, but by default it creates a 8bpp fullscreen-window with a automatic palette, which looks bad. To use fullscreen, change the following in your cfg file:

Code: Select all

[win32]
fullscreen_bpp = 32
The remaining bugs:
* Something with scrolling isn't right, artefacts. (Though may be solved in v0.3)
* Since it uses filtering (4x, 16x) for the zoomed out modes, these are quite a bit slower now. Especially the initial switch to them. But they look awesome.
* Palette scrolls no longer works. No idea how I'm going to do that one... Disabled hardcoded in 32bpp mode now, to remove artefacts
* Startup of the 8 bit version takes a bit longer since it has to init a 16mb color32 to palette conversion table. This only with super_zoom enabled.
* Only Win32!!!! Did not look at SDL code yet. v0.4?

And finally, a diff attached. Hope it works for all of you!
Attachments
32bpp_Gradient_SuperZoom_for_r2905_v0.3.diff
(41.1 KiB) Downloaded 91 times
boekabart
Transport Coordinator
Transport Coordinator
Posts: 333
Joined: 25 Aug 2005 09:44
Location: Eindhoven, Netherlands

Post by boekabart »

Did the colorizing thing, don't mind too much about the color for each month, I just made something up.
It allows overscaling (clipping). In fact it does a (col*multi)>>8 and caps that to 0xff. Scaling can be different per color.
There is a patch setting to enable season coloring, and a define which removes the whole support for coloring (for the speedfreaks)
Colorizing also supported for 8bpp mode, although a bit less accurate of course, but it does not affect the interface as was requested.
V0.4 exes (32bpp and 8bpp) can be found here.
Nighty night.
Attachments
32bpp_Gradient_SuperZoom_Seasons_for_r2905_v0.4.diff
(46.32 KiB) Downloaded 99 times
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 15 guests