For last few days (amongst other things), I’ve been working on the PSX shader to simulate that distortion you often see in PSX games. The goal is to use this shader to help add a layer of creepiness to the environment through the shader.
So before I did anything, I did a quick search on “PSX Shader” on Google to see what would come up. I ended up coming across a few forum posts which pointed me in the direction of Affine Transformations.
After doing a little bit of a deeper search, I came across a basic shader which simulated the effect, but wasn’t exactly ideal for what we were trying to do. So I spent a few hours experimenting to try and understand what was going on and come up with our own.
And I did it! But it did have some problems.
One of the problems with the shader was when in first person view, the textures underneath the player would become extremely distorted. So I ended up adding a cut-off value which determines when to blend between Affine Transformed UVs, and normal UVs to help remove the distortion underneath the player.
It kind of makes a nice sense of normality around the player, while everything else is distorted and feels like it’s moving.
I also added vertex snapping into the shader to simulate PSX fixed precision. I used a single float value which indicates how many increments there are per unit, and rounds each vertex axis to the nearest increment.
Sliding the value back and forth also creates a pretty neat effect causing the vertices to move around and shake. Which we might incorporate into gameplay some how.
Once I got the base shader, I wrote variations which add Vertex Coloring and support for Unity Lighting, which will allow us to create interesting lighting and set the mood. And to save time on writing too much shader code, I wrote it in a Surface Shader.
After testing it a little further, I was pretty happy with the results. The final result is a nice distortion effect to create a slightly creepy environment.
Comments for this post are closed.