From e2677d6ee5c3f74d5f547ca48bf6641f047a2a1e Mon Sep 17 00:00:00 2001 From: Linnea Gräf Date: Sun, 3 Nov 2024 01:24:24 +0100 Subject: 1.21.3 WIP --- .../firmament/shaders/code/rendertype_lines.fsh | 18 +++++++ .../firmament/shaders/code/rendertype_lines.json | 17 ++++++ .../firmament/shaders/code/rendertype_lines.vsh | 62 ++++++++++++++++++++++ .../shaders/core/firmament_rendertype_lines.fsh | 18 ------- .../shaders/core/firmament_rendertype_lines.json | 17 ------ .../shaders/core/firmament_rendertype_lines.vsh | 62 ---------------------- src/main/resources/firmament.accesswidener | 3 +- src/main/resources/firmament.mixins.json | 13 +++-- 8 files changed, 107 insertions(+), 103 deletions(-) create mode 100644 src/main/resources/assets/firmament/shaders/code/rendertype_lines.fsh create mode 100644 src/main/resources/assets/firmament/shaders/code/rendertype_lines.json create mode 100644 src/main/resources/assets/firmament/shaders/code/rendertype_lines.vsh delete mode 100644 src/main/resources/assets/minecraft/shaders/core/firmament_rendertype_lines.fsh delete mode 100644 src/main/resources/assets/minecraft/shaders/core/firmament_rendertype_lines.json delete mode 100644 src/main/resources/assets/minecraft/shaders/core/firmament_rendertype_lines.vsh (limited to 'src/main/resources') diff --git a/src/main/resources/assets/firmament/shaders/code/rendertype_lines.fsh b/src/main/resources/assets/firmament/shaders/code/rendertype_lines.fsh new file mode 100644 index 0000000..057f31f --- /dev/null +++ b/src/main/resources/assets/firmament/shaders/code/rendertype_lines.fsh @@ -0,0 +1,18 @@ +#version 150 + +#moj_import + +uniform vec4 ColorModulator; +uniform float FogStart; +uniform float FogEnd; +uniform vec4 FogColor; + +in float vertexDistance; +in vec4 vertexColor; + +out vec4 fragColor; + +void main() { + vec4 color = vertexColor * ColorModulator; + fragColor = linear_fog(color, vertexDistance, FogStart, FogEnd, FogColor); +} diff --git a/src/main/resources/assets/firmament/shaders/code/rendertype_lines.json b/src/main/resources/assets/firmament/shaders/code/rendertype_lines.json new file mode 100644 index 0000000..f276639 --- /dev/null +++ b/src/main/resources/assets/firmament/shaders/code/rendertype_lines.json @@ -0,0 +1,17 @@ +{ + "vertex": "firmament:rendertype_lines", + "fragment": "firmament:rendertype_lines", + "samplers": [ + ], + "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": "ColorModulator", "type": "float", "count": 4, "values": [ 1.0, 1.0, 1.0, 1.0 ] }, + { "name": "LineWidth", "type": "float", "count": 1, "values": [ 1.0 ] }, + { "name": "ScreenSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] }, + { "name": "FogStart", "type": "float", "count": 1, "values": [ 0.0 ] }, + { "name": "FogEnd", "type": "float", "count": 1, "values": [ 1.0 ] }, + { "name": "FogColor", "type": "float", "count": 4, "values": [ 0.0, 0.0, 0.0, 0.0 ] }, + { "name": "FogShape", "type": "int", "count": 1, "values": [ 0 ] } + ] +} diff --git a/src/main/resources/assets/firmament/shaders/code/rendertype_lines.vsh b/src/main/resources/assets/firmament/shaders/code/rendertype_lines.vsh new file mode 100644 index 0000000..b2d0f99 --- /dev/null +++ b/src/main/resources/assets/firmament/shaders/code/rendertype_lines.vsh @@ -0,0 +1,62 @@ +#version 150 + +#moj_import + +in vec3 Position; +in vec4 Color; +in vec3 Normal; + +uniform mat4 ModelViewMat; +uniform mat4 ProjMat; +uniform float LineWidth; +uniform vec2 ScreenSize; +uniform int FogShape; + +out float vertexDistance; +out vec4 vertexColor; + +const float VIEW_SHRINK = 1.0 - (1.0 / 256.0); +const mat4 VIEW_SCALE = mat4( + VIEW_SHRINK, 0.0, 0.0, 0.0, + 0.0, VIEW_SHRINK, 0.0, 0.0, + 0.0, 0.0, VIEW_SHRINK, 0.0, + 0.0, 0.0, 0.0, 1.0 +); + +void main() { + vec4 linePosStart = ProjMat * VIEW_SCALE * ModelViewMat * vec4(Position, 1.0); + vec4 linePosEnd = ProjMat * VIEW_SCALE * ModelViewMat * vec4(Position + Normal, 1.0); + + vec3 ndc1 = linePosStart.xyz / linePosStart.w; + vec3 ndc2 = linePosEnd.xyz / linePosEnd.w; + + bool linePosStartBehind = ndc1.z <= -1; + bool linePosEndBehind = ndc2.z <= -1; + + if ((linePosStartBehind && linePosEndBehind)) { + gl_Position = vec4(-2.0, -2.0, -2.0, 1.0); + return; // I don't care for these people + } + if ((linePosStartBehind || linePosEndBehind) && false) { + ndc1.z = 0.0; + ndc2.z = 0.0; + linePosStart.w = 1.0; + // TODO: use mx + b to find move the two coordinates around to extend lines + } + + vec2 lineScreenDirection = normalize((ndc2.xy - ndc1.xy) * ScreenSize); + vec2 lineOffset = vec2(-lineScreenDirection.y, lineScreenDirection.x) * LineWidth / ScreenSize; + + if (lineOffset.x < 0.0) { + lineOffset *= -1.0; + } + + if (gl_VertexID % 2 == 0) { + gl_Position = vec4((ndc1 + vec3(lineOffset, 0.0)) * linePosStart.w, linePosStart.w); + } else { + gl_Position = vec4((ndc1 - vec3(lineOffset, 0.0)) * linePosStart.w, linePosStart.w); + } + + vertexDistance = fog_distance(Position, FogShape); + vertexColor = Color; +} diff --git a/src/main/resources/assets/minecraft/shaders/core/firmament_rendertype_lines.fsh b/src/main/resources/assets/minecraft/shaders/core/firmament_rendertype_lines.fsh deleted file mode 100644 index 057f31f..0000000 --- a/src/main/resources/assets/minecraft/shaders/core/firmament_rendertype_lines.fsh +++ /dev/null @@ -1,18 +0,0 @@ -#version 150 - -#moj_import - -uniform vec4 ColorModulator; -uniform float FogStart; -uniform float FogEnd; -uniform vec4 FogColor; - -in float vertexDistance; -in vec4 vertexColor; - -out vec4 fragColor; - -void main() { - vec4 color = vertexColor * ColorModulator; - fragColor = linear_fog(color, vertexDistance, FogStart, FogEnd, FogColor); -} diff --git a/src/main/resources/assets/minecraft/shaders/core/firmament_rendertype_lines.json b/src/main/resources/assets/minecraft/shaders/core/firmament_rendertype_lines.json deleted file mode 100644 index 0828480..0000000 --- a/src/main/resources/assets/minecraft/shaders/core/firmament_rendertype_lines.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "vertex": "firmament_rendertype_lines", - "fragment": "firmament_rendertype_lines", - "samplers": [ - ], - "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": "ColorModulator", "type": "float", "count": 4, "values": [ 1.0, 1.0, 1.0, 1.0 ] }, - { "name": "LineWidth", "type": "float", "count": 1, "values": [ 1.0 ] }, - { "name": "ScreenSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] }, - { "name": "FogStart", "type": "float", "count": 1, "values": [ 0.0 ] }, - { "name": "FogEnd", "type": "float", "count": 1, "values": [ 1.0 ] }, - { "name": "FogColor", "type": "float", "count": 4, "values": [ 0.0, 0.0, 0.0, 0.0 ] }, - { "name": "FogShape", "type": "int", "count": 1, "values": [ 0 ] } - ] -} diff --git a/src/main/resources/assets/minecraft/shaders/core/firmament_rendertype_lines.vsh b/src/main/resources/assets/minecraft/shaders/core/firmament_rendertype_lines.vsh deleted file mode 100644 index b2d0f99..0000000 --- a/src/main/resources/assets/minecraft/shaders/core/firmament_rendertype_lines.vsh +++ /dev/null @@ -1,62 +0,0 @@ -#version 150 - -#moj_import - -in vec3 Position; -in vec4 Color; -in vec3 Normal; - -uniform mat4 ModelViewMat; -uniform mat4 ProjMat; -uniform float LineWidth; -uniform vec2 ScreenSize; -uniform int FogShape; - -out float vertexDistance; -out vec4 vertexColor; - -const float VIEW_SHRINK = 1.0 - (1.0 / 256.0); -const mat4 VIEW_SCALE = mat4( - VIEW_SHRINK, 0.0, 0.0, 0.0, - 0.0, VIEW_SHRINK, 0.0, 0.0, - 0.0, 0.0, VIEW_SHRINK, 0.0, - 0.0, 0.0, 0.0, 1.0 -); - -void main() { - vec4 linePosStart = ProjMat * VIEW_SCALE * ModelViewMat * vec4(Position, 1.0); - vec4 linePosEnd = ProjMat * VIEW_SCALE * ModelViewMat * vec4(Position + Normal, 1.0); - - vec3 ndc1 = linePosStart.xyz / linePosStart.w; - vec3 ndc2 = linePosEnd.xyz / linePosEnd.w; - - bool linePosStartBehind = ndc1.z <= -1; - bool linePosEndBehind = ndc2.z <= -1; - - if ((linePosStartBehind && linePosEndBehind)) { - gl_Position = vec4(-2.0, -2.0, -2.0, 1.0); - return; // I don't care for these people - } - if ((linePosStartBehind || linePosEndBehind) && false) { - ndc1.z = 0.0; - ndc2.z = 0.0; - linePosStart.w = 1.0; - // TODO: use mx + b to find move the two coordinates around to extend lines - } - - vec2 lineScreenDirection = normalize((ndc2.xy - ndc1.xy) * ScreenSize); - vec2 lineOffset = vec2(-lineScreenDirection.y, lineScreenDirection.x) * LineWidth / ScreenSize; - - if (lineOffset.x < 0.0) { - lineOffset *= -1.0; - } - - if (gl_VertexID % 2 == 0) { - gl_Position = vec4((ndc1 + vec3(lineOffset, 0.0)) * linePosStart.w, linePosStart.w); - } else { - gl_Position = vec4((ndc1 - vec3(lineOffset, 0.0)) * linePosStart.w, linePosStart.w); - } - - vertexDistance = fog_distance(Position, FogShape); - vertexColor = Color; -} diff --git a/src/main/resources/firmament.accesswidener b/src/main/resources/firmament.accesswidener index 60b31e3..5d64acc 100644 --- a/src/main/resources/firmament.accesswidener +++ b/src/main/resources/firmament.accesswidener @@ -5,6 +5,7 @@ accessible class net/minecraft/client/font/TextRenderer$Drawer accessible field net/minecraft/client/gui/hud/InGameHud SCOREBOARD_ENTRY_COMPARATOR Ljava/util/Comparator; accessible field net/minecraft/client/render/item/HeldItemRenderer itemRenderer Lnet/minecraft/client/render/item/ItemRenderer; +accessible field net/minecraft/client/render/item/ItemModels missingModelSupplier Ljava/util/function/Supplier; accessible class net/minecraft/client/render/model/json/ModelOverride$Deserializer accessible class net/minecraft/client/render/model/json/ModelOverrideList$BakedOverride @@ -14,7 +15,7 @@ accessible field net/minecraft/entity/passive/AbstractHorseEntity items Lnet/min accessible field net/minecraft/entity/passive/AbstractHorseEntity SADDLED_FLAG I accessible field net/minecraft/entity/passive/AbstractHorseEntity HORSE_FLAGS Lnet/minecraft/entity/data/TrackedData; accessible method net/minecraft/resource/NamespaceResourceManager loadMetadata (Lnet/minecraft/resource/InputSupplier;)Lnet/minecraft/resource/metadata/ResourceMetadata; -accessible method net/minecraft/client/gui/DrawContext drawTexturedQuad (Lnet/minecraft/util/Identifier;IIIIIFFFFFFFF)V +accessible method net/minecraft/client/gui/DrawContext drawTexturedQuad (Ljava/util/function/Function;Lnet/minecraft/util/Identifier;IIIIFFFFI)V mutable field net/minecraft/screen/slot/Slot x I mutable field net/minecraft/screen/slot/Slot y I diff --git a/src/main/resources/firmament.mixins.json b/src/main/resources/firmament.mixins.json index dbb8290..d78d124 100644 --- a/src/main/resources/firmament.mixins.json +++ b/src/main/resources/firmament.mixins.json @@ -1,7 +1,10 @@ { - "required": true, - "plugin": "moe.nea.firmament.init.MixinPlugin", - "package": "moe.nea.firmament.mixins", - "compatibilityLevel": "JAVA_21", - "refmap": "Firmament-refmap.json" + "required": true, + "plugin": "moe.nea.firmament.init.MixinPlugin", + "package": "moe.nea.firmament.mixins", + "compatibilityLevel": "JAVA_21", + "refmap": "Firmament-refmap.json", + "injectors": { + "defaultRequire": 1 + } } -- cgit