News:

The Forum Rules and Guidelines
Our forum has Rules and Guidelines. Please, be kind and read them ;).

Automatic adding of player colours

Started by VS, February 17, 2010, 10:13:04 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

VS

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 [dot] us (site down, do not visit) ]/files/get/Oxqw_T3Xnu/recolorer.7z

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!

The Hood

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

VS

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

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!

Spike

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.

Zeno

Quote from: VS on February 18, 2010, 12:57:04 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).

The Hood

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.

Zeno

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

The Hood

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?

Zeno

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

jamespetts

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.
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

Zeno

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.

Fabio

Quote from: Zeno 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.

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

VS

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.

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!

Zeno

Quote from: fabio on February 24, 2011, 11:29:44 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.

Fabio

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

Zeno

#15
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 :)

The Hood

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.

Zeno

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.

jamespetts

The Hood,

can you upload the Pak128.Britain version of the automatic renderer?
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

Zeno

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.

jamespetts

Thank you for the update! I haven't tried these yet, though - The Hood - did you get my request for PakBritainised versions?
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

The Hood

Zeno, awesome thanks!  Haven't tried it properly yet though.

jamespetts

I've been looking at this - most useful. How does the "make mask" function work?
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

Zeno

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.

jamespetts

Hmm - and may I further ask what is the shadeless check for all primary* and secondary* materials in the 3d model...?
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

The Hood

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

jamespetts

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?
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

The Hood


Zeno

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

jamespetts

The link to the image processor is broken :-(
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

Zeno

Sorry for the inconvenience, now it's available to download again. No version changed, remains to v1.5.

jamespetts

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?
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.