News:

SimuTranslator
Make Simutrans speak your language.

Player Color in Blender 2.68

Started by RealAmerican1776, July 19, 2020, 01:24:22 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

RealAmerican1776

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?

Mariculous

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.

jamespetts

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

prissi

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.

RealAmerican1776


Mariculous

Quote from: prissi on July 19, 2020, 01:16:38 PMWell, 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.

RealAmerican1776

So what if I change the player color to match the shading? Make it darker with shading if that makes sense. Will that work?

jamespetts

Quote from: TheRoadmaster1996 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?

I am not sure that I do understand, I am afraid; one cannot change the player colours as these are hard coded.
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.

RealAmerican1776

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?

Ranran

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.

RealAmerican1776

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

ceeac

Quote from: Freahk on July 19, 2020, 02:50:42 PMI'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.

Mariculous

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.

walsjona

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

jamespetts

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

RealAmerican1776

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.

walsjona

Quote from: jamespetts 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?

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.

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

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.

Mariculous

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.

Vladki

Quote from: Freahk on July 19, 2020, 02:50:42 PMCould 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).

Mariculous

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?

RealAmerican1776

Quote from: walsjona on July 21, 2020, 10:54:05 AM
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.

Vladki

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

wlindley

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.

Ranran

Quote from: Vladki on July 21, 2020, 03:16:26 PMAnd 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.

Mariculous

@Vladki, yes, that's exactly my understanding of player colors, but it's contradictory to prissis statement:
Quote from: prissi on July 19, 2020, 01:16:38 PMWell, 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.

Vladki

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.

jamespetts

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