Playing around with shaders and found this


Hello everyone,

Opposed to what I said previously I didn't focus on the entities and game-play but got carried away by a video from Francis Vace on YouTube (View video on Youtube). He created a palette shader where you can easily swap colors and create interesting effects such as a light effect. The input thought is a sprite with only black, white and gray. The shader makes it possible to change these colors and even hide colors if not in the reach of a certain parameter.

Technically you work with two cameras. The main camera which is capturing the scene, a material is set to a quad in 3D space, behind the main camera and the second camera captures what is on this quad, so basically what the camera sees


The twist behind it is, that we can apply an overall shader effect on the quad that affects all of our view without messing around with the actual game objects, but still the shader can reference game objects, with an extra object.


Cameras and quad in 3D perspective

So what I do here is taking a black and white sprite 

or this in the case of example white some gray
(I know these tiles don't look appealing but I just created them in the sake of testing the shaders)
an swap the colors inside the editor. I put the gray to do some experiments with a third color that will be visible depending on a threshold. This threshold will be used to swap colors again and when the colors are chosen wisely we create a stylized 2D lightning effect that can follow a object around the screen, all done with shaders.


(Swapping out some colors in the editor, this can change the appeal of levels much)

Where does this leads my UntitledTorchGame? I guess it is another approach how to achieve the lithgning effect but in this project I won't use it because it is not quite fitting in the whole concept. But I will keep this nice pallete swap shader for another project and I was really excited when I got the idea with multiple cameras, that I needed to try it myself.

So what is next on UntitledTorchGame?
I guess what I hold you guys before, creating entities and make them interact in some ways with the player.

See you around and have fun gaming and coding.
I added the project files to git, so you can grab them if you want:
https://github.com/postosaurus/BlackWhiteSwapShader

Leave a comment

Log in with itch.io to leave a comment.