-
-
Notifications
You must be signed in to change notification settings - Fork 420
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
00823b6
commit 840b121
Showing
4 changed files
with
164 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"targets": [ | ||
"swap" | ||
], | ||
"passes": [ | ||
{ | ||
"name": "lsd", | ||
"intarget": "minecraft:main", | ||
"outtarget": "swap" | ||
}, | ||
{ | ||
"name": "blit", | ||
"intarget": "swap", | ||
"outtarget": "minecraft:main" | ||
} | ||
] | ||
} |
60 changes: 60 additions & 0 deletions
60
src/main/resources/assets/minecraft/shaders/program/lsd.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,60 @@ | ||
#version 150 | ||
|
||
uniform sampler2D DiffuseSampler; | ||
|
||
in vec2 texCoord; | ||
in vec2 oneTexel; | ||
|
||
uniform vec2 InSize; | ||
|
||
uniform float Time; | ||
uniform vec2 Frequency; | ||
uniform vec2 WobbleAmount; | ||
|
||
out vec4 fragColor; | ||
|
||
vec3 hue(float h) | ||
{ | ||
float r = abs(h * 6.0 - 3.0) - 1.0; | ||
float g = 2.0 - abs(h * 6.0 - 2.0); | ||
float b = 2.0 - abs(h * 6.0 - 4.0); | ||
return clamp(vec3(r,g,b), 0.0, 1.0); | ||
} | ||
|
||
vec3 HSVtoRGB(vec3 hsv) { | ||
return ((hue(hsv.x) - 1.0) * hsv.y + 1.0) * hsv.z; | ||
} | ||
|
||
vec3 RGBtoHSV(vec3 rgb) { | ||
vec3 hsv = vec3(0.0); | ||
hsv.z = max(rgb.r, max(rgb.g, rgb.b)); | ||
float min = min(rgb.r, min(rgb.g, rgb.b)); | ||
float c = hsv.z - min; | ||
|
||
if (c != 0.0) | ||
{ | ||
hsv.y = c / hsv.z; | ||
vec3 delta = (hsv.z - rgb) / c; | ||
delta.rgb -= delta.brg; | ||
delta.rg += vec2(2.0, 4.0); | ||
if (rgb.r >= hsv.z) { | ||
hsv.x = delta.b; | ||
} else if (rgb.g >= hsv.z) { | ||
hsv.x = delta.r; | ||
} else { | ||
hsv.x = delta.g; | ||
} | ||
hsv.x = fract(hsv.x / 6.0); | ||
} | ||
return hsv; | ||
} | ||
|
||
void main() { | ||
float xOffset = sin(texCoord.y * Frequency.x + Time * 3.1415926535 * 2.0) * WobbleAmount.x; | ||
float yOffset = cos(texCoord.x * Frequency.y + Time * 3.1415926535 * 2.0) * WobbleAmount.y; | ||
vec2 offset = vec2(xOffset, yOffset); | ||
vec4 rgb = texture(DiffuseSampler, texCoord + offset); | ||
vec3 hsv = RGBtoHSV(rgb.rgb); | ||
hsv.x = fract(hsv.x + Time); | ||
fragColor = vec4(HSVtoRGB(hsv), 1.0); | ||
} |
86 changes: 86 additions & 0 deletions
86
src/main/resources/assets/minecraft/shaders/program/lsd.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,86 @@ | ||
{ | ||
"blend": { | ||
"func": "add", | ||
"srcrgb": "one", | ||
"dstrgb": "zero" | ||
}, | ||
"vertex": "sobel", | ||
"fragment": "lsd", | ||
"attributes": [ | ||
"Position" | ||
], | ||
"samplers": [ | ||
{ | ||
"name": "DiffuseSampler" | ||
} | ||
], | ||
"uniforms": [ | ||
{ | ||
"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": "InSize", | ||
"type": "float", | ||
"count": 2, | ||
"values": [ | ||
1.0, | ||
1.0 | ||
] | ||
}, | ||
{ | ||
"name": "OutSize", | ||
"type": "float", | ||
"count": 2, | ||
"values": [ | ||
1.0, | ||
1.0 | ||
] | ||
}, | ||
{ | ||
"name": "Time", | ||
"type": "float", | ||
"count": 1, | ||
"values": [ | ||
0.0 | ||
] | ||
}, | ||
{ | ||
"name": "Frequency", | ||
"type": "float", | ||
"count": 2, | ||
"values": [ | ||
512.0, | ||
288.0 | ||
] | ||
}, | ||
{ | ||
"name": "WobbleAmount", | ||
"type": "float", | ||
"count": 2, | ||
"values": [ | ||
0.002, | ||
0.002 | ||
] | ||
} | ||
] | ||
} |