The International Simutrans Forum

 

Author Topic: Automatic adding of player colours  (Read 14961 times)

0 Members and 1 Guest are viewing this topic.

Offline VS

  • Senior Plumber (Devotee)
  • Devotee
  • *
  • Posts: 4855
  • Vladimír Slávik
    • VS's Simutrans site
  • Languages: CS,EN
Automatic adding of player colours
« on: February 17, 2010, 10:13:04 PM »
Still working on this, but here is a preview of possible tool. It will process png files given as parameters and recolorize according to options.cfg in same folder as image.

http://files.simutrans.us/files/get/Oxqw_T3Xnu/recolorer.7z

Offline The Hood

  • Devotee
  • *
  • Posts: 2889
  • pak128.Britain developer
Re: Automatic adding of player colours
« Reply #1 on: February 18, 2010, 08:34:07 AM »
Sounds interesting.  Have I understood this tool correctly, i.e. could be used as follows?

1) render image in, say, black and pink
2) use tool to convert pink to player colour, black stays the same?

And does this work for 2 player colours?

This may solve the long-standing request for pak128.Britain vehicles in player colours without too much fuss...

Offline VS

  • Senior Plumber (Devotee)
  • Devotee
  • *
  • Posts: 4855
  • Vladimír Slávik
    • VS's Simutrans site
  • Languages: CS,EN
Re: Automatic adding of player colours
« Reply #2 on: February 18, 2010, 12:57:04 PM »
Currently it works like this:

For every pixel,
    store current colour as best result but with high metric
    for every candidate colour,
        find metric
        and if metric is bettter than best result,
            store this result as best
    finally, replace original colour with the best result


metric is Euclidian distance in rgb space



Zeno has worked out a better (more automatic) workflow for Blender, so you might want to give that a test instead. It's based on taking the normal render (w. OSA) and masking with non-osa & shadeless render...

Offline Spike

  • *
  • Posts: 1361
  • First Simutrans Developer and Graphics Artist
Re: Automatic adding of player colours
« Reply #3 on: February 18, 2010, 01:10:53 PM »
I found that sqrt(r*r*2 + g*g*3 + b*b) often is closer to what human eye sees as "similar" colors than unbiased euclidean distance in rgb space.

Offline Zeno

  • ENASSA Designer
  • Devotee
  • *
  • Posts: 1997
    • Zeno's Simutrans Creations
  • Languages: ES, EN, CAT
Re: Automatic adding of player colours
« Reply #4 on: February 18, 2010, 04:03:20 PM »
Zeno has worked out a better (more automatic) workflow for Blender, so you might want to give that a test instead. It's based on taking the normal render (w. OSA) and masking with non-osa & shadeless render...
Actually I have a small app that is strictly based in my working workflow, thus is only applicable to that way of working and it hasn't any flexibility at the moment.
As VS explains, this way of doing things is based on mask and osa renders. If anyone wants more info on it contact me via PM or the IRC chat (or just post here).

Offline The Hood

  • Devotee
  • *
  • Posts: 2889
  • pak128.Britain developer
Re: Automatic adding of player colours
« Reply #5 on: February 23, 2011, 09:43:36 PM »
MASSIVE dig, but I'd like to find out more about your process Zeno - multiplayer has made it time that pak128.Britain has some more player colour, at least on depots and stations, but I'd like to automate it if possible.

Offline Zeno

  • ENASSA Designer
  • Devotee
  • *
  • Posts: 1997
    • Zeno's Simutrans Creations
  • Languages: ES, EN, CAT
Re: Automatic adding of player colours
« Reply #6 on: February 23, 2011, 09:49:38 PM »
You may take a look here: http://www.youtube.com/watch?v=B03BNw46-ng
In that video you can see the whole process starting with a blender model and using my blender script, my processor tool and shades. The shame is the comments are in spanish, and I hadn't yet enough time to make an english version :(

Offline The Hood

  • Devotee
  • *
  • Posts: 2889
  • pak128.Britain developer
