The International Simutrans Forum

 

Author Topic: Player Color in Blender 2.68  (Read 726 times)

0 Members and 1 Guest are viewing this topic.

Offline TheRoadmaster1996

  • *
  • Posts: 221
  • Languages: EN, some ES
Player Color in Blender 2.68
« on: July 19, 2020, 01:24:22 AM »
Hello. While working on a vehicle on Blender, I wanted to put in player color. But when it comes back as an image, the coloring is off and the player color won't work. Does anybody have any suggestions on how to make it work?

Offline Freahk

  • Devotee
  • *
  • Posts: 1253
  • Languages: DE, EN
Re: Player Color in Blender 2.68
« Reply #1 on: July 19, 2020, 07:51:01 AM »
That's how rendering works! Colors won't remain the same due to reflections and shadows.

You will have to post-process those in gimp or whatever tool you use.

Offline jamespetts

  • Simutrans-Extended project coordinator
  • Moderator
  • *
  • Posts: 20194
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Player Color in Blender 2.68
« Reply #2 on: July 19, 2020, 10:26:31 AM »
I did look into trying to set up  player colours in Blender some time ago. Unfortunately, there is no practical way to achieve this. At a fundamental level, the player colour system in Simutrans and rendered graphics are irredeemably incompatible. The only way around this would be to modify the code either to replace or supplement the player colour system with a player livery system, in which different player colours are mapped to different livery names (with the livery system possibly extended to other objects than vehicles), and all the objects being rendered multiple times with different colours in Blender with different colour names that would then automatically be mapped to the chosen player colour when selected. This would be a substantial amount of work to code, however, and an unfeasible amount of work for existing paksets. It would still be less difficult than trying to get player colour output in Blender.

Online prissi

  • Developer
  • Administrator
  • *
  • Posts: 10131
  • Languages: De,EN,JP
Re: Player Color in Blender 2.68
« Reply #3 on: July 19, 2020, 01:16:38 PM »
Well, with transparency one could get more shades of player color. However, one would need to write a program to covert colors with a certain hue to player color plus alpha coded gray scales.

Offline TheRoadmaster1996

  • *
  • Posts: 221
  • Languages: EN, some ES
Re: Player Color in Blender 2.68
« Reply #4 on: July 19, 2020, 02:48:04 PM »
Alright. Thank you everyone.

Offline Freahk

  • Devotee
  • *
  • Posts: 1253
  • Languages: DE, EN
Re: Player Color in Blender 2.68
« Reply #5 on: July 19, 2020, 02:50:42 PM »
Well, with transparency one could get more shades of player color
Could you elaborate?
Is the alpha channel on special colors interpreted in a special way, which is shades of the special color rather than transparency or how does this work?
How would these shaded playercolors work with models rendered to rgba pngs?

I'd really be interessted in an automated workflow involving special colors, not only player colors but also light/night colors, but I am not sure how this would work.

Offline TheRoadmaster1996

  • *
  • Posts: 221
  • Languages: EN, some ES
Re: Player Color in Blender 2.68
« Reply #6 on: July 19, 2020, 02:57:55 PM »
So what if I change the player color to match the shading? Make it darker with shading if that makes sense. Will that work?

Offline jamespetts

  • Simutrans-Extended project coordinator
  • Moderator
  • *
  • Posts: 20194
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Player Color in Blender 2.68
« Reply #7 on: July 19, 2020, 03:08:03 PM »
So what if I change the player color to match the shading? Make it darker with shading if that makes sense. Will that work?

I am not sure that I do understand, I am afraid; one cannot change the player colours as these are hard coded.

Offline TheRoadmaster1996

  • *
  • Posts: 221
  • Languages: EN, some ES
Re: Player Color in Blender 2.68
« Reply #8 on: July 19, 2020, 03:59:37 PM »
What I mean is make the color darker to match the shading. There are cheat sheets out there with the different player colors. If at first it's a lighter color, can I make it darker to match the shading?

Offline Ranran

  • Devotee
  • *
  • Posts: 1151
  • Languages: ja
