Search Unity

Question World Space (VR) Dithered transparency?

Discussion in 'Shaders' started by NemesisWarlock, Apr 22, 2021.

  1. NemesisWarlock

    NemesisWarlock

    Joined:
    Jan 21, 2017
    Posts:
    141
    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?
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,352
    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
     
    Radivarig and Invertex like this.
  3. NemesisWarlock

    NemesisWarlock

    Joined:
    Jan 21, 2017
    Posts:
    141
    ....Why did I just *know* I'd have to return to the Obra Dinn at some point?

    Thanks for the heads up. :)
     
  4. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,352
    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.
     
  5. NemesisWarlock

    NemesisWarlock

    Joined:
    Jan 21, 2017
    Posts:
    141
    Any chance of a version of that constant size shader for Shadergraph? I'm not exactly a tech artist. ^_^;;
     
  6. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,352
    Nope!

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

    NemesisWarlock

    Joined:
    Jan 21, 2017
    Posts:
    141
    Wait, Nevermind, I got it!

    The big clue was the triplanar projection.

    Here's the node graph for anyone interested!

    upload_2021-4-23_11-46-7.png

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



    Thanks, bgolus!
     
  8. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,352
    That’ll get you the triplanar noise, but won’t keep it constant sized.
     
  9. NemesisWarlock

    NemesisWarlock

    Joined:
    Jan 21, 2017
    Posts:
    141
    This is true. I'll see if I can't talk to a friend about the other half of the shader :)
     
  10. NestorVG

    NestorVG

    Joined:
    Feb 12, 2019
    Posts:
    35
    Did you finish it? I'm also doing it for a VR project and I'm trying to figure out how to finish it
     
  11. NestorVG

    NestorVG

    Joined:
    Feb 12, 2019
    Posts:
    35
    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)

    upload_2023-2-27_1-45-29.png