Re: Automatic adding of player colours
« Reply #7 on: February 23, 2011, 10:37:00 PM »
Awesome - I really like the look of that (not sure I got all the spanish but I reckon I can figure it out).  Could you send me the blender model, script and post-processor so I can have a play?

Offline Zeno

  • ENASSA Designer
  • Devotee
  • *
  • Posts: 1997
    • Zeno's Simutrans Creations
  • Languages: ES, EN, CAT
Re: Automatic adding of player colours
« Reply #8 on: February 24, 2011, 07:09:24 AM »
Sure. I'll make a package for you when I'm back home later this afternoon.

You might also be interested in this dat file editor: http://sourceforge.net/projects/st-mass-dat/
It's in prealpha status, so there hasn't been any advertising for it, but you may find it useful as it allows to read multiple dat files in a folder and edit them all at the same time in a calc-sheet style layout, then save all them. It lacks a proper manual and it does not make any data validation, but if you type valid data in it works fine :)

Offline jamespetts gb

  • Simutrans-Extended project coordinator
  • Devotee
  • *
  • Posts: 18377
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Automatic adding of player colours
« Reply #9 on: February 24, 2011, 09:06:46 AM »
That's a very useful tool! Currently, I use MSVC++ for .dat file editing along with coding, but this seems to have some advantages. Data verification would indeed be a good addition, as would the ability to search (and replace) and sort by different columns.

Edit: One bug that I have noticed, however, is that it does not correctly handle .dat files which specify more than one object, as is common in Pak128.Britain and legal as far as Makeobj is concerned: in those cases, it shows only the last object specified in the .dat file.

Offline Zeno

  • ENASSA Designer
  • Devotee
  • *
  • Posts: 1997
    • Zeno's Simutrans Creations
  • Languages: ES, EN, CAT
Re: Automatic adding of player colours
« Reply #10 on: February 24, 2011, 10:14:43 AM »
You're right, it has only support for single-object dat files as they are "mandatory" in pak128 standard.
I'll take a look at the code and see if there is a way of allowing multi-object dats changing as few things as possible.
Data verification has the good part (prevent user error) and the bad one (on any new engine, way, etc., must change code). The bad one can be overtaken by config/tab files, but you're making things more and more complex with each step, so I'm not sure on how to proceed.

Offline Fabio

  • Devotee
  • Administrator
  • *
  • Posts: 2898
  • The Pak128 Guy
    • Visit me on Facebook
  • Languages: EN, IT, RO, FR
Re: Automatic adding of player colours
« Reply #11 on: February 24, 2011, 11:29:44 AM »
You're right, it has only support for single-object dat files as they are "mandatory" in pak128 standard.

This I didn't know and I'm ruined as my Roads project has all DATs in a single file of many, many lines... :(

Offline VS

  • Senior Plumber (Devotee)
  • Devotee
  • *
  • Posts: 4855
  • Vladimír Slávik
    • VS's Simutrans site
  • Languages: CS,EN
Re: Automatic adding of player colours
« Reply #12 on: February 24, 2011, 11:41:43 AM »
This is mostly for items that come in tens. When you want to find some item, you find a file with that name. But in the long run it would be better to have most items broken up like this...

Splitting can be done automatically with a script, so no worries.

Offline Zeno

  • ENASSA Designer
  • Devotee
  • *
  • Posts: 1997
    • Zeno's Simutrans Creations
  • Languages: ES, EN, CAT
Re: Automatic adding of player colours
« Reply #13 on: February 24, 2011, 11:43:39 AM »
This I didn't know and I'm ruined as my Roads project has all DATs in a single file of many, many lines... :(
Moreover I used "mandatory" between quotes to indicate that it's not really true, but we feel more comfortable with single object files. As VS says, don't worry, there's a script to automatically split in different files :)

Edit: of course, this applies mostly to vehicles, curiosity buildings, factories..., which are usually items that you would search by its name; for special items it isn't always the best way.

Offline Fabio

  • Devotee
  • Administrator
  • *
  • Posts: 2898
  • The Pak128 Guy
    • Visit me on Facebook
  • Languages: EN, IT, RO, FR
Re: Automatic adding of player colours
« Reply #14 on: February 24, 2011, 11:59:12 AM »
And also a single, huge, PNG...
Anyway, I'll release it like this, after that if changes are needed... we will see.
This format is the most convenient for my Gimp painting...

Offline Zeno

  • ENASSA Designer
  • Devotee
  • *
  • Posts: 1997
    • Zeno's Simutrans Creations
  • Languages: ES, EN, CAT
Re: Automatic adding of player colours
« Reply #15 on: February 24, 2011, 02:13:05 PM »
No problem, work the way you feel more comfortable, of course!
If later on there's need of using scissors and glue because of the pak "good practices", you don't have to worry now. We'll deal with that at the proper time :)

Files:
Image processor installer
Blender template and script. These are for Blender 2.56.

The template is a very simple template that contains the camera and one source of light, which are needed for the script to work.
To install the addon script, go to "user preferences -> addons -> install addon".
For more details ask here or at the Simutrans IRC chat room ;)

Edit: Replaced the Image processor tool link - now available version 1.5 :)
« Last Edit: October 08, 2011, 08:23:18 AM by Zeno »