Re: Player Color in Blender 2.68
« Reply #9 on: July 19, 2020, 04:00:13 PM »
The reason that the player color does not match the three-dimensional object is that the darkening rate varies depending on the color.
For example, if you mix the standard color or black by 10% each time, the ratio of change will be the same regardless of which player color is selected, so I think it will fit.
So a 50% darker color is only 50% darker, whether white, red or yellow.
However, after all, it is necessary to paint the special color by hand at the end. I think that it is unavoidable because simutrans is not completely 3D.

Offline TheRoadmaster1996

  • *
  • Posts: 221
  • Languages: EN, some ES
Re: Player Color in Blender 2.68
« Reply #10 on: July 19, 2020, 04:02:32 PM »
Thank you! That's what I was trying to ask. Besides, just knowing where it is and the shading could help when I paint the player color on later

Offline ceeac

  • Devotee
  • *
  • Posts: 178
Re: Player Color in Blender 2.68
« Reply #11 on: July 19, 2020, 05:29:18 PM »
I'd really be interessted in an automated workflow involving special colors, not only player colors but also light/night colors, but I am not sure how this would work.

How about doing multi-pass rendering? This way, one can darken player colours individually.
Example:
  • Render greyscale image (for luminosity)
  • Render flat diffuse colour image. Something like this. (This way, special colours stay the same when transforming from 3d to 2d space)
  • Extract player colour by setting everything else to transparent
  • Combine player diffuse and luminosity images using a color ramp (now you have bright/dark player colours)
  • Repeat above steps for secondary player colours and day/night colours
  • Render standard coloured and shaded image
  • Replace colours from the image obtained in the previous step by shaded player/day/night colours

I am not a Blender expert so I do not know if this is actually possible.

Offline Freahk

  • Devotee
  • *
  • Posts: 1253
  • Languages: DE, EN
Re: Player Color in Blender 2.68
« Reply #12 on: July 19, 2020, 07:12:25 PM »
Not sure about blender internal, which we use to render the pak, but in cycles you can use "toon" diffuse to get flat colors.
Rendering grayscale is possible in any case.

However, it would require a lot of manual work respectively a script.
I'm not even sure if a blender script allone can do this job, I assume it can't you you will need a gimp script to combine the outputs again.

Offline walsjona

  • *
  • Posts: 17
  • Languages: EN,DE
Re: Player Color in Blender 2.68
« Reply #13 on: July 20, 2020, 09:58:09 AM »
Hey all,

I have a nodes setup for cycles from a while back that might be of interest to people here. It renders the image and indexes where player colours have been assigned as materials and then colour corrects the image so that it uses the special colours for simutrans.
Here is an example blender file:
https://drive.google.com/file/d/1gmjjsNkYnSq6FVVbW92aNUedrm7A1Ioe/view?usp=sharing

As an example, here is an early Piccadilly line tube station I was testing:


How to set up:
1. Create two materials "Player colour 1" and "Player Colour 2" and allocate them a material pass index of 1 and 2 respectively (or copy them from my example)
2. Making sure you are rendering in cycles, select "Material Index" in the passes menu in Layer Properties
3. Append the node group from the example
4. Link the Render Layer:Image to Add Player Colour: Original Image and Render Layer:IndexMA to both ID Player 1 and ID Player 2
5. Link the New Image to the Composition output. If you are using alphas the link the alpha channel from the original render straight across to the composition

It should look something like this


and will produce something like this


It has been a while since I have used this and may need a bit of fixing but I think with a bit of work, a workflow with most of the special colours could be created from this

hope this helps

Jonny

Offline jamespetts

  • Simutrans-Extended project coordinator
  • Moderator
  • *
  • Posts: 20194
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Player Color in Blender 2.68
« Reply #14 on: July 20, 2020, 05:39:35 PM »
Jonny - that is very interesting. Have you tested it in-game to see whether the produced images work with player colours and that the boundaries work as intended?

Offline TheRoadmaster1996

  • *
  • Posts: 221
  • Languages: EN, some ES
Re: Player Color in Blender 2.68
« Reply #15 on: July 20, 2020, 06:49:37 PM »
Jonny. Yes I will try this. This might be what I need to do for modern day locomotives where one of the liveries will have player color. BTW is this on 2.68 or the newer version because I don't know how to use the newer version of Blender.

