-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Bubble rim lighting based off of https://github.com/chrischrist…
- Loading branch information
Showing
11 changed files
with
156 additions
and
24 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
40 changes: 40 additions & 0 deletions
40
src/main/resources/assets/galacticraft/shaders/core/rendertype_bubble.fsh
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,40 @@ | ||
#version 150 | ||
|
||
#moj_import <fog.glsl> | ||
|
||
uniform sampler2D Sampler0; | ||
|
||
uniform vec2 ScreenSize; | ||
uniform vec4 ColorModulator; | ||
uniform float FogStart; | ||
uniform float FogEnd; | ||
|
||
in float vertexDistance; | ||
in vec4 vertexColor; | ||
in vec4 overlayColor; | ||
in vec2 texCoord0; | ||
in vec4 normal; | ||
in vec3 normal2; | ||
in vec3 viewDir; | ||
|
||
out vec4 fragColor; | ||
|
||
void main() { | ||
// - Rim lighting - | ||
vec3 viewAngle = normalize(-viewDir); | ||
|
||
// The more orthogonal the camera is to the fragment, the stronger the rim light. | ||
// abs() so that the back faces get treated the same as the front, giving a rim effect. | ||
float rimStrength = 1 - abs(dot(viewAngle, normal2)); // The more orthogonal, the stronger | ||
|
||
float rimFactor = pow(rimStrength, 6); // higher power = sharper rim light | ||
vec4 rim = vec4(rimFactor); | ||
|
||
vec4 color = texture(Sampler0, texCoord0); | ||
if (color.a < 0.1) { | ||
discard; | ||
} | ||
color *= vertexColor * ColorModulator; | ||
color.rgb = mix(overlayColor.rgb, color.rgb, overlayColor.a); | ||
fragColor = color + rim * linear_fog_fade(vertexDistance, FogStart, FogEnd); | ||
} |
32 changes: 32 additions & 0 deletions
32
src/main/resources/assets/galacticraft/shaders/core/rendertype_bubble.json
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,32 @@ | ||
{ | ||
"blend": { | ||
"func": "add", | ||
"srcrgb": "srcalpha", | ||
"dstrgb": "1-srcalpha" | ||
}, | ||
"vertex": "galacticraft:rendertype_bubble", | ||
"fragment": "galacticraft:rendertype_bubble", | ||
"attributes": [ | ||
"Position", | ||
"Color", | ||
"UV0", | ||
"UV1", | ||
"UV2", | ||
"Normal" | ||
], | ||
"samplers": [ | ||
{ "name": "Sampler0" }, | ||
{ "name": "Sampler1" }, | ||
{ "name": "Sampler2" } | ||
], | ||
"uniforms": [ | ||
{ "name": "ModelViewMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, | ||
{ "name": "ProjMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, | ||
{ "name": "ScreenSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] }, | ||
{ "name": "ColorModulator", "type": "float", "count": 4, "values": [ 1.0, 1.0, 1.0, 1.0 ] }, | ||
{ "name": "Light0_Direction", "type": "float", "count": 3, "values": [0.0, 0.0, 0.0] }, | ||
{ "name": "Light1_Direction", "type": "float", "count": 3, "values": [0.0, 0.0, 0.0] }, | ||
{ "name": "FogStart", "type": "float", "count": 1, "values": [ 0.0 ] }, | ||
{ "name": "FogEnd", "type": "float", "count": 1, "values": [ 1.0 ] } | ||
] | ||
} |
40 changes: 40 additions & 0 deletions
40
src/main/resources/assets/galacticraft/shaders/core/rendertype_bubble.vsh
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,40 @@ | ||
#version 150 | ||
|
||
#moj_import <light.glsl> | ||
|
||
in vec3 Position; | ||
in vec4 Color; | ||
in vec2 UV0; | ||
in ivec2 UV1; | ||
in ivec2 UV2; | ||
in vec3 Normal; | ||
|
||
uniform sampler2D Sampler1; | ||
uniform sampler2D Sampler2; | ||
|
||
uniform mat4 ModelViewMat; | ||
uniform mat4 ProjMat; | ||
|
||
uniform vec3 Light0_Direction; | ||
uniform vec3 Light1_Direction; | ||
|
||
out float vertexDistance; | ||
out vec4 vertexColor; | ||
out vec4 overlayColor; | ||
out vec2 texCoord0; | ||
out vec4 normal; | ||
out vec3 normal2; | ||
out vec3 viewDir; | ||
|
||
void main() { | ||
vec4 viewSpace = ModelViewMat * vec4(Position, 1.0); | ||
viewDir = vec3(viewSpace); | ||
normal2 = Normal; | ||
gl_Position = ProjMat * viewSpace; | ||
|
||
vertexDistance = length((ModelViewMat * vec4(Position, 1.0)).xyz); | ||
vertexColor = minecraft_mix_light(Light0_Direction, Light1_Direction, Normal, Color); | ||
overlayColor = texelFetch(Sampler1, UV1, 0); | ||
texCoord0 = UV0; | ||
normal = ProjMat * ModelViewMat * vec4(Normal, 0.0); | ||
} |