Page 2 of 2
Re: Raster / shader project - insane?
Posted: 21 Feb 2012 08:59
by andythenorth
FooBar wrote:I'm quite surprised you can draw a tanker out of a single line of pixels!
Here's how it's done
This image shows each individual element used (usually all of these elements are drawn together).
The elements are coded in lists of pixel values, which suits me - but they could also be loaded as graphics from files, which might be less tedious than compiling lists in code.
Re: Raster / shader project - insane?
Posted: 21 Feb 2012 09:08
by FooBar
Ah, I see. So this line basically defines where each element must be placed, right?
Re: Raster / shader project - insane?
Posted: 21 Feb 2012 09:16
by Emperor Jake
andythenorth wrote:Tanker B-Train

Looks great, but it's technically not a B-train, it's more of a "true" road train.
(see link) Having been somewhat of a truck enthusiast in the past, I am knowledgeable about the wheel arrangements and their proper names. If you want I'd be glad to assist
(Or maybe the American definition of B-train is something different to the B-double I have in mind)
Re: Raster / shader project - insane?
Posted: 21 Feb 2012 09:48
by andythenorth
Emperor Jake wrote:(Or maybe the American definition of B-train is something different to the B-double I have in mind)
You're right, it's actually a Turnpike Double
http://www.fhwa.dot.gov/publications/pu ... /fork3.gif
Re: Raster / shader project - insane?
Posted: 21 Feb 2012 10:15
by Emperor Jake
Ah, I see. It seems to be the same thing but with less axles. (Australian trucks have the most axles and tyres - a standard Australian semi-trailer has 22 tyres, as opposed to the American 18 and the European 12 or 14)
Will some of those other combinations be in the set as well?
As you may have noticed, I am very interested in this set, as I use a LOT of trucks in my games, and I'm not entirely satisfied with the currently available truck sets. Keep at it!
/encouragement
Re: Raster / shader project - insane?
Posted: 23 Feb 2012 22:31
by andythenorth
Stake trailer with steel coils load. 4 pass render for this one:
1. draw flatbed, far-side stakes
2. draw coil furthest from camera
3. draw coil nearest to camera
4. draw near-side stakes

- steel_trailer.png (10.17 KiB) Viewed 8262 times
Re: Raster / shader project - insane?
Posted: 24 Feb 2012 00:14
by MinchinWeb
andythenorth wrote:Tanker B-Train

I looked it up because I was curious. Turns out "B-train" (at least in Alberta, Canada) refers to how the two trailers are hooked together. There's also such things as A-trains and C-trains. (I hope my picture is clear enough...).

- ABC Train.png (16.38 KiB) Viewed 8249 times
The Alberta Highway Design Guide also has this:
Alberta Infrastructure's [i]Highway Geometric Design Guide[/i] wrote:...a 25m [long] double-trailer combination (WB-23) commonly known as the Super B train. This design vehicle also covers A and C trains with similar dimensions. Details of A, B and C-train connections are shown in Figure D-5e [the picture above]. This is the longest tractor-trailer combination allowed on Alberta highways without special permits.
A Rocky-Mountain Double is sometimes called a WB-36 and can be up to 28 m long.
P.S. Andy, your trucks look amazing. I'm excited to see the whole set!
Re: Pixa (was raster / shader project - insane?)
Posted: 02 Mar 2012 09:14
by andythenorth
With help from Alberth (and others) I've been packaging the code for this into a python module so other people can use it
It will be released as 'Pixa' when done (name suggested by Rubidium; unlike most of my projects this one is not an acronym).
Meanwhile I've also been documenting how it works. Here's the diagram of the render stage; there will be other diagrams showing how to put the rest of the pipeline together around this.
'Gestalt' is a shape or form, typically a vehicle with all of its load states, colour variations etc. For example, in BANDIT I have a gestalt for each of tank trailer, tipping trailer, flatbed trailer. A gestalt is a python file defining values and rules for rendering.
Re: Pixa (was raster / shader project - insane?)
Posted: 02 Mar 2012 09:49
by FooBar
Nice, I've been talking to Voyager One that we may want to give this a go for rendering more or less crude shapes for cargo wagons (for the Dutch set) that then can be manually retouched to make it look more like the real vehicles.
I'm interested to learn if I can deploy this system myself. If not, I'll make sure to query you for assistance
andythenorth wrote:unlike most of my projects this one is not an acronym
Oh, but that can be solved by making it a backronym. How about...
Pixa Insane piXel Algorithm

Re: Pixa (was raster / shader project - insane?)
Posted: 03 Mar 2012 17:01
by Roujin
You could say that "pixa" stands for "Pixa Is Not an Acronym". I'd like that.

