-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor specular occlusions shader chunks (#7400)
* Refactor specular occlusions shader chunks * lint * one additional improvement * final update * lint imports --------- Co-authored-by: Martin Valigursky <[email protected]>
- Loading branch information
1 parent
77e2718
commit bf80c95
Showing
9 changed files
with
77 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,41 @@ | ||
export default /* glsl */` | ||
uniform float material_occludeSpecularIntensity; | ||
void occludeSpecular(float gloss, float ao, vec3 worldNormal, vec3 viewDir) { | ||
// approximated specular occlusion from AO | ||
float specPow = exp2(gloss * 11.0); | ||
// http://research.tri-ace.com/Data/cedec2011_RealtimePBR_Implementation_e.pptx | ||
float specOcc = saturate(pow(dot(worldNormal, viewDir) + ao, 0.01*specPow) - 1.0 + ao); | ||
specOcc = mix(1.0, specOcc, material_occludeSpecularIntensity); | ||
dSpecularLight *= specOcc; | ||
dReflection *= specOcc; | ||
#ifdef LIT_SHEEN | ||
sSpecularLight *= specOcc; | ||
sReflection *= specOcc; | ||
#if LIT_OCCLUDE_SPECULAR != NONE | ||
#ifdef LIT_OCCLUDE_SPECULAR_FLOAT | ||
uniform float material_occludeSpecularIntensity; | ||
#endif | ||
#endif | ||
void occludeSpecular(float gloss, float ao, vec3 worldNormal, vec3 viewDir) { | ||
#if LIT_OCCLUDE_SPECULAR == AO | ||
#ifdef LIT_OCCLUDE_SPECULAR_FLOAT | ||
float specOcc = mix(1.0, ao, material_occludeSpecularIntensity); | ||
#else | ||
float specOcc = ao; | ||
#endif | ||
#endif | ||
#if LIT_OCCLUDE_SPECULAR == GLOSSDEPENDENT | ||
// approximated specular occlusion from AO | ||
// http://research.tri-ace.com/Data/cedec2011_RealtimePBR_Implementation_e.pptx | ||
float specPow = exp2(gloss * 11.0); | ||
float specOcc = saturate(pow(dot(worldNormal, viewDir) + ao, 0.01*specPow) - 1.0 + ao); | ||
#ifdef LIT_OCCLUDE_SPECULAR_FLOAT | ||
specOcc = mix(1.0, specOcc, material_occludeSpecularIntensity); | ||
#endif | ||
#endif | ||
#if LIT_OCCLUDE_SPECULAR != NONE | ||
dSpecularLight *= specOcc; | ||
dReflection *= specOcc; | ||
#ifdef LIT_SHEEN | ||
sSpecularLight *= specOcc; | ||
sReflection *= specOcc; | ||
#endif | ||
#endif | ||
} | ||
`; |
This file was deleted.
Oops, something went wrong.
11 changes: 0 additions & 11 deletions
11
src/scene/shader-lib/chunks/lit/frag/aoSpecOccConstSimple.js
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters