-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8081 from Popov72/shadow-transparent
Add suport for soft transparent shadows
- Loading branch information
Showing
10 changed files
with
85 additions
and
14 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
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// from https://www.shadertoy.com/view/Mlt3z8 | ||
|
||
// Generates the basic 2x2 Bayer permutation matrix: | ||
// [1 2] | ||
// [3 0] | ||
// Expects _P in [0,1] | ||
float bayerDither2(vec2 _P) { | ||
return mod(2.0 * _P.y + _P.x + 1.0, 4.0); | ||
} | ||
|
||
// Generates the 4x4 matrix | ||
// Expects _P any pixel coordinate | ||
float bayerDither4(vec2 _P) { | ||
vec2 P1 = mod(_P, 2.0); // (P >> 0) & 1 | ||
vec2 P2 = floor(0.5 * mod(_P, 4.0)); // (P >> 1) & 1 | ||
return 4.0 * bayerDither2(P1) + bayerDither2(P2); | ||
} | ||
|
||
// Generates the 8x8 matrix | ||
float bayerDither8(vec2 _P) { | ||
vec2 P1 = mod(_P, 2.0); // (P >> 0) & 1 | ||
vec2 P2 = floor(0.5 * mod(_P, 4.0)); // (P >> 1) & 1 | ||
vec2 P4 = floor(0.25 * mod(_P, 8.0)); // (P >> 2) & 1 | ||
return 4.0 * (4.0 * bayerDither2(P1) + bayerDither2(P2)) + bayerDither2(P4); | ||
} |
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
3 changes: 3 additions & 0 deletions
3
src/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow.fx
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#if SM_SOFTTRANSPARENTSHADOW == 1 | ||
if ((bayerDither8(floor(mod(gl_FragCoord.xy, 8.0)))) / 64.0 >= softTransparentShadowSM * alpha) discard; | ||
#endif |
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