-
-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Expose light in the shader api - flw_light - for builtin smooth lighting, faster than can be implemented by materials alone - flw_lightFetch - for materials that want to go crazy, access to raw data
- Loading branch information
Showing
16 changed files
with
74 additions
and
50 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
1 change: 1 addition & 0 deletions
1
common/src/backend/resources/assets/flywheel/flywheel/internal/api_impl.frag
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
7 changes: 7 additions & 0 deletions
7
common/src/backend/resources/assets/flywheel/flywheel/internal/api_impl.glsl
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,7 @@ | ||
/// Get the light at the given world position. | ||
/// This may be interpolated for smooth lighting. | ||
bool flw_light(vec3 worldPos, out vec2 light); | ||
|
||
/// Fetches the light value at the given block position. | ||
/// Returns false if the light for the given block is not available. | ||
bool flw_lightFetch(ivec3 blockPos, out vec2 light); |
1 change: 1 addition & 0 deletions
1
common/src/backend/resources/assets/flywheel/flywheel/internal/api_impl.vert
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
17 changes: 17 additions & 0 deletions
17
common/src/backend/resources/assets/flywheel/flywheel/internal/indirect/light.glsl
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,17 @@ | ||
#include "flywheel:internal/light_lut.glsl" | ||
|
||
layout(std430, binding = _FLW_LIGHT_LUT_BINDING) restrict readonly buffer LightLut { | ||
uint _flw_lightLut[]; | ||
}; | ||
|
||
layout(std430, binding = _FLW_LIGHT_SECTIONS_BINDING) restrict readonly buffer LightSections { | ||
uint _flw_lightSections[]; | ||
}; | ||
|
||
uint _flw_indexLut(uint index) { | ||
return _flw_lightLut[index]; | ||
} | ||
|
||
uint _flw_indexLight(uint index) { | ||
return _flw_lightSections[index]; | ||
} |
18 changes: 1 addition & 17 deletions
18
common/src/backend/resources/assets/flywheel/flywheel/internal/indirect/main.frag
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
12 changes: 12 additions & 0 deletions
12
common/src/backend/resources/assets/flywheel/flywheel/internal/instancing/light.glsl
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,12 @@ | ||
#include "flywheel:internal/light_lut.glsl" | ||
|
||
uniform usamplerBuffer _flw_lightLut; | ||
uniform usamplerBuffer _flw_lightSections; | ||
|
||
uint _flw_indexLut(uint index) { | ||
return texelFetch(_flw_lightLut, int(index)).r; | ||
} | ||
|
||
uint _flw_indexLight(uint index) { | ||
return texelFetch(_flw_lightSections, int(index)).r; | ||
} |
13 changes: 1 addition & 12 deletions
13
common/src/backend/resources/assets/flywheel/flywheel/internal/instancing/main.frag
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
1 change: 1 addition & 0 deletions
1
common/src/backend/resources/assets/flywheel/flywheel/internal/instancing/main.vert
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
6 changes: 6 additions & 0 deletions
6
common/src/lib/resources/assets/flywheel/flywheel/material/default.frag
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,2 +1,8 @@ | ||
void flw_materialFragment() { | ||
#ifdef FLW_EMBEDDED | ||
vec2 embeddedLight; | ||
if (flw_light(flw_vertexPos.xyz, embeddedLight)) { | ||
flw_fragLight = max(flw_fragLight, embeddedLight); | ||
} | ||
#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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/// Get the light at the given world position. | ||
/// This may be interpolated for smooth lighting. | ||
bool flw_light(vec3 worldPos, out vec2 light); | ||
|
||
/// Fetches the light value at the given block position. | ||
/// Returns false if the light for the given block is not available. | ||
bool flw_lightFetch(ivec3 blockPos, out vec2 light); |
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