NewGFX company colour overlays (and shadows)

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

Alltaken
Tycoon
Tycoon
Posts: 1285
Joined: 03 Dec 2003 06:24
Location: Christchurch, New Zealand
Contact:

NewGFX company colour overlays (and shadows)

Post by Alltaken »

Hi guys, i am working down my todo list for things to complete these holidays. and one of the todo's is to finish defining all the important elements of the NewGFX format. so that coders, and artists can feel comfortable in continuing without my input. and without having to get hung up on problems.

-----disclaimer don't judge the lighting or visual quality of the vehicle it is mearly a test of colours it does not poses the feel the GFX in the game will have.------

here are some images for the vehicles. basicly an example of how 'I' envision the shadows, company colours, and base vehicle sprites working.

Base GFX - RGBA - (any company colour area is set to a white material, dirt and other things which would alter a company colour can be applied to this material, and it will be visable after company colour is applied)
Image

Shadow - RGBA - ( the shadow intensity can be controlled within the game, it could be made so that a mouse hover over a vehicle flips the shadow to white, to show that you will click on it. the sprite below the shadow is filtered through its alpha channel)
Image

Company Colour - RGB - (the company colour has 3 colours, R, G, B, which are treated as 3 greyscale images by the game. these channels can then have Hue, saturation, and lightness applied to them to achieve any of 16 million possible company colours. so up to 16^3 colour combos depending on the company colour choosing interface)
Image

quick photoshop version of this in practice. (just photoshoped, but the game would be able to do it on the fly i would hope)
Image



my request is that a coder (possibly mek) is able to code something into OTTD 32bpp suport which can handle an RGB PNG as a company colour overlay.

the colours were "multiplied" (in photoshop) over the base sprite in order to achieve the shaded final view.

the Red channel is company colour No 1
Green channel is CC No 2
Blue channel is CC No 3

thanks people.

uploaded .zip files of the base sprites and the CC sprites are as follows.
http://ottd.mudpuddle.co.nz/testfiles/col.zip
http://ottd.mudpuddle.co.nz/testfiles/base.zip

Alltaken
User avatar
bobingabout
Tycoon
Tycoon
Posts: 1850
Joined: 21 May 2005 15:10
Location: Hull, England

Post by bobingabout »

looking good. kinda looks something like my idea
JPG SUX!!! USE PNG!!!
There are times when JPG is useful, TTD screenshots is not one of them. Please use PNG instead.

[/url]
User avatar
mkxx
Engineer
Engineer
Posts: 65
Joined: 06 Jun 2005 22:15
Location: Czech Republic, Prague

Post by mkxx »

It looks like good idea! Good.
oboka
Engineer
Engineer
Posts: 91
Joined: 05 Jul 2004 09:13
Location: Barcelona

Post by oboka »

Won't it be too much sprites to draw and to download?

Anyway, if it is possible its a great idea.

I could write a little program to test your idea.
Alltaken
Tycoon
Tycoon
Posts: 1285
Joined: 03 Dec 2003 06:24
Location: Christchurch, New Zealand
Contact:

Post by Alltaken »

oboka wrote: I could write a little program to test your idea.
that would be excellent. :D
Won't it be too much sprites to draw and to download?
define to much. ;)
looking good. kinda looks something like my idea
yeah thats why i said i already had it sorted ;)

Alltaken
User avatar
bobingabout
Tycoon
Tycoon
Posts: 1850
Joined: 21 May 2005 15:10
Location: Hull, England

Post by bobingabout »

are you the 1 who would be writing the new 32 bit graphics engine?
JPG SUX!!! USE PNG!!!
There are times when JPG is useful, TTD screenshots is not one of them. Please use PNG instead.

[/url]
Mek
TTDPatch Developer
TTDPatch Developer
Posts: 417
Joined: 13 Apr 2004 13:35
Location: Eindhoven, Netherlands
Contact:

Post by Mek »

