Home Unity

Why does this Shader Forge BRDF shader not work?

I'm learning shader forge and am following a tutorial. The tutorial is a little out of date but I think I'm following it okay. 

Here's what I think I'm supposed to make:



Obviously it's not coming out correctly. I don't know why though. I did this tutorial about a year ago and it came out pretty much okay (there was one weird error but it looked close enough). 

This on the other hand looks nothing like what I see in the video. But the nodes look like they're set up the same. What am I missing?

I posted on the official Unity forum thread for Shader Forge and was directed to an alternative approach to doing a BRDF shader. This is what I came out with:

It looks more correct but it isn't set up to react to light attenuation, it doesn't show the full range of color in the ramp texture, and furthermore, I'm not really clear on why the first one didn't work? I want to make sure I'm understanding what I'm doing incorrectly, and not just copying what I see on forums. Any insight?

Replies

  • RyanB
    The falloff slider, which looks like it goes up to 11 (next time, just make 10 louder) is going through a power node into an append node.  The append node is constructing your UV coordinates so if you set the slider to anything higher than 1 it will tile in the U direction.  Set the max on the slider to 1 instead of 11 to limit the U values to between 0 and 1.


  • TheDonquixotic
    RyanB said:
    The falloff slider, which looks like it goes up to 11 (next time, just make 10 louder) is going through a power node into an append node.  The append node is constructing your UV coordinates so if you set the slider to anything higher than 1 it will tile in the U direction.  Set the max on the slider to 1 instead of 11 to limit the U values to between 0 and 1.


    Hahaha, oh. I guess the tutor was doing that as a joke, and I missed him changing it back. Nice, thanks!
  • TheDonquixotic
    Hmmm so it seems that it's actually more complicated than that. I followed your suggestion and that fixed it! But then I realized that the shading was view dependent, like specular, instead of like the diffuse type lighting I wanted. Then I realized I had fed the dot product of my normal and view direction into the exp instead of having it feed into the power alongside the exp node. I can't believe that I made so many silly mistakes there. The tutorial is kind of old, really the only Shader Forge tutorial I could find and the set up is all backwards so sometimes it sparks some dyslexia for me. 

    Anyway it's working now mostly! 

    Her'es what it should look like: 


    The only remaining problem is that the shading seems mirrored from the center of the sphere.... not sure why. I've tried checking all the dot products but they're all set to positive. So what could be causing that? 

    The one I found on the Unity forum uses half view direction instead of view direction, but that shouldn't be the issue since view direction is sampled for spectacular/rim lighting not for shading. Anyone have a clue why it's doing this?
Sign In or Register to comment.