-
-
Notifications
You must be signed in to change notification settings - Fork 492
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
Showing
14 changed files
with
516 additions
and
73 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
59 changes: 59 additions & 0 deletions
59
src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/render/ModuleItemChams.kt
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,59 @@ | ||
/* | ||
* This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce) | ||
* | ||
* Copyright (c) 2015 - 2024 CCBlueX | ||
* | ||
* LiquidBounce is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* LiquidBounce is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
package net.ccbluex.liquidbounce.features.module.modules.render | ||
|
||
import net.ccbluex.liquidbounce.features.module.Category | ||
import net.ccbluex.liquidbounce.features.module.ClientModule | ||
import net.ccbluex.liquidbounce.injection.mixins.minecraft.render.MixinGameRenderer | ||
import net.ccbluex.liquidbounce.render.engine.Color4b | ||
import net.ccbluex.liquidbounce.render.shader.shaders.OutlineEffectShaderData | ||
|
||
/** | ||
* Module ItemChams | ||
* | ||
* Applies visual effects to your held items. | ||
* | ||
* [MixinGameRenderer] | ||
* | ||
* @author ccetl | ||
*/ | ||
object ModuleItemChams : ClientModule("ItemChams", Category.RENDER) { | ||
|
||
private val blendColor by color("BlendColor", Color4b(0, 64, 255, 186)) | ||
private val alpha by int("Alpha", 95, 1..255) | ||
private val glowColor by color("GlowColor", Color4b(0, 64, 255, 15)) | ||
private val layers by int("Layers", 3, 1..10) | ||
private val layerSize by float("LayerSize", 1.91f, 1f..5f) | ||
private val falloff by float("Falloff", 6.83f, 0f..20f) | ||
|
||
var active = false | ||
|
||
fun setData() { | ||
active = true | ||
with(OutlineEffectShaderData) { | ||
falloff = ModuleItemChams.falloff | ||
sampleMul = layerSize | ||
layerCount = layers | ||
glowColor = ModuleItemChams.glowColor | ||
blendColor = ModuleItemChams.blendColor | ||
alpha = ModuleItemChams.alpha / 255f | ||
} | ||
} | ||
|
||
} |
18 changes: 18 additions & 0 deletions
18
...otlin/net/ccbluex/liquidbounce/features/module/modules/world/nuker/mode/LegitNukerMode.kt
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
93 changes: 93 additions & 0 deletions
93
src/main/kotlin/net/ccbluex/liquidbounce/render/shader/CanvasShader.kt
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,93 @@ | ||
/* | ||
* This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce) | ||
* | ||
* Copyright (c) 2015 - 2024 CCBlueX | ||
* | ||
* LiquidBounce is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* LiquidBounce is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
package net.ccbluex.liquidbounce.render.shader | ||
|
||
import net.ccbluex.liquidbounce.utils.client.mc | ||
import net.minecraft.client.gl.GlUniform | ||
import net.minecraft.client.gl.VertexBuffer | ||
import net.minecraft.client.render.Tessellator | ||
import net.minecraft.client.render.VertexFormat | ||
import net.minecraft.client.render.VertexFormats | ||
import org.lwjgl.opengl.GL30 | ||
|
||
/** | ||
* A GLSL shader renderer. Takes a vertex and fragment shader and renders it to the canvas. | ||
* | ||
* Inspired from the GLSL Panorama Shader Mod | ||
* https://github.com/magistermaks/mod-glsl | ||
*/ | ||
class CanvasShader(vertex: String, fragment: String) : Shader(vertex, fragment) { | ||
|
||
private var canvas = ScalableCanvas() | ||
private var buffer = VertexBuffer(VertexBuffer.Usage.DYNAMIC) | ||
|
||
private val timeLocation: Int | ||
private val mouseLocation: Int | ||
private val resolutionLocation: Int | ||
|
||
private var time = 0f | ||
|
||
init { | ||
// bake buffer data | ||
val builder = Tessellator.getInstance() | ||
val buffer = builder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE_COLOR) | ||
buffer.vertex(-1.0f, -1.0f, 1.0f).texture(0f, 0f) | ||
.color(1f, 1f, 1f, 1f) | ||
buffer.vertex(1.0f, -1.0f, 1.0f).texture(1f, 0f) | ||
.color(1f, 1f, 1f, 1f) | ||
buffer.vertex(1.0f, 1.0f, 1.0f).texture(1f, 1f) | ||
.color(1f, 1f, 1f, 1f) | ||
buffer.vertex(-1.0f, 1.0f, 1.0f).texture(0f, 1f) | ||
.color(1f, 1f, 1f, 1f) | ||
|
||
this.buffer.bind() | ||
this.buffer.upload(buffer.end()) | ||
VertexBuffer.unbind() | ||
|
||
// get uniform pointers | ||
timeLocation = GlUniform.getUniformLocation(program, "time") | ||
mouseLocation = GlUniform.getUniformLocation(program, "mouse") | ||
resolutionLocation = GlUniform.getUniformLocation(program, "resolution") | ||
} | ||
|
||
fun draw(mouseX: Int, mouseY: Int, delta: Float) { | ||
super.use() | ||
|
||
canvas.resize(mc.window.framebufferWidth, mc.window.framebufferHeight) | ||
canvas.write() | ||
|
||
// update uniforms | ||
GL30.glUniform1f(timeLocation, time) | ||
time += (delta / 10f) | ||
GL30.glUniform2f(mouseLocation, mouseX.toFloat(), mouseY.toFloat()) | ||
GL30.glUniform2f(resolutionLocation, canvas.width().toFloat(), canvas.height().toFloat()) | ||
|
||
// draw | ||
buffer.bind() | ||
buffer.draw() | ||
canvas.blit(buffer) | ||
} | ||
|
||
override fun close() { | ||
super.close() | ||
buffer.close() | ||
canvas.close() | ||
} | ||
|
||
} |
129 changes: 129 additions & 0 deletions
129
src/main/kotlin/net/ccbluex/liquidbounce/render/shader/FramebufferShader.kt
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,129 @@ | ||
/* | ||
* This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce) | ||
* | ||
* Copyright (c) 2015 - 2024 CCBlueX | ||
* | ||
* LiquidBounce is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* LiquidBounce is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
package net.ccbluex.liquidbounce.render.shader | ||
|
||
import com.mojang.blaze3d.platform.GlStateManager | ||
import com.mojang.blaze3d.systems.RenderSystem | ||
import net.ccbluex.liquidbounce.features.module.MinecraftShortcuts | ||
import net.minecraft.client.gl.SimpleFramebuffer | ||
import net.minecraft.client.gl.VertexBuffer | ||
import net.minecraft.client.render.Tessellator | ||
import net.minecraft.client.render.VertexFormat | ||
import net.minecraft.client.render.VertexFormats | ||
import org.lwjgl.opengl.GL11 | ||
import org.lwjgl.opengl.GL13 | ||
import java.io.Closeable | ||
|
||
/** | ||
* @author ccetl | ||
*/ | ||
open class FramebufferShader(vararg val shaders: Shader) : MinecraftShortcuts, Closeable { | ||
|
||
private val framebuffers = mutableListOf<SimpleFramebuffer>() | ||
private var buffer = VertexBuffer(VertexBuffer.Usage.DYNAMIC) | ||
|
||
init { | ||
val width = mc.window.framebufferWidth | ||
val height = mc.window.framebufferHeight | ||
shaders.forEach { _ -> | ||
val framebuffer = SimpleFramebuffer(width, height, false, false) | ||
framebuffer.setClearColor(0f, 0f, 0f, 0f) | ||
framebuffers.add(framebuffer) | ||
} | ||
|
||
val builder = Tessellator.getInstance() | ||
val bufferBuilder = builder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE) | ||
bufferBuilder.vertex(-1f, -1f, 0f).texture(0f, 0f) | ||
bufferBuilder.vertex(1f, -1f, 0f).texture(1f, 0f) | ||
bufferBuilder.vertex(1f, 1f, 0f).texture(1f, 1f) | ||
bufferBuilder.vertex(-1f, 1f, 0f).texture(0f, 1f) | ||
buffer.bind() | ||
buffer.upload(bufferBuilder.end()) | ||
VertexBuffer.unbind() | ||
} | ||
|
||
fun prepare() { | ||
val width = mc.window.framebufferWidth | ||
val height = mc.window.framebufferHeight | ||
framebuffers.forEach { | ||
if (it.textureWidth != width || it.textureHeight != height) { | ||
it.resize(width, height, false) | ||
} | ||
} | ||
|
||
framebuffers[0].clear(false) | ||
framebuffers[0].beginWrite(true) | ||
} | ||
|
||
fun apply() { | ||
val active = GlStateManager._getActiveTexture() | ||
val alphaTest = GL11.glIsEnabled(GL11.GL_ALPHA_TEST) | ||
|
||
GL11.glDisable(GL11.GL_ALPHA_TEST) | ||
GlStateManager._bindTexture(0) | ||
|
||
RenderSystem.disableDepthTest() | ||
RenderSystem.enableBlend() | ||
RenderSystem.blendFunc(GlStateManager.SrcFactor.SRC_ALPHA, GlStateManager.DstFactor.ONE_MINUS_SRC_ALPHA) | ||
|
||
RenderSystem.setShaderColor(1f, 1f, 1f, 0f) | ||
shaders.forEachIndexed { i, shader -> | ||
val inputFramebuffer = framebuffers.getOrNull(i) ?: framebuffers.first() | ||
val outputFramebuffer = framebuffers.getOrNull(i + 1) | ||
|
||
outputFramebuffer?.clear(false) | ||
outputFramebuffer?.beginWrite(true) ?: mc.framebuffer.beginWrite(false) | ||
|
||
GlStateManager._activeTexture(GL13.GL_TEXTURE0 + i) | ||
GlStateManager._bindTexture(inputFramebuffer.colorAttachment) | ||
|
||
shader.use() | ||
|
||
buffer.bind() | ||
buffer.draw() | ||
VertexBuffer.unbind() | ||
|
||
shader.stop() | ||
} | ||
|
||
shaders.indices.forEach { | ||
GlStateManager._activeTexture(GL13.GL_TEXTURE0 + it) | ||
GlStateManager._bindTexture(0) | ||
} | ||
|
||
RenderSystem.enableDepthTest() | ||
GlStateManager._activeTexture(active) | ||
if (alphaTest) { | ||
GL11.glEnable(GL11.GL_ALPHA_TEST) | ||
} | ||
} | ||
|
||
fun render(drawAction: () -> Unit) { | ||
prepare() | ||
drawAction() | ||
apply() | ||
} | ||
|
||
override fun close() { | ||
shaders.forEach { it.close() } | ||
buffer.close() | ||
framebuffers.forEach { it.delete() } | ||
} | ||
|
||
} |
Oops, something went wrong.