Re: Pixa (was raster / shader project - insane?)
Posted: 03 Mar 2012 17:05
by Eddi
that would be "PINA"... did you read a book "backronyms for dyslexics" or something?

Re: Pixa (was raster / shader project - insane?)
Posted: 04 Mar 2012 14:17
by Bob_Mackenzie
but he said it WASN'T and acronym..

Re: Pixa (was raster / shader project - insane?)
Posted: 05 Mar 2012 06:51
by andythenorth
More Pixa docs: using a Gestalt to assemble spritesheets.
Pixa doesn't enforce a particular spritesheet structure, this inherent flexibility means authors have to put together a small pipeline to assemble spritesheets to suit their project.
For BANDIT, each vehicle type has Variations; each Variation being a specific combination of colours, cargo type, vehicle length, and other details. For each Variation, Pixa outputs a png spritesheet, with 1 row per load state for that Variation (BANDIT typically uses 4 load states per vehicle, so 4 rows).
Re: Pixa (was raster / shader project - insane?)
Posted: 08 Mar 2012 08:02
by andythenorth
Doing some work with some tarpaulin loads from Mr. Bird...
Re: Pixa (was raster / shader project - insane?)
Posted: 08 Mar 2012 08:04
by andythenorth
...
Re: Pixa (was raster / shader project - insane?)
Posted: 11 Mar 2012 07:31
by andythenorth
Alberth and I have found some optimisations to Pixa that decreased total render time in the test project by more than 50%.
I've also switched it to use python multiprocessing, as rendering pngs is an
embarrassingly parallel problem. The speed effect of this varies by number of cores / thread units available, and the size of the project.
The net effect of this can be seen in the render times (per BANDIT image) below.
Unoptimised: 0.15s / image
Optimised, MP (4 thread units): 0.03s / image
This will vary significantly depending on the size and type of image, how many render passes are used etc. However if it scales linearly, rendering 1,000 BANDIT-style images would take ~1min. This is very slow, but acceptable as rendering images won't need to be done very often.
Re: Pixa (was raster / shader project - insane?)
Posted: 11 Mar 2012 09:13
by Coxx
Sounds like a interessting concept for ships to.
Re: Pixa (was raster / shader project - insane?)
Posted: 01 Apr 2012 07:04
by andythenorth
Pixa is now released as 0.1 here
http://dev.openttdcoop.org/projects/pixa/repository
To get pixa, checkout (or download) that project, then from the project root run 'python setup.py install' (this will install pixa to your system python).
There's no further documentation and no tutorial yet. Pixa is in use for BANDIT and there are examples there.
If anyone would like to try using pixa, we can work through it here, which will provide an example / tutorial for others.
Pixa is good for three cases so far:
1. quickly generating sprites for vehicles or buildings that have regular shapes or patterns
2. compositing vehicle sprites with cargo sprites for different load states (empty, part-loaded, fully loaded etc).
3. recolouring; although recolour sprites can be used in game, an alternative approach is to recolour before compiling. This works for different cargos, liveries etc.
PIL is a required dependency; this is also required for nml, so many authors will already have it.
Pixa works well with python's built-in multi-processing module, which can significantly decrease render time when multiple thread units, cores or CPUs are available.
Pixa can be used with a makefile.
Pixa has also been tested as working on the openttdcoop compile farm.
Re: Pixa (was raster / shader project - insane?)
Posted: 21 Apr 2012 10:46
by Eddi
Quickly getting started.
I've recently discussed with andythenorth about a "how-to" for pixa, so here's the quick-and-dirty conclusion for the first steps.
1) install python and PIL with the usual installers for your OS
2) install pixa. from your downloaded source, run:
3) make a floorplan image with your favourit image processor, preferrably already in TTD (DOS) Palette.
4) make a script (or use the python interactive console)
4a) open your image file
Code: Select all
floorplan = Image.open("test-input.png")
4b) make a spritesheet out of your image
Code: Select all
spritesheet = pixa.Spritesheet(floorplan.size[0], floorplan.size[1], floorplan.palette)
spriterow = {'height' : floorplan.size[1], 'floorplan' : floorplan}
4c) define the transformations you want to do on the image (here: replace all pixels with colour 86 (green) to pixels with colour 240 (flashing red))
Code: Select all
seq = pixa.PixaSequence(points = [(0,0,240)])
sc = pixa.PixaSequenceCollection(sequences = { 86 : seq })
spriterow['render_passes'] = [{'seq':sc, 'colourset':None}]
4d) process the image
Code: Select all
spritesheet.render(spriterows=[spriterow])
4e) save the image
Code: Select all
spritesheet.save('test-output.png')
for more advanced stuff, you may refer to the BANDIT source for examples.