Offline walsjona

  • *
  • Posts: 17
  • Languages: EN,DE
Re: Player Color in Blender 2.68
« Reply #16 on: July 21, 2020, 10:54:05 AM »
Jonny - that is very interesting. Have you tested it in-game to see whether the produced images work with player colours and that the boundaries work as intended?

Hi James - Yes I have and it mostly works as you can see here:







The main problem I have been finding with the underground platforms is getting the lighting correct which is why the middle platform looks a bit uneven. I have corrected this but not finished the image set yet.

I have also tried using it with transparency and anti aliasing with mixed results as you can see from the left most platform. The index mask doesn't account for the blurring of pixels so you end up with a fairly block colouring and artefacts at the edges of objects. I'm not sure if the former can be easily fixed as it is as much a limitation of the special colours as it is a limitation in this method, however, I had been working on the latter problem.

Jonny. Yes I will try this. This might be what I need to do for modern day locomotives where one of the liveries will have player color. BTW is this on 2.68 or the newer version because I don't know how to use the newer version of Blender.

I don't know if it will work with 2.68 sorry. I originally built it during the 2.7x generation and it certainly still works as of 2.83. It may work with 2.68 as this version has nodes and the cycles render engine. I get the frustration with moving to newer versions of Blender though, even in the small increments it sometimes feels like a completely new piece of software.

Offline Freahk

  • Devotee
  • *
  • Posts: 1253
  • Languages: DE, EN
Re: Player Color in Blender 2.68
« Reply #17 on: July 21, 2020, 11:46:50 AM »
Whilst the player colors and tile borders seem to be working, the look sems to be quite inconsistent to the blender internal rendered images.
It seems like there is still much work needed to get the lightning right.

Offline Vladki

  • Devotee
  • *
  • Posts: 3407
    • My addons, mostly roadsigns, pak128.cs
  • Languages: EN, CS
Re: Player Color in Blender 2.68
« Reply #18 on: July 21, 2020, 01:33:30 PM »
Could you elaborate?
Is the alpha channel on special colors interpreted in a special way, which is shades of the special color rather than transparency or how does this work?
How would these shaded playercolors work with models rendered to rgba pngs?
For a color to be special, the RGB triplet must be the same (as given in documentation). But you can set any value in alpha channel, thus getting more or less transparent player color. You can then let simutrans graphics engine to blend it with the background. So this can be used for: tinted glass roof, antialiased edges - where the player color touches with other objects in the background. To get more shades you can play tricks with front image in player color, and some other color in backimage...

And not completely related note - rendered images often include special colors (that shine in night), this can be amended by quick postprocessing in gimp, with https://forum.simutrans.com/index.php/topic,9500.0.html
There is a tool to select special colors and make them not special (by slightly modifying the rgb value).

Offline Freahk

  • Devotee
  • *
  • Posts: 1253
  • Languages: DE, EN
Re: Player Color in Blender 2.68
« Reply #19 on: July 21, 2020, 01:37:46 PM »
So these are not handled differently from any other colors, in which case I do not understand how this could be used to get more different shades of playercolor?
"cheating" with front/backimage? Or is there anything else that could be abused for this?

Offline TheRoadmaster1996

  • *
  • Posts: 221
  • Languages: EN, some ES
Re: Player Color in Blender 2.68
« Reply #20 on: July 21, 2020, 01:51:28 PM »
I don't know if it will work with 2.68 sorry. I originally built it during the 2.7x generation and it certainly still works as of 2.83. It may work with 2.68 as this version has nodes and the cycles render engine. I get the frustration with moving to newer versions of Blender though, even in the small increments it sometimes feels like a completely new piece of software.

If it works for the older version it just might work with the version I use. I was just worried you were using the newest version. I have tried using the newest version and I can't seem to figure it out. While it does look nice, the controls are different from 2.68, I couldn't even render an image. I would differently try to learn the new one but seeing how long it took me to learn 2.68, I don't really want to.

Offline Vladki

  • Devotee
  • *
  • Posts: 3407
    • My addons, mostly roadsigns, pak128.cs
  • Languages: EN, CS