Offline The Hood

  • Devotee
  • *
  • Posts: 2889
  • pak128.Britain developer
Re: Automatic adding of player colours
« Reply #16 on: February 26, 2011, 12:02:39 PM »
These are definitely very neat, thanks!  The main problem I'm having though is that either:
1) Once I've converted to player colours the image is very "flat" in the player colour section and seems to lose detail unless it's on a curved surface (which comes up nicely)
2) There are some stray colours similar to the player colour but not "special" which do not get processed (e.g. where grills are supposed to be), and then look odd when player colour other than default blue is applied.

I'm beginning to wonder whether full-on player colour for pak128.Britain is too much.  I will try and do stations and depots though.  At any rate, the auto-render is very helpful - I've now adapted it to my own version which works better with the pak128.Britain render set-up.

Offline Zeno

  • ENASSA Designer
  • Devotee
  • *
  • Posts: 1997
    • Zeno's Simutrans Creations
  • Languages: ES, EN, CAT
Re: Automatic adding of player colours
« Reply #17 on: February 26, 2011, 12:12:55 PM »
I'm happy you found it worthy. About your comments:
1) Well, player color is an eight flat color pallete... you can't do much with that. Anyway, I will try to add Hajo's color proximity calculation and allow the user to select the algorithm in the processor tool; results may improve with that, but I don't expect it to be superb as the 8 color limit is still there. This is exactly what I meant when I talked about applying player color to big surfaces; small strays give better results.
2) Obviously, inside the game only those colors matching the special pallette will change. If you use similar colors but not exact you will find that issue on your objects. I use to paint my objects with different special colors (e.g. the 3rd and 8th of the blender template pallete) which give as result light/dark strays which change with the player color.

Offline jamespetts gb

  • Simutrans-Extended project coordinator
  • Devotee
  • *
  • Posts: 18377
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Automatic adding of player colours
« Reply #18 on: February 26, 2011, 10:09:37 PM »
The Hood,

can you upload the Pak128.Britain version of the automatic renderer?

Offline Zeno

  • ENASSA Designer
  • Devotee
  • *
  • Posts: 1997
    • Zeno's Simutrans Creations
  • Languages: ES, EN, CAT
Re: Automatic adding of player colours
« Reply #19 on: March 02, 2011, 08:28:50 PM »
Got new version of the image processor: now supports customizable back color for images/masks, requested by The Hood :)
The links got updated four messages above.

Offline jamespetts gb

  • Simutrans-Extended project coordinator
  • Devotee
  • *
  • Posts: 18377
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Automatic adding of player colours
« Reply #20 on: March 02, 2011, 11:09:07 PM »
Thank you for the update! I haven't tried these yet, though - The Hood - did you get my request for PakBritainised versions?

