diff --git a/src/main/java/net/wurstclient/hacks/LsdHack.java b/src/main/java/net/wurstclient/hacks/LsdHack.java index 6905c592e6..8f33242b0d 100644 --- a/src/main/java/net/wurstclient/hacks/LsdHack.java +++ b/src/main/java/net/wurstclient/hacks/LsdHack.java @@ -35,7 +35,7 @@ protected void onEnable() MC.gameRenderer.disablePostProcessor(); MC.gameRenderer - .loadPostProcessor(new Identifier("shaders/post/wobble.json")); + .loadPostProcessor(new Identifier("shaders/post/lsd.json")); } @Override diff --git a/src/main/resources/assets/minecraft/shaders/post/lsd.json b/src/main/resources/assets/minecraft/shaders/post/lsd.json new file mode 100644 index 0000000000..86849976f7 --- /dev/null +++ b/src/main/resources/assets/minecraft/shaders/post/lsd.json @@ -0,0 +1,17 @@ +{ + "targets": [ + "swap" + ], + "passes": [ + { + "name": "lsd", + "intarget": "minecraft:main", + "outtarget": "swap" + }, + { + "name": "blit", + "intarget": "swap", + "outtarget": "minecraft:main" + } + ] +} diff --git a/src/main/resources/assets/minecraft/shaders/program/lsd.fsh b/src/main/resources/assets/minecraft/shaders/program/lsd.fsh new file mode 100644 index 0000000000..b36e4854d1 --- /dev/null +++ b/src/main/resources/assets/minecraft/shaders/program/lsd.fsh @@ -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); +} diff --git a/src/main/resources/assets/minecraft/shaders/program/lsd.json b/src/main/resources/assets/minecraft/shaders/program/lsd.json new file mode 100644 index 0000000000..abc35e63d3 --- /dev/null +++ b/src/main/resources/assets/minecraft/shaders/program/lsd.json @@ -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 + ] + } + ] +}