Post

Sharing this here too! Small thing I wanted to try ever since I saw it in a bunch of toon shaders: a depth-offset based rim lighting that responds to the light direction ✨ It's quite more stylized than just a thresholded fresnel and it can look pretty sick with cel shading👀 #unity3d #madewithunity

38 reposts361 likes

Ah, I've never heard of this technique but I think I get it! You compare the scene depth of the fragment to the scene depth at an offset based on the screen-space lighting direction. If the depth is much deeper, then you know it's at the very edge of the object. Very cool. Are there any artifacts?

Yeah, it's really cool for 2D/anime-style stuff ✨ there shouldn't be any artifacts, only thing to keep in mind is that because the offset currently has a constant pixel size, when the camera gets too far away, the rim becomes much bigger proportionally. Some ddx/y maths should keep it constant tho

Neat! That makes sense, that sounds solvable. If you have two objects right next to each other, does it not sample a depth that's very similar, and then it doesn't get a highlight for one of the objects? That's what I was thinking of I guess this depends on how big the depth threshold is 🤔

... and maybe if they were *that* close and it forms such a single continuous shape, maybe it's okay if there is no individual highlight on them and they receive more of a highlight as a whole?