![]() In the inspector, you can then set the color palette under Shader Param. To create different filters, simply create new ShaderMaterials with the shader assigned to them. Set it to the bottom of the scene hierarchy at top level, so the effects gets drawn on top. ExampleĪs filter lens, there is a ColoreRect with a GameBoyFilterMaterial_es set as material. On the top right, there is an orange filter applied. On the top left, there is a blue filter applied. In the upper image, there is a screenshot of an imaginary game called "GameBoy Hospital". With this shader, you can color in images (or swap the palette) to look like they are displayed on a GameBoy. #Godot palette swap codeThe code for the shader was updated to Godot v3.1.1. You can find all my addons on my profile page.This is a variant of Ivan Skodje's Godot Gameboy Shaders. The shader should be pretty fast, but I didn't test performance limits. I optimized the code and there is only one if that will branch if your source image has colors that won't be replaced. The colors are first converted to integer, so the comparison is faster and perfectly accurate. The shader uses for loop to compare pixels. The palette appear in your files with the name youroriginalimage_palette.png.In the script editor, use File -> Run ( Ctrl + Shift + X).Select any node with a texture property (e.g.Open PaletteGenerator.gd file in the script editor.It checks every pixel for unique colors and puts them in a row, and adds a second empty row. It's an editor script that will automatically generate a palette template for the selected node containing a texture. The asset comes bundled with PaletteGenerator.gd file. Note: Be sure to set texture_filter on the node with material to Nearest. It's fast enough to have tens of them, but hundreds/thousands might be problematic (I didn't test exact numbers, but I guess no one will use such big palette. Number of rows doesn't matter, but having too many columns will have impact on performance. The shader supports any palette size (but Godot imports only up to 16k). The colors in the same column are being cycled and the animation length depends on number of columns. The shader will replace these colors from the original with the other colors in subsequent rows. The palette is divided in columns and rows. fps - frames per second, or more like, rows per second in the animation.Normally the alpha is ignored and uses the source alpha. use_palette_alpha - if enabled, the output color will also use the alpha value from the palette.In case of the above example, the orb would have one grayscale frame. skip_first_row - if disabled, the first row of palette will also be used for animation.The first row are the grayscale reference colors from the image, the other rows are colors for animation. It will cycle through the rows of the assigned palette, based on the fps parameter. Put the palette into the material params.Assign shader to your Sprite or any other CanvasItem node.Top row of the palette are colors you want to replace, second row are the desired colors. Get some image that you want to recolor.It's like your standard palette-swap, except it requires zero configuration, has virtually no limit for number of colors and supports animation. This shader allows for remapping colors based on a provided palette. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |