World Space (VR) Dithered transparency?

Hey all, I’d recently been shown a neat dithered transparency shader:

This is really great, and basically exactly what I want to use, however I’m making a title in VR, and the Dither node is screen based.

is there a way to set up a world-based dither pattern that doesn’t change when you move your head?

Yes, there is. But it requires a 3D noise / pattern, which Unity does not provide any nodes for. Or you can try more advanced mappings of the 2D noise on to surfaces. Even if you do use a 3D noise, you probably want to find a way to try to keep it mostly constant sized in screen space, which requires even more work, but is doable.

https://twitter.com/bgolus/status/834825069624823808?s=20

2 Likes

…Why did I just know I’d have to return to the Obra Dinn at some point?

Thanks for the heads up. :slight_smile:

Lucas Pope doesn’t exactly post any code examples of what he’s doing for the noise, but it sounds like it was fairly janky. Also he’s if you do more than rotate the dithering doesn’t stick to the surface. It’s only stable in rotation. Not perfectly applicable.

Depending on exactly what look you’re going for, a triplanar projection of that Bayer pattern + that constant size example code I posted might be a reasonable solution.

Any chance of a version of that constant size shader for Shadergraph? I’m not exactly a tech artist. ^_^;;

Nope!

But all of the functions and operations used in the shader can be directly mapped to shader graph nodes.

Wait, Nevermind, I got it!

The big clue was the triplanar projection.

Here’s the node graph for anyone interested!

I grabbed the Blue noise texture from the collection available here:
http://momentsingraphics.de/BlueNoise.html

Thanks, bgolus!

That’ll get you the triplanar noise, but won’t keep it constant sized.

This is true. I’ll see if I can’t talk to a friend about the other half of the shader :slight_smile:

Did you finish it? I’m also doing it for a VR project and I’m trying to figure out how to finish it

Nevermind I got it working, this is the part that was left (making the value of “Opacity” change depending on the distance from the eye to the surface)

I’m looking for something somewhere between world space and screen space. I like the way screen space dithering looks, but in VR, it tilts with your head depending on the angle of the headset.

What I’m after is a way to retain screen space dithering (the dither pattern is a constant size no matter how near or far the object is), but somehow axis-locked to world coordinates?

Can anyone recommend an approach to achieve this? Thank you!

I got one that works pretty well but it’s not good for most games since it’s made very specifically for the type of graphics I use as well as only being used for transparency. The way this shader works is by getting the position of the camera (through a scripts since otherwise it would be different for each eye and your head would hurt after a bit since each eye would get a different value of the effect) and a texture of a noise or a patter (I sometimes use a checkboard of squares, each of them with a random value of grey, as well as tiled noises for more organic effects) which is applied as any triplanar material would be applied. Now we make it so that the shaders calculates the distance between the point in the screen and the camera location, and sums/substracts from the triplanar transparency. We clamp those values and we get an effect of objects becoming invisible when they are further from a certain distance, or the inverse, and they become transparent when the camera approaches.

If you want a different effect, you can simply ditch the camera position code or just give it a different functionality, such as changing the colors or making patterns appear as if it was comic print ink/ink jet printing

any chance you could share a screenshot of a graph?