Skip to content

Commit

Permalink
Universal/always normalize normal (#2788)
Browse files Browse the repository at this point in the history
* Always normalize the normal in pixel shader.

* Update change log.

* Update mobile images to match desktop.

* Another update on mobile ref pics.

There's a mobile optimization for clear coat which is why desktop ref pics aren't compatible.

* Update Android ref pics.
  • Loading branch information
eh-unity committed Dec 15, 2020
1 parent 433f423 commit c658c22
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions com.unity.render-pipelines.universal/CHANGELOG.md
Expand Up @@ -41,6 +41,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Autodesk Interactive Shader Graph files and folders containing them were renamed. The new file paths do not have spaces.
- Changed shader keywords of main light shadow from toggling to enumerating.
- Moved `ForwardRendererData.postProcessData` into `UniversalRenderPipelineAsset.postProcessData` and made it optional. Builds do not include post-processing shaders and textures when `UniversalRenderPipelineAsset.postProcessData` is null.
- Always use "High" quality normals, which normalizes the normal in pixel shader. "Low" quality normals looked too much like a bug.
- Re-enabled implicit MSAA resolve to backbuffer on Metal MacOS.

### Fixed
Expand Down
Expand Up @@ -152,9 +152,12 @@ half OutputAlpha(half outputAlpha, half surfaceType = 0.0)
// 3) In fragment when using normal map, because mikktspace sets up non orthonormal basis.
// However we will try to balance performance vs quality here as also let users configure that as
// shader quality tiers.
// Low Quality Tier: Normalize either per-vertex or per-pixel depending if normalmap is sampled.
// Medium Quality Tier: Always normalize per-vertex. Normalize per-pixel only if using normal map
// High Quality Tier: Normalize in both vertex and pixel shaders.
// Low Quality Tier: Don't normalize per-vertex.
// Medium Quality Tier: Always normalize per-vertex.
// High Quality Tier: Always normalize per-vertex.
//
// Always normalize per-pixel.
// Too many bug like lighting quality issues otherwise.
real3 NormalizeNormalPerVertex(real3 normalWS)
{
#if defined(SHADER_QUALITY_LOW) && defined(_NORMALMAP)
Expand All @@ -166,11 +169,7 @@ real3 NormalizeNormalPerVertex(real3 normalWS)

real3 NormalizeNormalPerPixel(real3 normalWS)
{
#if defined(SHADER_QUALITY_HIGH) || defined(_NORMALMAP)
return normalize(normalWS);
#else
return normalWS;
#endif
return normalize(normalWS);
}


Expand Down

0 comments on commit c658c22

Please sign in to comment.