News:

Simutrans.com Portal
Our Simutrans site. You can find everything about Simutrans from here.

Rendering multiple Blender files

Started by IgorEliezer, December 30, 2014, 11:32:06 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

IgorEliezer

Quote from: jamespetts on December 28, 2014, 08:45:14 PM
Won't anybody think of the pakset maintainers? It'd take months to re-render all of the Pak128.Britain .blends...
umm, where are those blend files? Just for curiosity.

----

MOD EDIT: This is a topic split from http://forum.simutrans.com/index.php?topic=14243.msg141155#msg141155.

jamespetts

A large number of them are here. Many more are here. Some are missing, such as .blends for aircraft and the latest Underground trains, but I am sure that Milko and The Hood could supply them if necessary.
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.

IgorEliezer

Quote from: jamespetts on December 30, 2014, 11:42:03 AM
A large number of them are here.
"Sorry, we had to truncate this directory to 1,000 files. 2,447 entries were omitted from the list. "

Ouch! That is huge. I believe that all blender files have their render scene set up.

jamespetts

Quote from: IgorEliezer on December 30, 2014, 12:22:14 PM
"Sorry, we had to truncate this directory to 1,000 files. 2,447 entries were omitted from the list. "

Ouch! That is huge. I believe that all blender files have their render scene set up.

I did tell you! And that's not even all of them. They do indeed have the render scene largely set up, however, although it does sometimes require manual turning on of the relevant layers, and, in the case of older blender models, manual setting of the file-names and the type. There are a few blender models missing, too, and one where only a much earlier version is available in a totally different scale (the LSWR M7 class steam locomotive).
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.

IgorEliezer

Quote from: jamespetts on December 30, 2014, 12:29:50 PM
I did tell you! And that's not even all of them. They do indeed have the render scene largely set up, however, although it does sometimes require manual turning on of the relevant layers, and, in the case of older blender models, manual setting of the file-names and the type. There are a few blender models missing, too, and one where only a much earlier version is available in a totally different scale (the LSWR M7 class steam locomotive).
I have good news: I wrote a small Python application which generates a batch file to render PNG images of large quantity of blender files stored in a folder. It is almost done.

The problem is what you said, the blender files do not follow an "ready-to-render" standard. I tested my app with 16 blender files, they all rendered just fine but with alpha channel and no proper background color.

jamespetts

Quote from: IgorEliezer on January 02, 2015, 08:54:54 PM
I have good news: I wrote a small Python application which generates a batch file to render PNG images of large quantity of blender files stored in a folder. It is almost done.

The problem is what you said, the blender files do not follow an "ready-to-render" standard. I tested my app with 16 blender files, they all rendered just fine but with alpha channel and no proper background color.

When I use Blender, I do not find that they output an alpha channel, but this is ignored by Makeobj (albeit with a warning), so this is not a real problem. The background colour is more of an issue: the only way to do this is have a black background with no anti-aliasing and then use the GIMP's flood fill with a tolerance of zero to replace all of the black background with the right colour. Trying to set the background colour in Blender results in it trying to anti-alias it, resulting in light blueish pixels at the edge of everything. For some reason, the only background colour that works without anti-aliasing is black. The normal workflow is to use Image Masker to process the images into a single graphic per vehicle, then use the Gimp to replace the black background all at once: this can be quite efficient.

The thing that takes most of the time is actually setting it up in Blender. Your script might actually, therefore, be very useful, and this is a very interesting development that might further improve the efficiency of graphics production. Presumably, the render settings (including the file name, and whether we want 4 or 8 rotations, normal or vehicle) have to be set up in each individual Blender file first?
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.

Sarlock

Interesting.  When I am using Blender, I export to a PNG with alpha channel (using F3), load the PNG in to GIMP, strip the alpha channel out with the Threshold tool, choosing a level that looks the best (usually around 50-100) and then drop the image on to the blue background for Simutrans and presto it's done.  Takes about 30 seconds.
Current projects: Pak128 Trees, blender graphics

jamespetts

30 seconds per image? Goodness: that's much longer than the method that I describe. (I assume that you mean per image assembled in Image Masker, rather than per rotation, or else that would be 4 minutes for every vehicle, which would just be painful).
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.

IgorEliezer

#8
Quote from: jamespetts on January 02, 2015, 09:13:50 PM
*post*
And
Quote from: Sarlock on January 02, 2015, 09:57:47 PM
*post*
If I'm sure there was a way to disable alpha channel and anti-aliasing and set up the background color right off the bat in blender so you wouldn't need any post-render edit. I remember there was a way because Raven taught me how to do so (edit: but I forgot it) when I used to post my horrible buildings like this: http://archive.forum.simutrans.com/topic/07334.0/index.html

jamespetts

If anyone knows/remembers a way of doing this, I should be very grateful to know!
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.

Ters

Quote from: IgorEliezer on January 02, 2015, 11:18:38 PM
AndIf I'm sure there was a way to disable alpha channel and anti-aliasing and set up the background color right off the bat in blender so you wouldn't need any post-render edit.

You mean, like disable anti-aliasing and setting a solid background color? The former is done in the render window and the latter is set in the world settings. By default, Blender doesn't output alpha transparency. However, if you want anti-aliasing everywhere except on edges against the background, I'm not sure if that's easily achiveable.

