Search Unity

Question is there a blur node?

Discussion in 'Shader Graph' started by LizardBrain451, Jun 24, 2019.

  1. LizardBrain451

    LizardBrain451

    Joined:
    Apr 22, 2019
    Posts:
    10
    I am looking to blur a node output in shader graph, so that I can use it as the mask for a Lerp. Something like the following illustrates my goal. I could try and preprocess the blur in an image application, However in my case, I am trying to stay procedural on this. However, I can't find any blur related nodes. I understand that a real time blur can be expensive, but I am just curious if such a node exists in shader graph?

    upload_2019-6-24_9-18-53.png
     
    Nobi-Knobi and sandolkakos like this.
  2. skilfuldriver

    skilfuldriver

    Joined:
    May 20, 2015
    Posts:
    19
    Yes it would be possible but expensive in a node as it'd have to process multiple offset samples.

    However if it's just a texture sample you want to blur you can use Sample Texture 2D LOD to get lower mip levels (although you'll get better results by blurring in your image app).
     
  3. LizardBrain451

    LizardBrain451

    Joined:
    Apr 22, 2019
    Posts:
    10
    In this case, it is just the binary output of a branch node (the star was for illustration purposes only). I am taking the output of a dot product and using it to create a vertex displacement transition. The transition is just really hard, due to the black and white nature of the result, so I am trying to figure out how to soften the edges between the black and white pixels. But mostly, I am just trying to learn what nodes are available.
     
  4. skilfuldriver

    skilfuldriver

    Joined:
    May 20, 2015
    Posts:
    19
    A dot product gives a range of values from -1 to 1, so you might be able to remap the values to get something more gradual and use in a lerp? This is also going to be simpler and more efficient so would generally be a better approach. What are you using as the input for the dot product?
     
  5. LizardBrain451

    LizardBrain451

    Joined:
    Apr 22, 2019
    Posts:
    10
    That's right.

    I was using the dot product range (-1 to 1) and comparing it to a solid value, such as zero, then branching to create a solid mask (if greater than 0 draw white, if less draw black), with a goal of blurring the result. However, I was able to cobble together something that works using smoothstep instead.

    However, I may also be experiencing a bug. I am using the normal vector (world) and a second vector to represent a lighting direction and getting the dot product, but when I do that I get a black result in the dot product preview regardless of vector value (see below)

    upload_2019-6-25_7-44-10.png

    instead of what I would expect, which should look something like this (snarfed from internet for example) ...

    upload_2019-6-25_8-1-22.png

    the resultant shader looks fine in the preview and in the scene view, so I might be experiencing a bug?

    I am running 2019.1.6 and HDRP
     

    Attached Files:

  6. unity_9eWJmHFApMYJkg

    unity_9eWJmHFApMYJkg

    Joined:
    Apr 23, 2018
    Posts:
    5
    Have you been able to fix this issue? I want to do the same. I'm looking to create a shader that blurs my sprite, possibly using the Sample Texture 2D LOD to lower the mip levels. But I really have no idea where to start or where to search for some examples.
     
  7. Olmi

    Olmi

    Joined:
    Nov 29, 2012
    Posts:
    1,553
    You could sample lower mipmap level using Sample Texture 2D LOD, and then create a Custom Function node with a single pass blur implementation. This will save quite a lot of computation I think.

    Start from manual on how to create a Custom Function node, it's explained there, then implement a blur.
     
    Lo-renzo likes this.
  8. P1105405

    P1105405

    Joined:
    Aug 30, 2014
    Posts:
    1
    Hello, I know this is late but this is for anyone looking for a shader graph method to blur a given sampled texture as I couldn't find any other resource on this matter.



    What is happening is you have a blur scale float value (In my case I'm using 1.0005) offsetting 4 unique UV's offsets X and Y values by that blur scale value, leaving one UV's offsets at 0, 0, then adding all the samples and dividing by 5 (the total amount of samples).

    From what I can tell this isn't very resource intensive and can be scaled up with additional sampling, and I'm sure this can be further improved.

    In this case I'm blurring two textures so ignore the bottom right corner unless you also want to blur multiple samples.



    Edit: Day 2, Indeed I already found a better way to do this, looks better and is more efficient.

    Same concept as before, just using a noise map to scramble the base textures UV. This blur is different as it has a noisy look to it. In this instance there are two sampled textures, one for an inner blur and one for an outer blur where you can control both the scale and opacity of the UV noise scramble.

    The values I am using:
    Tanline Blur Scale Inner = 500000
    Tanline Blur Amount Inner = 0.995
    Tanline Blur Scale Outer = 2000
    Tanline Blur Amount Outer = 0.995
     
    Last edited: Nov 24, 2022
  9. acnestis

    acnestis

    Joined:
    Sep 11, 2019
    Posts:
    15
    sandolkakos and TeramonGame like this.
  10. acnestis

    acnestis

    Joined:
    Sep 11, 2019
    Posts:
    15
    How about using white noise to offset UV coordinate?
    upload_2023-3-7_16-23-13.png

    OR Add a "digital dissolve" effect:
    upload_2023-3-7_16-23-18.png

    upload_2023-3-7_16-23-22.png
     
    ad9235 and fuzzy3d like this.
  11. Graigy1337

    Graigy1337

    Joined:
    Oct 26, 2019
    Posts:
    9

    Hey there, your pics arent loading are you able to repost the set up nodes?
    Thanks
     
  12. ad9235

    ad9235

    Joined:
    May 28, 2022
    Posts:
    1