Search Unity

Color bending on custom smoke shader

Discussion in 'Universal Render Pipeline' started by peaj_metric, Dec 3, 2019.

  1. peaj_metric

    peaj_metric

    Joined:
    Sep 15, 2014
    Posts:
    146
    I built a custom raymarching shader for a smoke effect which looks fine (with little artifacts) in the legacy RP:


    But in URP it has extreme color bending artifacts:


    I first thought it was connected to the color space as switching to Gamma space in URP reduces the problem a bit but switching to Linear in the lagacy pipeline didnt make it any worse.

    Side question: Does anybody know in which color space 3D textures are being stored or if it can be manually set anywhere?

    I am using R8_UNorm 3D textures btw.

    Why does the same shader that works in lRP produce these artifacts URP?

    Thanks!
     

    Attached Files:

  2. Olmi

    Olmi

    Joined:
    Nov 29, 2012
    Posts:
    1,553
    Hi,

    About your side question: I think Texture3D is linear and if you set your pixels when project is in Linear mode, they would be linear. I'm not sure though. But as there's no color space flag like Texture2D has, it's hard to know. Documentation doesn't say anything about that either. Anyway, if someone knows better I'd be interested to know too.
    Btw, I imagine you would be using RenderTexture3D if you're rendering some raymarched things to textures?
     
  3. peaj_metric

    peaj_metric

    Joined:
    Sep 15, 2014
    Posts:
    146
    I created a small test left is a 2DTexture from PNG and right a 3DTexture both generated from the same noise shader:
    Gamma: 2D 3D
    colorSpace_gamma.png
    Linear: 2D (sRGB) 3D
    colorSpace_linear.png
    The 2D texture in linear space has the sRGB flag set. Otherwise it looks like the right (3D) one.
    I guess unity automatically saves PNGs in sRGB?
    If that is true it seems like the 3D textures are stored in sRGB too which would be a problem.
     
  4. peaj_metric

    peaj_metric

    Joined:
    Sep 15, 2014
    Posts:
    146
    Yes but its the other way around. I am raymarching through a 3D texture which has been generated from a noise shader.
    And I am aware that these artifacts might be caused by the marching steps but then again it doesnt make sense that there is a difference between lRP and URP with the same stap count (which is 128 btw)