Dark Shader

Some time ago I started work on a game project taking inspiration from titles such as Slender and Amnesia: The Dark Descent. The majority of the game was to take place inside a dark mansion with the aim of invoking fear through a build up of tension, as opposed to a continuous cycle of jump scares. Although that particular project never saw the light of day (it was dark after all), it gave me an idea. For my first Unity shader, I wanted a simple but powerful way of enhancing darker scenes. What I ended up with was a fragment shader that achieved exactly that through a two stage process.

 


The first stage involves a simple formula that enhances the range of darker colours and vice versa for brighter colours, by mapping the red, green and blue colour components to a slight curve.




The second stage relates to the idea of cool and warm colours. By decreasing and increasing the red and associated green components depending on how dark or bright a pixel is respectively, an eery yet natural tone can be achieved to compliment an already dark environment. This stage introduces a multiplier variable for controlling the overall "warmth" of the scene with a value of 1 indicating a completely "cool" tone. I have chosen a value of 2 as default, as shown in the image below. The effect of this stage is clearly demonstrated given that the original image was grayscale.




I will follow up to this post with a Unity web build of the shader in action.

Comments

Popular Posts