-
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 of lit-shader generator, mostly related to the ambient lighting
- Loading branch information
Martin Valigursky
committed
Mar 5, 2025
1 parent
726c0bc
commit d2eb253
Showing
12 changed files
with
125 additions
and
162 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
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,52 @@ | ||
export default /* glsl */` | ||
#ifdef LIT_AMBIENT_SOURCE == AMBIENTSH | ||
uniform vec3 ambientSH[9]; | ||
#endif | ||
#if LIT_AMBIENT_SOURCE == ENVALATLAS | ||
#include "envAtlasPS" | ||
#ifndef ENV_ATLAS | ||
#define ENV_ATLAS | ||
uniform sampler2D texture_envAtlas; | ||
#endif | ||
#endif | ||
void addAmbient(vec3 worldNormal) { | ||
#ifdef LIT_AMBIENT_SOURCE == AMBIENTSH | ||
vec3 n = cubeMapRotate(worldNormal); | ||
vec3 color = | ||
ambientSH[0] + | ||
ambientSH[1] * n.x + | ||
ambientSH[2] * n.y + | ||
ambientSH[3] * n.z + | ||
ambientSH[4] * n.x * n.z + | ||
ambientSH[5] * n.z * n.y + | ||
ambientSH[6] * n.y * n.x + | ||
ambientSH[7] * (3.0 * n.z * n.z - 1.0) + | ||
ambientSH[8] * (n.x * n.x - n.y * n.y); | ||
dDiffuseLight += processEnvironment(max(color, vec3(0.0))); | ||
#endif | ||
#if LIT_AMBIENT_SOURCE == ENVALATLAS | ||
vec3 dir = normalize(cubeMapRotate(worldNormal) * vec3(-1.0, 1.0, 1.0)); | ||
vec2 uv = mapUv(toSphericalUv(dir), vec4(128.0, 256.0 + 128.0, 64.0, 32.0) / atlasSize); | ||
vec4 raw = texture2D(texture_envAtlas, uv); | ||
vec3 linear = {ambientDecode}(raw); | ||
dDiffuseLight += processEnvironment(linear); | ||
#endif | ||
#if LIT_AMBIENT_SOURCE == CONSTANT | ||
dDiffuseLight += light_globalAmbient; | ||
#endif | ||
} | ||
`; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.