bobingabout wrote:are you the 1 who would be writing the new 32 bit graphics engine?
no.. that would most likely be me. basic 32 bit support is working, now i'm trying to add sprite-recolour support, and the above mentioned company colour system.
User avatar
bobingabout
Tycoon
Tycoon
Posts: 1850
Joined: 21 May 2005 15:10
Location: Hull, England

Post by bobingabout »

32 bit suport is working eh? would that allow the day/night cylces patch to have 2 palletes? 1 for GUI, other for the other things?
JPG SUX!!! USE PNG!!!
There are times when JPG is useful, TTD screenshots is not one of them. Please use PNG instead.

[/url]
User avatar
mkxx
Engineer
Engineer
Posts: 65
Joined: 06 Jun 2005 22:15
Location: Czech Republic, Prague

Post by mkxx »

bobingabout wrote:would that allow the day/night cylces patch to have 2 palletes?
Now - system supports 256colors - that's 8bits. So we need a palette for it. AFTER system will support 32bits-colors - that's about 16millions color and transparency - we will not need to have pallettes. We will be able to use every color we want ;)
User avatar
SkeedR
Tycoon
Tycoon
Posts: 2267
Joined: 11 Jul 2004 14:55
Location: West Midlands
Contact:

Post by SkeedR »

:shock: O_O :shock:
Wow, that is good.

EDIT by Owen: Turned all the table-breaking rubbish into proper English. Please don't do that again.
Last known as: Weirdy
Seven Force
Engineer
Engineer
Posts: 84
Joined: 22 May 2005 09:45
Location: United Kingdom

Post by Seven Force »

weirdy, you're table-breaking. Either remove it or put some line breaks in there.
Last edited by Seven Force on 23 Jun 2005 17:43, edited 1 time in total.
User avatar
Sellu
Engineer
Engineer
Posts: 98
Joined: 24 Sep 2004 20:06

Post by Sellu »

I have to give a try to that too;)
Image
The power that I trust.
Alltaken
Tycoon
Tycoon
Posts: 1285
Joined: 03 Dec 2003 06:24
Location: Christchurch, New Zealand
Contact:

Post by Alltaken »

Sellu if you want to test it on some of your vehicles, i would love to see the result.

just keep in mind that R,G,B are important in that order. so assign the colours from largest area to smallest in that order.

i would also love to see some dirtyish vehicles done like this, to see how dirt and grime reacts to the company colours being overlayed over the top.

Alltaken
Mek
TTDPatch Developer
TTDPatch Developer
Posts: 417
Joined: 13 Apr 2004 13:35
Location: Eindhoven, Netherlands
Contact:

Post by Mek »

This is how it'll currently look like in my implementation (wich is cheating in quite a number of places, i just can't seem te find the correct formula, can somebody perhaps give me a simple formula that given the Red components of the three company colours (RC1, RC2, RC3), the RGB values of the company colour overlay sprite (CR, CG, CB) and the Red value of the base sprite (RB) returns the Red component for the pixel that should be drawn? :))
Attachments
CColour4.png
CColour4.png (438.97 KiB) Viewed 5868 times
Alltaken
Tycoon
Tycoon
Posts: 1285
Joined: 03 Dec 2003 06:24
Location: Christchurch, New Zealand
Contact:

Post by Alltaken »

(User selected company colour/255)*Red channel of the CC overlay (multiply all channels by the red channel value)

