Skip to content

Commit

Permalink
fix: specular anti aliasing value (#773)
Browse files Browse the repository at this point in the history
* fix: specular anti aliasing
  • Loading branch information
zhuxudong authored Apr 29, 2022
1 parent e514013 commit fa94637
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/core/src/shaderlib/pbr/pbr_helper.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@ float computeSpecularOcclusion(float ambientOcclusion, float roughness, float do
}

float getAARoughnessFactor(vec3 normal) {
// Kaplanyan 2016, "Stable specular highlights"
// Tokuyoshi 2017, "Error Reduction and Simplification for Shading Anti-Aliasing"
// Tokuyoshi and Kaplanyan 2019, "Improved Geometric Specular Antialiasing"
#ifdef HAS_DERIVATIVES
vec3 dxy = max( abs(dFdx(normal)), abs(dFdy(normal)) );
return max( max(dxy.x, dxy.y), dxy.z );
return 0.04 + max( max(dxy.x, dxy.y), dxy.z );
#else
return 0.04;
#endif
Expand Down Expand Up @@ -117,4 +120,4 @@ void initMaterial(out Material material, const in Geometry geometry){
// direct + indirect
#include <brdf>
#include <direct_irradiance_frag_define>
#include <ibl_frag_define>
#include <ibl_frag_define>

0 comments on commit fa94637

Please sign in to comment.