jamespetts

Quote from: Ters on January 03, 2015, 10:40:38 AM
You mean, like disable anti-aliasing and setting a solid background color? The former is done in the render window and the latter is set in the world settings. By default, Blender doesn't output alpha transparency. However, if you want anti-aliasing everywhere except on edges against the background, I'm not sure if that's easily achiveable.

Yes, that latter problem is the issue, I think, as internal edges need to be anti-aliased.
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.

Fabio

You could render with no antialiasing at all and correct background (if possible), to be used as a mask on the render with black background and full antialiasing, then combine with the mask using a batch editor like imagemagik. The latter program is extremely powerful for post editing.


Sent from my iPhone using Tapatalk

jamespetts

That sounds more time consuming than the present method, which is actually quite efficient.
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.

Fabio

Not if you can script the rendering, but I'm Blender illiterate. It might just be a script to launch on a folder, go grab a coffee/tea and be back with the job done.


Sent from my iPhone using Tapatalk

jamespetts

If somebody could actually set up all of the steps end to end fully automated, that would be significant progress, but I do not have the skills to do that.
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.

Ters

Quote from: Fabio on January 03, 2015, 02:48:59 PM
You could render with no antialiasing at all and correct background (if possible), to be used as a mask on the render with black background and full antialiasing, then combine with the mask using a batch editor like imagemagik. The latter program is extremely powerful for post editing.


Sent from my iPhone using Tapatalk

You might perhaps not need to use an external program. Blender has a very complex node system for post-processing. Understanding it is another matter. In either case, there might be a problem that anti-aliasing bleeds both ways, so there is a mix of the background color inside the mask as well. One could perhaps get around that somehow by adding the background color in a post-processing node, after the edges have been made aliased somehow.


Sent from my computer using a browser

jamespetts

If anyone can find a way of doing that (preferably automatically), then that would be splendid.
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.

Sarlock

Perhaps I am not fully understanding the issue, but you can output to an RGBA alpha PNG in Blender.  This still does all of the anti-aliasing and then you just have to strip the alpha channel out (either fully or at some determined percentage) and you have a nicely anti-aliased image internally with sharp edges on the outside.  This way you do not get any anti-aliased blending with the background colour, since there is none.

If your script outputs all of the images together on one PNG for the different rotations, it just takes one quick operation to strip the alpha channel and it's ready to import to Simutrans.  Further, I believe this alpha channel removal could be automated using GIMP's command line feature (you could do an entire folder of files in one command line operation).

If the alpha enabled PNGs are kept separate, then you even have a quick way to make an alpha-channel ready pakset, if ever that should be a possibility in the future.  But I dream...  ;)
Current projects: Pak128 Trees, blender graphics

jamespetts

That is an interesting idea, but, unless the post-processing could be automated, it'd be no better than the current arrangement, where it's just a single click in the GIMP with the fill tool to post process a single vehicle after it has been through Image Masker to combine it into one image (the Blender output produces one image per rotation, not per vehicle, and I suspect that this would be hard to change).
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.

Sarlock

Could the script output the images from Blender with filenames that are numbered/ordered so that a second, later, script can be run to auto process these images through GIMP and makeobj?  You could process a whole batch of images through Blender, then quickly script process those same images with a single click to import them to Simutrans as .pak files.  You could conceivably process dozens or more vehicles/buildings/etc in a matter of seconds.
Current projects: Pak128 Trees, blender graphics

IgorEliezer

Quote from: Sarlock on January 03, 2015, 08:30:17 PMCould the script output the images from Blender with filenames that are numbered/ordered so that a second, later, script can be run to auto process these images through GIMP and makeobj?
As to the 1st script: I wrote one to render every blender file "as-is" stored in a directory: http://github.com/IgorEliezer/RenderTrans, but it still needs some final tweaks.

jamespetts

Yes, the output files do have determinate names and numbers that are used for semi-automatic processing by Image Masker.
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.

Ters

Quote from: Sarlock on January 03, 2015, 07:54:43 PM
Perhaps I am not fully understanding the issue, but you can output to an RGBA alpha PNG in Blender.  This still does all of the anti-aliasing and then you just have to strip the alpha channel out (either fully or at some determined percentage) and you have a nicely anti-aliased image internally with sharp edges on the outside.  This way you do not get any anti-aliased blending with the background colour, since there is none.

I was thinking the same, and now I tried it out. But it appears Blender anti-aliases against black when there is no background.

jamespetts

Another issue is that quite a number of the Blender graphics, particularly for railway vehicles are made by having one Blender file for a whole set of different but related vehicles, such as different configurations of the same basic type of carriage, or even one layer for a steam locomotive and one for its tender.
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.

IgorEliezer

I think we should split the topic and move all Blender-related posts to PakSets and Customization section before our bored programmer comes in and say "Get off my lawn!" :D

Agreed?

EDIT: Blender has an internal Python API so it's possible to run a script "in" Blender to set up things right... not a trivial task though.

jamespetts

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.

Markohs

I'm not that bored anymore, but yes, get out! ;)

Yona-TYT

I think there is enough material to entertaining here.  ;D