Search Unity

  1. Calling all beginners! Join the FPS Beginners Mods Challenge until December 13.
    Dismiss Notice
  2. It's Cyber Week at the Asset Store!
    Dismiss Notice

PBS in Unity 5.0 how does it affect current shader paradigm?

Discussion in 'Shaders' started by garrettstrobel, Jul 30, 2014.

  1. garrettstrobel

    garrettstrobel

    Joined:
    Dec 25, 2013
    Posts:
    6
    Hello All,
    I am very new to the idea of developing shaders in Unity. I am wondering if it is worth my time now learning what is out there now as far as Surface Shader language, or if things will change so dramatically that it would be better to wait to learn shader programming after 5.0 release?

    I know people say it is always worth learning something but if it is all changing with PBS I would rather wait.

    Thanks for your input!
     
  2. Noisecrime

    Noisecrime

    Joined:
    Apr 7, 2010
    Posts:
    1,521
    Go ahead and start learning surface shaders as nothing will change with PBS.

    PBS is as far as I can tell simply going to be an 'uber-shader' that supports all the key points of physically based shading. As such it wont be a surface shader, but like any other shader that you want to support lighting and dynamic shadows it will use all the underlying structure of Unity shader design.

    What I mean is that Unity provides a structure that you must support in order for shaders to work as expected in forward rendering, deferred rendering, or adding dynamic shadows. Although you can also simply write vertex/fragment shaders too, but there its up to you to support multi-lights, shadows etc.This is accomplished through shader 'passes', so you'll have 'Base forward pass', 'Additive forward pass' (called for every additional pixel light that affects the mesh), 'Deferred Pass', 'Shadow Caster pass' & 'Shadow Collector pass'. On top of this you can have specific lighting functions in surface shaders and many other options.

    Essentially then Unity provides all the structure and many helper functions/macro's to let you write shaders, you can write them as straight vertex/pixel or as surface shaders. However for new users this can be very confusing as there is much to learn and absorb. Personally after 3-4 years of writing shaders I feel I've only recently begun to truly understand and appreciate ShaderLab/Surface Shaders.

    In terms of learning i'd recommend reading through the manual section on shaders several times. You should also grab the 'built-in-shader' code from here. Then read through the shaderlab subforum here to get an idea of what other people are doing and the issues they come across.

    Good luck.
     
    garrettstrobel likes this.
  3. metaleap

    metaleap

    Joined:
    Oct 3, 2012
    Posts:
    589
    PBS is essentially "just a better specular" (as opposed to the current Blinn-Phong specular). So I would not be surprised if Surface Shaders largely stay the same with the new "Standard Shader" being a Surface (uber) Shader with lots of #pragma multi_compile so they don't have to ship 20+ individual .shader files..

    There's 1000s of surface shaders on Asset Store and on the web, so I'd wager Surface Shaders won't be ditched and will continue to work the same way. All they'll do I reckon is add a more contemporary spec-lighting function ("PBS") and merge most of the various standard shader into a unified ubershader that'll be called "the Unity Standard Shader".
     
    garrettstrobel likes this.
  4. Daniel_Brauer

    Daniel_Brauer

    Unity Technologies

    Joined:
    Aug 11, 2006
    Posts:
    3,356
    What makes you say that?
     
  5. metaleap

    metaleap

    Joined:
    Oct 3, 2012
    Posts:
    589
    Old-school: Lambertian diffuse plus artist-controlled Blinn-Phong specular on select materials.

    New-school: "specular everywhere", now it's Lambertian diffuse plus (Blinn-Phong or GGX or Beckmann or Cook-Torrance) specular on all materials, instead of artist-controlled specularity+glossiness we have roughness+(reflectivity or metalness or refractive-index) artist-looked-up ;)

    By "better specular" I mean just that. The tweaking approach is better (we can look up physical specularity properties in a cheat-sheet), and the newer specular lobes other than Blinn-Phong have also (subjectively of course) "better-looking" properties (soft tail etc.) Also we get to skip the pow and the BRDF formulas are "better" as in consistent/predictable across many/all lighting conditions thanks to the ND*F*GV formula.

    But --- you can still implement all this in the established Surface Shader model with its "Lighting function" model.
     
    garrettstrobel likes this.
  6. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,539
    garrettstrobel likes this.
  7. garrettstrobel

    garrettstrobel

    Joined:
    Dec 25, 2013
    Posts:
    6
    Thank you for the detailed replies and clarifications!