Search Unity

Feedback Different result of sample texture in shadergraph and Lit master shader

Discussion in 'Shader Graph' started by sevelee, Jul 30, 2019.

  1. sevelee

    sevelee

    Joined:
    Apr 5, 2017
    Posts:
    25
    I am using Lit master node, But I find out that the sample result is different with the result of default Lit shader.
    In picture1, left is my shadergraph result where i use sample texture 2d to sample a basecolor map. Right is the same texture on HDRP default Lit shader.
    There is a obvious different that the mipmap level of sample is different, the right on (default Lit shader) is more clear and sharp.
    Is this a bug or I miss up some settings of shadergraph?
     

    Attached Files:

  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,348
    What happens if you don't assign a sampler state and let it use the default?

    I'm suspecting the default sampler state is either using a bias, or anisotropic filtering, and the one you've provided using the Sampler State node is just using Bilinear or Trilinear.
     
  3. sevelee

    sevelee

    Joined:
    Apr 5, 2017
    Posts:
    25
    I debuged with RenderDoc, default lit shader do a bias-1 when sample the texture. But I just didn't find any code in HDRP that they did a bias-1 when sampling.
     
  4. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,348
    It's likely set on the texture asset's properties itself. A sampler state can be setup with an innate mip bias, and setting a bias on the texture asset will make Unity set the bias for the default sampler state for each texture property. But if you use a Sampler State node instead of the one auto-setup for that texture it'll override settings, and there's no way to set a bias on a Sampler State node. You can't even use anisotropic filtering with Sampler State nodes, something else likely automatically enabled for most textures in HDRP.

    HDRP expectation of the use of temporal anti-aliasing makes the use of a default mip bias make sense, as to some degree you want to introduce some amount of aliasing in your rendering for TAA to do it's stuff to, otherwise you'll get a slightly more blurred image vs without. This is something UE4 does too AFAIK.