Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Resolved Why doesn't this Fake BRDF shader work?

Discussion in 'Shader Graph' started by R42_Leon, Jul 11, 2019.

  1. R42_Leon

    R42_Leon

    Joined:
    Feb 24, 2016
    Posts:
    25
    I'm trying to recreate the fake BRDF shader described in here and / or this video. This is my graph:

    upload_2019-7-11_11-52-35.png

    Everything looked pretty straightforward, I'm using a property with a reference to _WorldSpaceLightPos0 to get the light position, however when I plug the shader into an object I get incorrect results:

    upload_2019-7-11_11-54-6.png

    The dot product between the normals and the light direction seems to work fine as it generates the output I expect, however the dot product between the normals and the view direction seems to have something weird going on, as if I plug it directly to the color output I get overblown values:

    upload_2019-7-11_11-55-52.png

    While, judging from the article I linked earlier, I should expect a value between 0 and 1 (1 when directly facing the normal, 0 at right angles)

    Anyone could help me understand what's going on?
     
  2. R42_Leon

    R42_Leon

    Joined:
    Feb 24, 2016
    Posts:
    25
    Solved this myself: just needed to normalize the output of the view direction node.
     
    romanpapush likes this.
  3. bigobigobigo

    bigobigobigo

    Joined:
    Jul 31, 2017
    Posts:
    11
    Thanks man!
     
  4. Bovine

    Bovine

    Joined:
    Oct 13, 2010
    Posts:
    161
    This is very interesting. How can the best texture be created? The calculations look quite cheap.