Skip to content

Commit 610b551

Browse files
emyfopsAvanatiker
andauthored
Ref: Removed shader language, correct floating origin in shaders and other fixes (#184)
This pull request aims to try to improve the monstruous rendering system by: - Removing the custom shader language. - Fixing rendering at large distances - Simplifying texture loading and handling And there may be more changes in the near future. Co-authored-by: Constructor <fractalminds@protonmail.com>
1 parent 5e9c94c commit 610b551

36 files changed

+223
-744
lines changed

src/main/kotlin/com/lambda/graphics/animation/Animation.kt

Lines changed: 0 additions & 72 deletions
This file was deleted.

src/main/kotlin/com/lambda/graphics/animation/AnimationTicker.kt

Lines changed: 0 additions & 28 deletions
This file was deleted.

src/main/kotlin/com/lambda/graphics/renderer/esp/ShapeDsl.kt

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,11 @@ package com.lambda.graphics.renderer.esp
1919

2020
import com.lambda.graphics.pipeline.VertexBuilder
2121
import com.lambda.graphics.renderer.esp.DirectionMask.hasDirection
22-
import com.lambda.graphics.renderer.esp.Treed.Companion.cameraPos
2322
import com.lambda.threading.runSafe
2423
import com.lambda.util.BlockUtils.blockState
2524
import com.lambda.util.extension.max
2625
import com.lambda.util.extension.min
2726
import com.lambda.util.extension.outlineShape
28-
import com.lambda.util.math.minus
2927
import net.minecraft.block.BlockState
3028
import net.minecraft.block.entity.BlockEntity
3129
import net.minecraft.entity.Entity
@@ -48,12 +46,11 @@ class ShapeBuilder(
4846
sides : Int = DirectionMask.ALL,
4947
) = faces.apply {
5048
val boxes = box.pair ?: return@apply
51-
val camera = cameraPos
5249

53-
val pos11 = boxes.first.min - camera
54-
val pos12 = boxes.first.max - camera
55-
val pos21 = boxes.second.min - camera
56-
val pos22 = boxes.second.max - camera
50+
val pos11 = boxes.first.min
51+
val pos12 = boxes.first.max
52+
val pos21 = boxes.second.min
53+
val pos22 = boxes.second.max
5754

5855
val blb by lazy { vertex { vec3(pos11.x, pos11.y, pos11.z).vec3(pos21.x, pos21.y, pos21.z).color(color) } }
5956
val blf by lazy { vertex { vec3(pos11.x, pos11.y, pos12.z).vec3(pos21.x, pos21.y, pos22.z).color(color) } }
@@ -79,9 +76,8 @@ class ShapeBuilder(
7976
topColor : Color = bottomColor,
8077
sides : Int = DirectionMask.ALL
8178
) = faces.apply {
82-
val camera = cameraPos
83-
val pos1 = box.min - camera
84-
val pos2 = box.max - camera
79+
val pos1 = box.min
80+
val pos2 = box.max
8581

8682
val blb by lazy { vertex { vec3(pos1.x, pos1.y, pos1.z).color(bottomColor) } }
8783
val blf by lazy { vertex { vec3(pos1.x, pos1.y, pos2.z).color(bottomColor) } }
@@ -156,12 +152,11 @@ class ShapeBuilder(
156152
mode : DirectionMask.OutlineMode = DirectionMask.OutlineMode.Or,
157153
) = edges.apply {
158154
val boxes = box.pair ?: return@apply
159-
val camera = cameraPos
160155

161-
val pos11 = boxes.first.min - camera
162-
val pos12 = boxes.first.max - camera
163-
val pos21 = boxes.second.min - camera
164-
val pos22 = boxes.second.max - camera
156+
val pos11 = boxes.first.min
157+
val pos12 = boxes.first.max
158+
val pos21 = boxes.second.min
159+
val pos22 = boxes.second.max
165160

166161
val blb by lazy { vertex { vec3(pos11.x, pos11.y, pos11.z).vec3(pos21.x, pos21.y, pos21.z).color(color) } }
167162
val blf by lazy { vertex { vec3(pos11.x, pos11.y, pos12.z).vec3(pos21.x, pos21.y, pos22.z).color(color) } }
@@ -203,9 +198,8 @@ class ShapeBuilder(
203198
sides : Int = DirectionMask.ALL,
204199
mode : DirectionMask.OutlineMode = DirectionMask.OutlineMode.Or,
205200
) = edges.apply {
206-
val camera = cameraPos
207-
val pos1 = box.min - camera
208-
val pos2 = box.max - camera
201+
val pos1 = box.min
202+
val pos2 = box.max
209203

210204
val blb by lazy { vertex { vec3(pos1.x, pos1.y, pos1.z).color(bottomColor) } }
211205
val blf by lazy { vertex { vec3(pos1.x, pos1.y, pos2.z).color(bottomColor) } }

src/main/kotlin/com/lambda/graphics/renderer/esp/Treed.kt

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,14 @@ import com.lambda.graphics.buffer.vertex.attributes.VertexMode
2323
import com.lambda.graphics.gl.GlStateUtils
2424
import com.lambda.graphics.pipeline.VertexBuilder
2525
import com.lambda.graphics.pipeline.VertexPipeline
26-
import com.lambda.graphics.shader.Shader.Companion.shader
26+
import com.lambda.graphics.shader.Shader
2727
import com.lambda.module.modules.client.StyleEditor
2828
import com.lambda.util.extension.partialTicks
29-
import com.lambda.util.math.minus
30-
import net.minecraft.util.math.Vec3d
3129

3230
/**
3331
* Open class for 3d rendering. It contains two pipelines, one for edges and the other for faces.
3432
*/
35-
open class Treed(static: Boolean) {
33+
open class Treed(private val static: Boolean) {
3634
val shader = if (static) staticMode.first else dynamicMode.first
3735

3836
val faces = VertexPipeline(VertexMode.Triangles, if (static) staticMode.second else dynamicMode.second)
@@ -48,8 +46,9 @@ open class Treed(static: Boolean) {
4846

4947
fun render() {
5048
shader.use()
51-
shader["u_TickDelta"] = mc.partialTicks
52-
shader["u_CameraLerp"] = cachedCameraPos - mc.gameRenderer.camera.pos
49+
50+
if (!static)
51+
shader["u_TickDelta"] = mc.partialTicks
5352

5453
GlStateUtils.withFaceCulling(faces::render)
5554
GlStateUtils.withLineWidth(StyleEditor.outlineWidth, edges::render)
@@ -76,14 +75,7 @@ open class Treed(static: Boolean) {
7675
object Dynamic : Treed(false)
7776

7877
companion object {
79-
private val staticMode = shader("renderer/box_static") to VertexAttrib.Group.STATIC_RENDERER
80-
private val dynamicMode = shader("renderer/box_dynamic") to VertexAttrib.Group.DYNAMIC_RENDERER
81-
82-
var cachedCameraPos: Vec3d = Vec3d.ZERO
83-
val cameraPos: Vec3d
84-
get() {
85-
cachedCameraPos = mc.gameRenderer.camera.pos
86-
return cachedCameraPos
87-
}
78+
private val staticMode = Shader("shaders/vertex/box_static.glsl", "shaders/fragment/pos_color.glsl") to VertexAttrib.Group.STATIC_RENDERER
79+
private val dynamicMode = Shader("shaders/vertex/box_dynamic.glsl", "shaders/fragment/pos_color.glsl") to VertexAttrib.Group.DYNAMIC_RENDERER
8880
}
8981
}

src/main/kotlin/com/lambda/graphics/renderer/gui/FontRenderer.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import com.lambda.graphics.pipeline.VertexBuilder
2222
import com.lambda.graphics.renderer.gui.font.core.GlyphInfo
2323
import com.lambda.graphics.renderer.gui.font.core.LambdaAtlas.get
2424
import com.lambda.graphics.renderer.gui.font.core.LambdaAtlas.height
25-
import com.lambda.graphics.shader.Shader.Companion.shader
2625
import com.lambda.graphics.texture.TextureOwner.bind
2726
import com.lambda.gui.components.ClickGuiLayout
2827
import com.lambda.module.modules.client.LambdaMoji
@@ -39,7 +38,7 @@ import java.awt.Color
3938
* Renders text and emoji glyphs using a shader-based font rendering system.
4039
* This class handles text and emoji rendering, shadow effects, and text scaling.
4140
*/
42-
object FontRenderer : AbstractGUIRenderer(VertexAttrib.Group.FONT, shader("renderer/font")) {
41+
/*object FontRenderer : AbstractGUIRenderer(VertexAttrib.Group.FONT, shader("renderer/font")) {
4342
private val chars get() = StyleEditor.textFont
4443
private val emojis get() = StyleEditor.emojiFont
4544
@@ -278,4 +277,4 @@ object FontRenderer : AbstractGUIRenderer(VertexAttrib.Group.FONT, shader("rende
278277
(color.blue * StyleEditor.shadowBrightness).toInt(),
279278
color.alpha
280279
)
281-
}
280+
}*/

src/main/kotlin/com/lambda/graphics/shader/ParsedShader.kt

Lines changed: 0 additions & 119 deletions
This file was deleted.

0 commit comments

Comments
 (0)