It’s still Saturday in America, which I think means I have to post a screenshot. It’s quite tech-heavy, so there’ll be plenty to say about how we’ve been approaching various challenges in the game’s development. We’ve been chipping away at bits of it for a good while now, but not full time and not consistently, so it’s still early days – I suppose I would say it’s part way between a fairly well-fleshed-out tech demo and a pre-alpha game. For now, I’ll just say that we’re hoping it will appeal to people who enjoyed games such as Factorio, Terraria, and World of Goo (yes, I realise they are three very different games). Soon (tomorrow), I’ll put up a big, proper post. It’s called Sun Shy, and it’s getting to the point now where I should probably start talking about it in public. Long story short, we’ve settled on something. I don’t know how this goes for most developers, but for me, this process usually involves building a few demos or other bits and pieces, seeing what seems good and/or interesting, and eventually settling on something to focus on. It’s been a while since I was working on Sprite Lamp full time, and we’ve been kicking around/playing with a few ideas for Snake Hill Games’ next project in the meantime. Each of these things will be getting a Proper Post in the near future. So this is me trying to get back into the swing of things. However, some things are happening! And some of those things involve being a bit more talkative on the internet. One of the things I mentioned is how bad I am at interfacing with the world through social media, and I think my lengthy silence bears that out. I find that it is easier to do it using a uniform array so I use that.So it’s been quiet out here since my last post, almost two years ago, about finalising Sprite Lamp. There are two strategies to pass the palette to the shader: by using a texture or a uniform array. Now, that we have preprocessed our images, we are ready to write the shader to finally swap the palettes. Nothing fancy, all the hard work is done by Pillow. Then, it reinterprets it as a grayscale image. fromarray ( palette_colors, mode = 'RGBA' ) return grayscale_image, palette_imageįirstly, the function converts the image to the palette mode. astype ( 'uint8' ) palette_image = Image. asarray ( + ] \įor i in range ( palette_size )]]). getpalette () transparency = list ( indexed_image. asarray ( indexed_image ), 'L' ) # Create the palette open ( f ) # Reinterpret the indexed image as a grayscale image save ( f, 'png' ) indexed_image = Image. # Save and load the image to update the info (transparency field in particular)į = io. convert ( mode = 'P', dither = 'NONE', colors = palette_size ) # Be careful it can remove colors Import io import numpy as np from PIL import Image def convert_to_indexed_image ( image, palette_size ): # Convert to an indexed image To do that, I use a little Python function that uses the Pillow library: The image is in grayscale mode and the gray level of each pixel corresponds to the index of its color in the palette. it replaces indices by the corresponding color in the palette.Ĭonsequently, to avoid this problem, I store separately the image and the palette. It uses stb_image under the hood which automatically “depalettizes” images i.e. It is the case of SFML, the library I used. Unfortunately, many libraries that load images will provide an array of colors even if the image was stored in indexed mode. For instance, the PNG image format has an indexed color option. In fact, several image formats support this way of storing images. This way, we decouple the structure of the image (the areas with the same color) with the real colors. What we would like instead is that each pixel contains the index of its color in a palette. In a raster image, each pixel contains a color. The first step is to prepare your images for palette swapping. Now, it is used in procedural generation to produce new assets, I will show many examples in later devlogs. It was a useful technique in the old days to add variety in the assets without using too much memory. Here, we will do that at runtime using shaders. Palette swapping is simply changing the palette of a texture. In this devlog, I will show you a technique that I love and that I will abuse in Vagabond: palette swapping.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |