-
-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Add material shader component to specify smooth lighting behavior - Allows much easier composition of smooth lighting/material shader effects, and potentially gives backends the option to specialize shaders on the complexity of shader lighting - Pack fog, cutout, and light into a single uint
- Loading branch information
Showing
20 changed files
with
132 additions
and
19 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
common/src/api/java/dev/engine_room/flywheel/api/material/LightShader.java
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,11 @@ | ||
package dev.engine_room.flywheel.api.material; | ||
|
||
import dev.engine_room.flywheel.api.internal.FlwApiLink; | ||
import dev.engine_room.flywheel.api.registry.Registry; | ||
import net.minecraft.resources.ResourceLocation; | ||
|
||
public interface LightShader { | ||
Registry<LightShader> REGISTRY = FlwApiLink.INSTANCE.createRegistry(); | ||
|
||
ResourceLocation source(); | ||
} |
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
1 change: 1 addition & 0 deletions
1
common/src/backend/resources/assets/flywheel/flywheel/internal/components_header.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,3 +1,4 @@ | ||
uint _flw_uberMaterialFragmentIndex; | ||
uint _flw_uberFogIndex; | ||
uint _flw_uberCutoutIndex; | ||
uint _flw_uberLightIndex; |
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
19 changes: 19 additions & 0 deletions
19
common/src/lib/java/dev/engine_room/flywheel/lib/material/LightShaders.java
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,19 @@ | ||
package dev.engine_room.flywheel.lib.material; | ||
|
||
import org.jetbrains.annotations.ApiStatus; | ||
|
||
import dev.engine_room.flywheel.api.Flywheel; | ||
import dev.engine_room.flywheel.api.material.LightShader; | ||
|
||
public class LightShaders { | ||
public static final LightShader SMOOTH_WHEN_EMBEDDED = LightShader.REGISTRY.registerAndGet(new SimpleLightShader(Flywheel.rl("light/smooth_when_embedded.glsl"))); | ||
public static final LightShader SMOOTH = LightShader.REGISTRY.registerAndGet(new SimpleLightShader(Flywheel.rl("light/smooth.glsl"))); | ||
public static final LightShader FLAT = LightShader.REGISTRY.registerAndGet(new SimpleLightShader(Flywheel.rl("light/flat.glsl"))); | ||
|
||
private LightShaders() { | ||
} | ||
|
||
@ApiStatus.Internal | ||
public static void init() { | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
common/src/lib/java/dev/engine_room/flywheel/lib/material/SimpleLightShader.java
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 @@ | ||
package dev.engine_room.flywheel.lib.material; | ||
|
||
import dev.engine_room.flywheel.api.material.LightShader; | ||
import net.minecraft.resources.ResourceLocation; | ||
|
||
public record SimpleLightShader(@Override ResourceLocation source) implements LightShader { | ||
} |
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/light/flat.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,6 @@ | ||
void flw_shaderLight() { | ||
vec2 embeddedLight; | ||
if (flw_lightFetch(ivec3(floor(flw_vertexPos.xyz)), embeddedLight)) { | ||
flw_fragLight = max(flw_fragLight, embeddedLight); | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
common/src/lib/resources/assets/flywheel/flywheel/light/smooth.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,6 @@ | ||
void flw_shaderLight() { | ||
vec2 embeddedLight; | ||
if (flw_light(flw_vertexPos.xyz, flw_vertexNormal, embeddedLight)) { | ||
flw_fragLight = max(flw_fragLight, embeddedLight); | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
common/src/lib/resources/assets/flywheel/flywheel/light/smooth_when_embedded.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,8 @@ | ||
void flw_shaderLight() { | ||
#ifdef FLW_EMBEDDED | ||
vec2 embeddedLight; | ||
if (flw_light(flw_vertexPos.xyz, flw_vertexNormal, embeddedLight)) { | ||
flw_fragLight = max(flw_fragLight, embeddedLight); | ||
} | ||
#endif | ||
} |
6 changes: 0 additions & 6 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,8 +1,2 @@ | ||
void flw_materialFragment() { | ||
#ifdef FLW_EMBEDDED | ||
vec2 embeddedLight; | ||
if (flw_light(flw_vertexPos.xyz, flw_vertexNormal, 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