News:

SimuTranslator
Make Simutrans speak your language.

Blender to png

Started by The Hood, January 27, 2014, 08:48:42 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

The Hood

This thread gives a summary of how to use the rendering add-on for blender and Zeno's ImageMasker program to create full pngs for pak128.Britain. This works for 1x1 buildings and all vehicles.


Step 1: make blender model and scale correctly:
- best to start from an existing blender file so the lighting is set up correctly.
- Ensure vehicle is correctly aligned - centred down its direction of travel, z-aligned with wheels on the z=0 plane, 4 blender guide squares in front of the vertical axis looking side on (see an existing example of a blend for what I mean here).


Step 2: use the rendering add-on to output the images (see attachment):
- make sure the py script in the attachment is in the python add-ons folder in blender: e.g. C:\Users\XXXXX\AppData\Roaming\Blender Foundation\Blender\2.64\scripts\addons
- enable the addon in blender: User preferences->addons->render tab, make sure the check box is ticked on the right:

- Back in the properties window in blender you should now see an extra box in the render tab:

- give the image a name in the first box (NO FILE SUFFIX)
- choose render option: 4 views for buildings, 8 views vehicle alignment FOR RAIL VEHICLES, 8 views normal alignment FOR ALL OTHER VEHICLES
- Hit the render views button and wait
- "MAKE MASK" is if you want to automatically create a shadeless, non anti-aliased images which can be used to give sharper edges and auto player colour in the next step, but this doesn't work too well and pak128.Britain graphics do not generally use this feature.


Step 3: Load up ImageMasker
- Choose 4 or 8 views as appropriate
- open button - select the 4 or 8 output pngs
- select the SAME 4 or 8 files at the second prompt again, unless you have created a mask set of images in which case use those.
- hit process
- hit save and save the output png where you need it


Step 4: Use a graphics program eg GIMP to convert black background to #e7ffff simutrans transparency colour on the output png and resave


Step 5: Get the dat file right
- NB image definition 1.0 is WEST, 1.1 is NW etc.
- apply any offsets. I have now worked out the offsets for road vehicles - this works for vehicles centre-aligned in blender and with the drive_left flag set to 1 in compat.tab:


EmptyImage[E]=./images/aec-swift.1.4,-28,14
EmptyImage[SE]=./images/aec-swift.1.5,-13,0
EmptyImage[S]=./images/aec-swift.1.6,4,4
EmptyImage[SW]=./images/aec-swift.1.7,0,18
EmptyImage[W]=./images/aec-swift.1.0,4,5
EmptyImage[NW]=./images/aec-swift.1.1,12,10
EmptyImage[N]=./images/aec-swift.1.2,28,14
EmptyImage[NE]=./images/aec-swift.1.3,0,24



Step 6: Compile with makeobj and enjoy


Moderator note: The original download link (below) is now broken, but you can download an updated version of the file here instead. - Jamespetts.

Moderator note 2: For this workflow to work correctly, it is essential to use Blender version 2.65 (or earlier, but not all earlier versions have been tested). Version 2.65 can be downloaded for Windows, Linux and MacOS X here.

jamespetts

Ahh, you have the road vehicle offsets - excellent! This is of great assistance. When you write "centre aligned" in respect of road vehicles, do you mean using the "normal" rather than "vehicle" settings?

Finally, I wonder whether there is anything to be said for using the road vehicle offsets for river and canal boats...?
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

Either. What I mean is make sure the vehicle straddles the y-axis along its length.

jamespetts

Ahh, I see what you mean by that; but surely the offsets would need to be different if the vehicle was in "normal" than "vehicle" alignment? Was it "vehicle" alignment that you used?
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

All in the first post... (look carefully at step 2) :)

jamespetts

Ahh, the road vehicle offsets are indeed based on the "vehicle" settings?
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

Excellent!  Thank you for this :)
Current projects: Pak128 Trees, blender graphics

The Hood

Quote
- choose render option: 4 views for buildings, 8 views vehicle alignment FOR RAIL VEHICLES, 8 views normal alignment FOR ALL OTHER VEHICLES

Am I missing something here or is this not clear enough? Road vehicles are based on NORMAL settings. I should probably rename "vehicle alignment" to "rail alignment" in the python script though.

jamespetts

By "rail vehicles", I assume that you mean to include rail, narrow gauge, tram, monorail and maglev?
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

Well I've never made any monorail and maglev vehicles so I don't know about those, but the first three yes.

fam621

How do you get the trains and make them on blend then into a dat file then a pak file James? I'm trying out blender for a bit to see if I can make liveries? :)

jamespetts

Fam621 - you originally posted in a thread about an unrelated bug, so I have split your topic and merged it with this thread, which contains the answer to your question.
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.

jamespetts

After extensive testing, I have found that Blender versions newer than 2.65 cannot produce usable graphics unless they are exported in full alpha. This is because the way in which Blender handled image transparency was modified in version 2.66: see here for details of the change.

The problem is that, in the newer rendering system, when a black background is used, objects tend to be surrounded by a thick, black line because the renderer now blends the black background pixels with the image pixels in a way that it used not to do when the render output was set to "straight alpha" (which is no longer available from version 2.66 onwards).

Despite the statement on Blender's own page (linked above), however, that the alpha convert node could be used to revert to the previous behaviour, I have not been able to get the alpha convert node to have any effect (I suspect because nodes are not compatible with the Blender rendering script).
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.