Re: Player Color in Blender 2.68
« Reply #21 on: July 21, 2020, 03:16:26 PM »
So these are not handled differently from any other colors, in which case I do not understand how this could be used to get more different shades of playercolor?
"cheating" with front/backimage? Or is there anything else that could be abused for this?
You have only the 8 shades of player color given here: https://simutrans-germany.com/wiki/wiki/tiki-index.php?page=en_SpecialColors&no_bl=y
And 255 levels of transparency for each of them. Nothing else.

Offline wlindley

  • Devotee
  • *
  • Posts: 1026
    • Hacking for fun and profit since 1977
  • Languages: EN, DE
Re: Player Color in Blender 2.68
« Reply #22 on: July 21, 2020, 03:22:15 PM »
Using the Imager module in Perl, it is quite easy to change gradations of any given hue to the standard set of player colors.

Here is a sample program that loads a given image (with -i), and changes any color with a given hue (with -h), ± a given range (given with -H) to the eight gradations of primary player color (-P) or alternate player colors (-A). The output file is given with -o.

You can also specify a source hue from a mapcolor as "-h m3" for example.

In this way, you should be able to use Blender with any one or two colors being mapped to player / alternate-player colors… although this does not account for antialiasing.

Offline Ranran

  • Devotee
  • *
  • Posts: 1151
  • Languages: ja
Re: Player Color in Blender 2.68
« Reply #23 on: July 21, 2020, 03:31:05 PM »
And 255 levels of transparency for each of them. Nothing else.
It is handled more crudely in simtrans. Also, colors using the alpha channel are very poor.

Offline Freahk

  • Devotee
  • *
  • Posts: 1253
  • Languages: DE, EN
Re: Player Color in Blender 2.68
« Reply #24 on: July 21, 2020, 03:31:48 PM »
@Vladki, yes, that's exactly my understanding of player colors, but it's contradictory to prissis statement:
Well, with transparency one could get more shades of player color. However, one would need to write a program to covert colors with a certain hue to player color plus alpha coded gray scales.
So clarification would be great here.

Offline Vladki

  • Devotee
  • *
  • Posts: 3407
    • My addons, mostly roadsigns, pak128.cs
  • Languages: EN, CS
Re: Player Color in Blender 2.68
« Reply #25 on: July 21, 2020, 06:24:57 PM »
Oh, I didn't notice that it was written by Prissi, who is definitively more authoritative source of such information. In that case I'm also very eager to see some more details.

Offline jamespetts

  • Simutrans-Extended project coordinator
  • Moderator
  • *
  • Posts: 20194
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Player Color in Blender 2.68
« Reply #26 on: July 21, 2020, 09:46:38 PM »
This is very interesting. Handling transparency is important (or else the workflow for exporting from Blender is vastly more difficult and time consuming for each individual image (currently, no work at all needs to be done on any image exported from Blender, and this is very important for productivity) and the quality much reduced) but also, as Jonny has discovered, inherently difficult because of the lack of support for transparency in special colours in the Simutrans code.

In theory, the solution to this would be simply to set the alpha of each player colour pixel to its minimum or maximum value somewhere in Blender, whilst allowing normal gradation of other colours, but I have no idea whether this is achievable.

Another interesting thing is the use of the Cycles renderer. One problem that we have in Pak128.Britain-Ex is that the rendering workflow that we use relies on the in-built Blender renderer, which has been deprecated and is no longer in the latest versions, so we are stuck with a version of Blender that is gradually going out of date. If we can have a workflow that uses the Cycles renderer instead of the internal renderer, then we can upgrade to the latest version of Blender.

However, as has been pointed out, so far, the look that we are getting from the Cycles renderer is so far inconsistent with the look that we get from the Blender internal renderer such that we cannot use objects exported in one alongside objects exported in the other. The impression that I get from looking at these images is that the overall look of the Cycles renderer is better, but, in Pak128.Britain-Ex, it would not be feasible to go back and re-render every single image (especially as a few of the .blend files have now been lost), so this is not a workable solution for this pakset unless and until the look can be made consistent.

Of course, for a new pakset, such as some of the North American paksets being proposed, this is not an issue, and this workflow might be a good option for new paksets now being created, at least for those who prefer to work with rendered graphics.