Physically based shading related code has been refactored in
Unity 5.5 (files UnityStandardBRDF.cginc
and so on). In most
cases this does not affect your shader code directly, unless
you are manually calling some functions directly. Notable
changes are listed below.
There are now functions to convert between smoothness,
roughness and perceptual roughness:
PerceptualRoughnessToRoughness
,
RoughnessToPerceptualRoughness
, SmoothnessToRoughness
,
RoughnessToSmoothness
.
The visibility term in UnityStandardBRDF.cginc
takes roughness
and not perceptualRoughness
.
In older versions of Unity, it was possible to do a remapping with Marmoset roughness. With the move to GGX it no longer matches, and UNITY_GLOSS_MATCHES_MARMOSET_TOOLBAG2
definition and associated code has been removed.
All reads and writes into the Gbuffer should go through new functions UnityStandardDataToGbuffer
/ UnityStandardDataFromGbuffer
.
Your shader code should call UnityGlossyEnvironmentSetup()
to initialize a Unity_GlossyEnvironmentData
struct instead of doing it manually.
The roughness
variable of Unity_GlossyEnvironmentData
is actually “perceptual roughness” but it hasn’t been renamed to avoid errors with existing shader code. Note: UnityGlossyEnvironmentSetup
takes smoothness
as a parameter and calculates perceptual roughness.
The ndotl
variable value in UnityLight
is now calculated on the fly and any value written into the variable is ignored.
The UNITY_GI
macro is deprecated and should not be used anymore.
Unity 5.5 now handles DX9 half-pixel offset rasterization in the background, which means you no longer need to fix DX9 half-pixel issues either in shaders or in code. See more details in this blog post. If you use any of these checks in your code, they can now be removed:
The way Unity solves this now is by inserting half-pixel adjustment code into all vertex shaders that are being compiled. As a result, vertex shader constant