Offline The Hood

  • Devotee
  • *
  • Posts: 2889
  • pak128.Britain developer
Re: Automatic adding of player colours
« Reply #21 on: March 03, 2011, 05:08:38 PM »
Zeno, awesome thanks!  Haven't tried it properly yet though.

Offline jamespetts gb

  • Simutrans-Extended project coordinator
  • Devotee
  • *
  • Posts: 18377
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Automatic adding of player colours
« Reply #22 on: March 03, 2011, 11:55:20 PM »
I've been looking at this - most useful. How does the "make mask" function work?

Offline Zeno

  • ENASSA Designer
  • Devotee
  • *
  • Posts: 1997
    • Zeno's Simutrans Creations
  • Languages: ES, EN, CAT
Re: Automatic adding of player colours
« Reply #23 on: March 04, 2011, 10:14:14 AM »
I guess you talk about the blender script. The "make mask" button only activates the "shadeless" check for all "primary*", "secondary*" materials in the 3D model. It also replaces the dark_windows_2 material with the ugly magenta shadeless material, which will be used to auto-paint windows in the processor tool.

Offline jamespetts gb

  • Simutrans-Extended project coordinator
  • Devotee
  • *
  • Posts: 18377
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Automatic adding of player colours
« Reply #24 on: March 04, 2011, 10:42:52 AM »
Hmm - and may I further ask what is the shadeless check for all primary* and secondary* materials in the 3d model...?

Offline The Hood

  • Devotee
  • *
  • Posts: 2889
  • pak128.Britain developer
Re: Automatic adding of player colours
« Reply #25 on: March 04, 2011, 10:51:30 AM »
If you use those colours, they are player colours.  The shadeless property means that blender light won't render them with shadows- you just get a a mass of that colour.  If you do this without anti-aliasing you can get a "map" of where player colours are on the render and therefore which pixels on the anti-aliased image need to be converted (with Zeno's tool) to the closest player colour (to take account of the shadow).

Offline jamespetts gb

  • Simutrans-Extended project coordinator
  • Devotee
  • *
  • Posts: 18377
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Automatic adding of player colours
« Reply #26 on: March 04, 2011, 11:14:59 AM »
Ahh, I see - I think! Are the colours in that one has to specify Blender to get this result exactly the same as the player colours in the .png files?

Offline The Hood

  • Devotee
  • *
  • Posts: 2889
  • pak128.Britain developer
Re: Automatic adding of player colours
« Reply #27 on: March 04, 2011, 12:57:53 PM »
yes

Offline Zeno

  • ENASSA Designer
  • Devotee
  • *
  • Posts: 1997
    • Zeno's Simutrans Creations
  • Languages: ES, EN, CAT
Re: Automatic adding of player colours
« Reply #28 on: April 18, 2011, 05:25:58 PM »
I've modified the script to allow it working for Blender 2.57 version. There are also some minor changes affecting to the masking functionality. Details can be found inside the script file (see comments, etc.).

Offline jamespetts gb

  • Simutrans-Extended project coordinator
  • Devotee
  • *
  • Posts: 18377
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Automatic adding of player colours
« Reply #29 on: October 02, 2011, 11:33:50 PM »
The link to the image processor is broken :-(

Offline Zeno

  • ENASSA Designer
  • Devotee
  • *
  • Posts: 1997
    • Zeno's Simutrans Creations
  • Languages: ES, EN, CAT
Re: Automatic adding of player colours
« Reply #30 on: October 08, 2011, 08:24:26 AM »
Sorry for the inconvenience, now it's available to download again. No version changed, remains to v1.5.

Offline jamespetts gb

  • Simutrans-Extended project coordinator
  • Devotee
  • *
  • Posts: 18377
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Automatic adding of player colours
« Reply #31 on: October 09, 2011, 08:22:44 PM »
Thank you for uploading that - that is most helpful!

May I ask - how ought one adapt this workflow to work with road vehicles, which have a different alignment to other sorts of vehicles?