opengl

Figure I outta post some holdover material, so here’s opengl render of the van from the previous ADPAB post. Got lazy on texturing, but I figured the flaws wouldn’t be noticeable from the proper angles and lighting. Plus I’d spent far too long on the model and just needed it out the door.

Xargus / Game Engine - Experimenting with modifying colour encoding method for dynamically recolourable images

I have been experimenting with making adjustments to the algorithms and methods that my game engine uses in order to dynamically recolor images, in the hope of increasing the efficiency of dynamically recolouring images, as well as making it easier to create recolourable images.

Doing this will hopefully allow for recolourable images to be used in Xargus more easily and more efficiently, paving the way for their use in more places throughout Xargus, such as in background detail images, floor detail images, enemies (recolourable skin, hair and clothing), and in the alien (recolourable skin and potentially clothing).

Changing from using Red pixels to encode black areas to using black pixels to encode black areas

Currently, I use the approximate following method for providing dynamically recolourable images where they are used in Xargus (currently they are only used for the hill backgrounds and grass tile background):

This method was used as it was easy to implement and relatively efficient, however the major drawback to it is that it is quite complicated to generate the images used – each colour needs to be layered on top of the previous one additively, which involves recolouring different parts/layers of the original image, and takes quite a bit of time in photoshop; especially recolouring all the black lines and shading to be red and use additive blending.


I have therefore come up with an alternative formula to use that does not suffer from these problems, as it uses black instead of red as the colour for black lines. This is slightly more complex as a formula, due to the fact that black is the final colour that should be added to the image and merged with all previous ones, and it is difficult to measure the amount of black as a single value (i.e. measuring the amount of red can be done with pixel.r, but with black this isn’t as straightforward):

This alternate method allows for a significantly easier way of creating recolourable images, at the expense of a slightly more complex (and therefore slightly more expensive) algorithm. I am hopeful that this additional expense will be minor.

The key way in which this method works is that all of the non-black areas of the image have a red value of 1 (the maximum), and then additional custom colours are made by layering them on top of the red colour in an additive way (i.e. the green custom colour would be green+red = yellow, and the blue custom colour would be blue+red = pink). This way, the amount of black in a pixel can be measured by (1-pixel.red)

This method involves a slightly more complex formula as it is necessitated  to divide by pixel.red when working out how much of each custom color, as pixels will contain less red value when translucent black has been added over the top of them.

Like the original method, this method, in addition to allowing for solid areas of the first, second and third custom colours, also allows for blends/gradients between them, e.g. blends between the first and second, first and third, or second and third custom colours.

  • Me before seeing the final episode: Pff, people are overreacting. Computers are deterministic machines, and everything can be explained as a series of dissectable equations determining what gets displayed.
  • Me after seeing the final episode: What the fu.ck What the fuck. What the fucking fuck. Computers aren't real. Nothing is real. What. The fuck.