then with that number Multiply it with the base sprite colours (channel for channel, don't mix the channels anymore)

then divide all channels by 255.

this should be the final outcome.

if the CC overlay is somthing with mixtures of two colours i.e. red and green. then you will need to do the calculations for both, and then "mix" the results. so add them then divide by 2.

Multiply
Well, I didn't really understand how this worked, so I'll fill in Quartic's elegant explanation along with my own commentary:

From: Federico Mena Quintero
Reply to: quartic@polloux.fciencias.unam.mx


Multiply - Multiplies the pixels of one image by the pixels of the
other one. If the pixels were in the real range [0, 1], it could be
viewed as

for (every pixel)
dest_pixel = source1_pixel * source2_pixel;

And this would also produce values in the range [0, 1]. However, our
integer values are in [0, 255], so the actual formula used is

dest_pixel = source1_pixel * source2_pixel / 255;

This is to 'bring back' the values to [0, 255]. Note that multiplying
an image by another one always darkens the result. This is because a
number in the range [0, 1] multiplied by another number in the same
range will always be smaller than or equal to either of them.

Basically, this treats both images as being of "unit brightness" (I think that's the right term), in other words, with a maximum brightness of one and a minimum brightness of zero. It then multiplies the unit brightness of each image together. Since multiplying anything less than 1 by something else always results in a smaller value, the image always gets darker.
DaleStan
TTDPatch Developer
TTDPatch Developer
Posts: 10285
Joined: 18 Feb 2004 03:06
Contact:

Post by DaleStan »

OT: I like that grass. You might yet convince me that 32bbp is a good thing. The shadows need to be lightened, though. (Translation: gruff compliment for a feature I'm not yet convinced is desirable.)

If you scale each to [0,1] and then do min(RC1*CR+RC2*CG+RC3*CB,1)*RB; what happens? Obviously, it would be perfectly possible to overflow the color range without the min, but if you do (RC1*CR+RC2*CG+RC3*CB)*RB/3 instead, then I fear a major lack of contrast.

Averaging the HSV coordinates (instead of the min call) would probably also work, and might well be better than RGB-multiply-and-add. RGB averaging would not work; if first two company colors are FFFFFF and 010101, and the overlay is #FFFF00, the result should obviously be 808080, but if the colors are FF0101 and 01FF01 do we really want a result of 808001? Averaging the HSV coordinates returns FEFE01 instead, which is a more desireable result. (at least IMO) (I was actually hoping to get FFFF01. Better accuracy in the HSV conversions might return that color, but the idea remains the same.)
To get a good answer, ask a Smart Question. Similarly, if you want a bug fixed, write a Useful Bug Report. No TTDPatch crashlog? Then follow directions.
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser
Alltaken
Tycoon
Tycoon
Posts: 1285
Joined: 03 Dec 2003 06:24
Location: Christchurch, New Zealand
Contact:

Post by Alltaken »

dalestan, actually i would probably think the yuck brown is more accurate than the yellow when mixing red and green :P (i use paint, os thats what i expect)

but averaging the HSV stuff would make a lot more sense i think.

Alltaken
User avatar
Hackykid
Traffic Manager
Traffic Manager
Posts: 157
Joined: 22 Nov 2004 16:04
Location: Eindhoven de Gekste!!! (ongeveer ;P)
Contact:

Post by Hackykid »

Hmm, i dont know much about this stuff, but this is what would seem most logical to me:

min(1, (RC1*CR) + (RC2*CG) + (RC3*CB) + (RB * max(0,1-CR-CG-CB)) )

this way you can just set percentages for each of the company color, and the percentage that is left (1-CR-CG-CB) gets used for the original color.

PS. i have no idea if this will work out, how it will look, or any of that stuff, this is just what seems most "logical" to me, from a math pov. Still might be an idea to try out.
DopeFish Lives!!!
Mek
TTDPatch Developer
TTDPatch Developer
Posts: 417
Joined: 13 Apr 2004 13:35
Location: Eindhoven, Netherlands
Contact:

Post by Mek »

Hackykid wrote:min(1, (RC1*CR) + (RC2*CG) + (RC3*CB) + (RB * max(0,1-CR-CG-CB)) )
With this formula if either of CR, CG and CB is 255 none of the orriginal sprite is used.... so shadows/dirt will no longer be visible i think... (and i think some more problems which i can't think of right now will also occur...)
dmh_mac
Transport Coordinator
Transport Coordinator
Posts: 278
Joined: 25 Apr 2005 18:18

Post by dmh_mac »

Perhaps this can be of some help...

http://www.pegtop.net/delphi/blendmodes/

Probably not though :oops:
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 29 guests