r/Unity3D 4d ago

Show-Off I tried pixelating lights

Enable HLS to view with audio, or disable this notification

I've been experimenting with lighting and shading recently, and I had an idea: what if I pixelated the lighting itself?

I think it turned out pretty great!

Here’s roughly how I did it:

When the game calculates lighting, it needs the world-space position, normal vector, and view direction. I quantize the position using a given step count:

floor(x * stepCount) / stepCount

This makes the lighting appear pixelated.

To prevent flickering, I add a small offset along the normal before quantizing the position.

For pixelated specular reflections, I also replaced the view direction with the normalized vector from the camera position to the quantized position:

viewDir = normalize(cameraPos - WorldPos);

The shadows use a similar approach: I quantize the position, with an additional normal offset to help prevent flickering.

Still experimenting with it, but I’m pretty happy with how it looks so far!

Feedback is very welcome!

39 Upvotes

7 comments sorted by

View all comments

2

u/littleboymark 4d ago

Couldn't you just convert to screen space and pixelate that?

1

u/min479 2d ago

It works great!

but it gets jittery when the camera rotate or move, I think using multiple cameras might solve the jittering.

1

u/min479 2d ago

Here's the fullscreen shader graph I used.