Hello Guest

Author Topic: Tile Pixel Manipulation  (Read 1045 times)

0 Members and 1 Guest are viewing this topic.

Lycake

  • Member
  • Posts: 2
    • View Profile
Tile Pixel Manipulation
« on: October 22, 2016, 08:38:22 AM »
Hello!

I am using a tilemap similar to the principle of the game Dwarf Fortress. It works like this: You have transparency, gray pixels, and colored pixels on the tiles. Together with the tile number, you get a foreground and a background color. The the transparency defines the amount of background color on that pixel, the gray pixels the amount of foreground color and the colored pixels are unchanged.

This makes it so you can use the same tiles for different objects in your game - colored differently. For example you can have a bucket out of copper or iron (using a reddish or gray foreground color), while having pre-colored blue water with one single bucket tile.

Now my problem is, that I need to change the gray pixels in my tiles to the foreground color (or rather merge it, because I need various degrees of foreground color brightness, depending on the darkness of the gray pixel). I can't seem to find an approach that works. I couldn't find a way to change my tiles on a pixel per pixel basis manually and my other thought was using a shader, but shaders only work on the whole tilemap and not on individual tiles. Coloring the whole tile also changes the true colors in the tiles, which should stay unchanged.

I know this forum isn't very active anymore, but I really hope someone has an idea how to solve my problem. I really like otter so far and hope I can use it with this project of mine.

Thank you,
Lycake
« Last Edit: October 22, 2016, 12:13:11 PM by Lycake »

Commanderstitch

  • Member
  • Posts: 37
  • Personal Text
    • View Profile
    • commanderstitch Homepage (coming someday)
Re: Tile Pixel Manipulation
« Reply #1 on: October 22, 2016, 09:23:52 AM »
I usually just white/greyscale my sprites/tiles and set them to whatever color i want at runtime. That's just what i do atm. I've never tried this pixel manipulation of individual pixels since c++. Good luck with your stuff! I'll see if i can't get others to read this on the forum and check it out. Most of us are in the otterslack. join up and have a chat. we'd love to see you.
:-)
- Commanderstitch

Lycake

  • Member
  • Posts: 2
    • View Profile
Re: Tile Pixel Manipulation
« Reply #2 on: October 22, 2016, 09:37:40 AM »
Thanks for the quick reply!

Hm is it possible to only color the grayscale part of the sprite? Coloring the whole tile wouldn't work because I have fixed colored parts that shouldn't be tinted and stay as they are.

Oh and yes I have requested a slack invite but havn't gotten any email yet (yes I checked the spam folder)
« Last Edit: October 22, 2016, 10:18:20 AM by Lycake »

misthema

  • Member
  • Posts: 3
    • View Profile
Re: Tile Pixel Manipulation
« Reply #3 on: December 29, 2016, 01:56:36 AM »
Thanks for the quick reply!

Hm is it possible to only color the grayscale part of the sprite? Coloring the whole tile wouldn't work because I have fixed colored parts that shouldn't be tinted and stay as they are.

Oh and yes I have requested a slack invite but havn't gotten any email yet (yes I checked the spam folder)
You could always separate your fixed-colored-parts and the greyscale images into 2 images, then use color tinting on the greyscale one. This might cause some problems if you're rotating your sprites/camera, unless you use the exact same (rounded) position and angle for both images. Doing this by manipulating pixels would be slow as hell if done in real-time. Pre-processing these wont cause any problems though.