diff --git a/first_person_hand_models/assets/minecraft/items/mosin_rifle.json b/first_person_hand_models/assets/minecraft/items/mosin_rifle.json index c48a9ab..86e119e 100644 --- a/first_person_hand_models/assets/minecraft/items/mosin_rifle.json +++ b/first_person_hand_models/assets/minecraft/items/mosin_rifle.json @@ -1,27 +1,25 @@ { - "model": { - "type": "minecraft:composite", - "models": [ - { - "type": "minecraft:model", - "model": "minecraft:item/mosin_rifle" - }, - { - "type": "minecraft:special", - "base": "minecraft:item/left_hand", - "model": { - "type": "minecraft:head", - "kind": "player" - } - }, - { - "type": "minecraft:special", - "base": "minecraft:item/right_hand", - "model": { - "type": "minecraft:head", - "kind": "player" - } - } - ] - } + "model": { + "type": "minecraft:composite", + "models": [ + { + "type": "minecraft:model", + "model": "minecraft:item/mosin_rifle" + }, + { + "type": "minecraft:special", + "base": "minecraft:item/left_hand", + "model": { + "type": "minecraft:player_head" + } + }, + { + "type": "minecraft:special", + "base": "minecraft:item/right_hand", + "model": { + "type": "minecraft:player_head" + } + } + ] + } } \ No newline at end of file diff --git a/first_person_hand_models/assets/minecraft/models/item/mosin_rifle.json b/first_person_hand_models/assets/minecraft/models/item/mosin_rifle.json index f81b676..751e70b 100644 --- a/first_person_hand_models/assets/minecraft/models/item/mosin_rifle.json +++ b/first_person_hand_models/assets/minecraft/models/item/mosin_rifle.json @@ -1,4 +1,5 @@ { + "format_version": "1.21.11", "credit": "Made by Falanta", "texture_size": [64, 64], "textures": { @@ -60,7 +61,7 @@ "rotation": {"angle": 22.5, "axis": "x", "origin": [9.40352, 10.7, 7.5]}, "faces": { "east": {"uv": [1.5, 7.25, 2.5, 7.75], "texture": "#1"}, - "south": {"uv": [0, 0, 0.37, 0.25], "texture": "#missing"}, + "south": {"uv": [0, 0, 0.37, 0.25], "texture": "#1"}, "west": {"uv": [2.5, 7.25, 1.5, 7.75], "texture": "#1"}, "down": {"uv": [1.5, 7.75, 2.5, 8.5], "rotation": 90, "texture": "#1"} } @@ -92,70 +93,73 @@ "east": {"uv": [12.75, 0, 14, 1], "texture": "#1"}, "south": {"uv": [12.75, 0, 13, 1], "texture": "#1"}, "west": {"uv": [14, 0, 12.75, 1], "texture": "#1"}, - "up": {"uv": [0, 0, 0.125, 0.625], "texture": "#missing"}, + "up": {"uv": [0, 0, 0.125, 0.625], "texture": "#1"}, "down": {"uv": [12.75, 0.75, 14, 1], "rotation": 90, "texture": "#1"} } }, { - "from": [7.55264, 13.025, 12.375], - "to": [8.55264, 13.525, 14.875], + "from": [7.55264, 11.775, -9.625], + "to": [8.55264, 13.275, 6.375], "rotation": {"angle": 0, "axis": "y", "origin": [9.40352, 10.7, 7.5]}, "faces": { - "north": {"uv": [11.25, 1.25, 11.5, 0.75], "rotation": 90, "texture": "#1"}, - "east": {"uv": [12.5, 0.75, 11.25, 1], "texture": "#1"}, - "south": {"uv": [12.25, 0.75, 12.5, 1.25], "rotation": 90, "texture": "#1"}, - "west": {"uv": [11.25, 1, 12.5, 1.25], "texture": "#1"}, - "up": {"uv": [11.25, 0.75, 12.5, 1.25], "rotation": 90, "texture": "#1"}, - "down": {"uv": [0, 0, 0.25, 0.625], "texture": "#missing"} + "north": {"uv": [8, 14.5, 8.5, 15.25], "texture": "#1"}, + "east": {"uv": [0, 14.75, 8, 15.5], "texture": "#1"}, + "south": {"uv": [8, 15.25, 8.5, 16], "texture": "#1"}, + "west": {"uv": [8, 14.75, 0, 15.5], "texture": "#1"}, + "up": {"uv": [0, 14.25, 8, 14.75], "rotation": 90, "texture": "#1"}, + "down": {"uv": [0, 15.5, 8, 16], "rotation": 90, "texture": "#1"} } }, { - "from": [7.55264, 13.025, 7.375], - "to": [8.55264, 13.525, 10.375], + "from": [7.80264, 13.525, -12.625], + "to": [8.30264, 14.025, -12.125], "rotation": {"angle": 0, "axis": "y", "origin": [9.40352, 10.7, 7.5]}, "faces": { - "north": {"uv": [11, 1.75, 11.25, 1.25], "rotation": 90, "texture": "#1"}, - "east": {"uv": [12.5, 1.25, 11, 1.5], "texture": "#1"}, - "south": {"uv": [12.25, 1.25, 12.5, 1.75], "rotation": 90, "texture": "#1"}, - "west": {"uv": [11, 1.5, 12.5, 1.75], "texture": "#1"}, - "up": {"uv": [11, 1.25, 12.5, 1.75], "rotation": 90, "texture": "#1"}, - "down": {"uv": [0, 0, 0.25, 0.625], "texture": "#missing"} + "north": {"uv": [0, 0, 0, 0], "texture": "#1"}, + "east": {"uv": [0.5, 9.75, 0.75, 10], "texture": "#1"}, + "south": {"uv": [0, 0, 0, 0], "texture": "#1"}, + "west": {"uv": [0.5, 9.75, 0.75, 10], "texture": "#1"}, + "up": {"uv": [0.75, 9.75, 1, 10], "texture": "#1"}, + "down": {"uv": [1, 9.75, 1.25, 10], "texture": "#1"} } }, { - "from": [7.80264, 13.025, 10.375], - "to": [8.30264, 13.525, 12.375], + "from": [7.92764, 13.025, -12.625], + "to": [8.17764, 13.525, -12.125], "rotation": {"angle": 0, "axis": "y", "origin": [9.40352, 10.7, 7.5]}, "faces": { - "east": {"uv": [12.5, 0.5, 12.75, 1.5], "rotation": 90, "texture": "#1"}, - "west": {"uv": [12.5, 1.5, 12.75, 0.5], "rotation": 90, "texture": "#1"}, - "up": {"uv": [12.5, 0.5, 12.75, 1.5], "texture": "#1"} + "north": {"uv": [1.75, 9.75, 2, 10], "texture": "#1"}, + "east": {"uv": [1.25, 9.75, 1.5, 10], "texture": "#1"}, + "south": {"uv": [1.5, 9.75, 1.75, 10], "texture": "#1"}, + "west": {"uv": [1.25, 9.75, 1.5, 10], "texture": "#1"}, + "up": {"uv": [0, 0, 0, 0], "texture": "#1"}, + "down": {"uv": [0, 0, 0, 0], "texture": "#1"} } }, { - "from": [7.55264, 12.775, 14.875], - "to": [9.05264, 13.275, 16.875], + "from": [7.80264, 12.025, -10.625], + "to": [8.30264, 12.525, -9.625], "rotation": {"angle": 0, "axis": "y", "origin": [9.40352, 10.7, 7.5]}, "faces": { - "north": {"uv": [11.5, 0.75, 11.25, 0], "rotation": 90, "texture": "#1"}, - "east": {"uv": [12.25, 0, 11.25, 0.25], "texture": "#1"}, - "south": {"uv": [12, 0, 12.25, 0.75], "rotation": 90, "texture": "#1"}, - "west": {"uv": [11.25, 0.5, 12.25, 0.75], "texture": "#1"}, - "up": {"uv": [11.25, 0, 12.25, 0.75], "rotation": 90, "texture": "#1"}, - "down": {"uv": [12.25, 0, 11.25, 0.75], "rotation": 90, "texture": "#1"} + "north": {"uv": [0.25, 9.75, 0.5, 10], "texture": "#1"}, + "east": {"uv": [0, 9.75, 0.5, 10], "texture": "#1"}, + "south": {"uv": [0, 0, 0.125, 0.125], "texture": "#1"}, + "west": {"uv": [0.5, 9.75, 0, 10], "texture": "#1"}, + "up": {"uv": [0, 0, 0, 0], "texture": "#1"}, + "down": {"uv": [0, 9.75, 0.5, 10], "rotation": 90, "texture": "#1"} } }, { - "from": [9.05264, 12.775, 15.625], - "to": [10.55264, 13.275, 16.125], + "from": [7.80264, 12.525, -13.625], + "to": [8.30264, 13.025, -9.625], "rotation": {"angle": 0, "axis": "y", "origin": [9.40352, 10.7, 7.5]}, "faces": { - "north": {"uv": [15.5, 1.25, 14.75, 1.5], "texture": "#1"}, - "east": {"uv": [15.25, 1, 15.5, 1.25], "texture": "#1"}, - "south": {"uv": [14.75, 1.25, 15.5, 1.5], "texture": "#1"}, - "west": {"uv": [0, 0, 0.125, 0.125], "texture": "#missing"}, - "up": {"uv": [14.75, 1, 15.5, 1.25], "texture": "#1"}, - "down": {"uv": [14.75, 1.5, 15.5, 1.75], "texture": "#1"} + "north": {"uv": [2, 9.5, 2.25, 9.75], "texture": "#1"}, + "east": {"uv": [0, 9.5, 2, 9.75], "texture": "#1"}, + "south": {"uv": [0, 0, 0, 0], "texture": "#1"}, + "west": {"uv": [2, 9.5, 0, 9.75], "texture": "#1"}, + "up": {"uv": [2, 9.5, 0, 9.75], "rotation": 90, "texture": "#1"}, + "down": {"uv": [0, 9.5, 2, 9.75], "rotation": 90, "texture": "#1"} } }, { @@ -166,10 +170,24 @@ "north": {"uv": [15.5, 1, 15.75, 1.25], "texture": "#1"}, "east": {"uv": [15.75, 1.25, 16, 1.5], "texture": "#1"}, "south": {"uv": [15.5, 1, 15.75, 1.25], "texture": "#1"}, + "west": {"uv": [0, 0, 0, 0], "texture": "#1"}, "up": {"uv": [15.75, 1, 16, 1.25], "texture": "#1"}, "down": {"uv": [15.5, 1.25, 15.75, 1.5], "texture": "#1"} } }, + { + "from": [9.05264, 12.775, 15.625], + "to": [10.55264, 13.275, 16.125], + "rotation": {"angle": 0, "axis": "y", "origin": [9.40352, 10.7, 7.5]}, + "faces": { + "north": {"uv": [15.5, 1.25, 14.75, 1.5], "texture": "#1"}, + "east": {"uv": [15.25, 1, 15.5, 1.25], "texture": "#1"}, + "south": {"uv": [14.75, 1.25, 15.5, 1.5], "texture": "#1"}, + "west": {"uv": [0, 0, 0.125, 0.125], "texture": "#1"}, + "up": {"uv": [14.75, 1, 15.5, 1.25], "texture": "#1"}, + "down": {"uv": [14.75, 1.5, 15.5, 1.75], "texture": "#1"} + } + }, { "from": [7.55264, 13.525, 7.375], "to": [8.55264, 13.775, 8.375], @@ -179,109 +197,47 @@ "east": {"uv": [12, 1.75, 12.5, 2], "texture": "#1"}, "south": {"uv": [12.25, 1.75, 12.5, 2.25], "rotation": 90, "texture": "#1"}, "west": {"uv": [12, 2, 12.5, 2.25], "texture": "#1"}, - "up": {"uv": [12, 1.75, 12.5, 2.25], "rotation": 90, "texture": "#1"} - } - }, - { - "from": [7.55264, 12.525, 16.875], - "to": [8.55264, 13.525, 19.375], - "rotation": {"angle": 0, "axis": "y", "origin": [9.40352, 10.7, 7.5]}, - "faces": { - "north": {"uv": [14.25, 1.5, 14.75, 2], "texture": "#1"}, - "east": {"uv": [13, 1, 14.25, 1.5], "texture": "#1"}, - "south": {"uv": [14.25, 1, 14.75, 1.5], "texture": "#1"}, - "west": {"uv": [14.25, 1, 13, 1.5], "texture": "#1"}, - "up": {"uv": [13, 2, 14.25, 1.5], "rotation": 90, "texture": "#1"}, - "down": {"uv": [0, 0, 0.25, 0.625], "texture": "#missing"} - } - }, - { - "from": [7.80264, 11.095, 17.57], - "to": [8.30264, 9.995, 19.07], - "rotation": {"angle": 0, "axis": "y", "origin": [9.40352, 10.7, 7.5]}, - "faces": { - "north": {"uv": [13.75, 0.2, 14, 0.75], "rotation": 180, "texture": "#1"}, - "south": {"uv": [12.75, 0.2, 13, 0.75], "rotation": 180, "texture": "#1"}, - "up": {"uv": [13, 0.75, 13.75, 1], "rotation": 270, "texture": "#1"} + "up": {"uv": [12, 1.75, 12.5, 2.25], "rotation": 90, "texture": "#1"}, + "down": {"uv": [0, 0, 0, 0], "texture": "#1"} } }, { - "from": [8.05264, 10.125, 17.875], - "to": [8.05264, 11.125, 18.875], - "rotation": {"angle": 0, "axis": "y", "origin": [9.40352, 10.7, 7.5]}, - "faces": { - "east": {"uv": [12.25, 0, 12.75, 0.5], "texture": "#1"}, - "west": {"uv": [12.75, 0, 12.25, 0.5], "texture": "#1"} - } - }, - { - "from": [7.55264, 11.775, -9.625], - "to": [8.55264, 13.275, 6.375], - "rotation": {"angle": 0, "axis": "y", "origin": [9.40352, 10.7, 7.5]}, - "faces": { - "north": {"uv": [8, 14.5, 8.5, 15.25], "texture": "#1"}, - "east": {"uv": [0, 14.75, 8, 15.5], "texture": "#1"}, - "south": {"uv": [8, 15.25, 8.5, 16], "texture": "#1"}, - "west": {"uv": [8, 14.75, 0, 15.5], "texture": "#1"}, - "up": {"uv": [0, 14.25, 8, 14.75], "rotation": 90, "texture": "#1"}, - "down": {"uv": [0, 15.5, 8, 16], "rotation": 90, "texture": "#1"} - } - }, - { - "from": [7.80264, 12.525, -13.625], - "to": [8.30264, 13.025, -9.625], - "rotation": {"angle": 0, "axis": "y", "origin": [9.40352, 10.7, 7.5]}, - "faces": { - "north": {"uv": [2, 9.5, 2.25, 9.75], "texture": "#1"}, - "east": {"uv": [0, 9.5, 2, 9.75], "texture": "#1"}, - "west": {"uv": [2, 9.5, 0, 9.75], "texture": "#1"}, - "up": {"uv": [2, 9.5, 0, 9.75], "rotation": 90, "texture": "#1"}, - "down": {"uv": [0, 9.5, 2, 9.75], "rotation": 90, "texture": "#1"} - } - }, - { - "from": [7.80264, 12.025, -10.625], - "to": [8.30264, 12.525, -9.625], - "rotation": {"angle": 0, "axis": "y", "origin": [9.40352, 10.7, 7.5]}, - "faces": { - "north": {"uv": [0.25, 9.75, 0.5, 10], "texture": "#1"}, - "east": {"uv": [0, 9.75, 0.5, 10], "texture": "#1"}, - "south": {"uv": [0, 0, 0.125, 0.125], "texture": "#missing"}, - "west": {"uv": [0.5, 9.75, 0, 10], "texture": "#1"}, - "down": {"uv": [0, 9.75, 0.5, 10], "rotation": 90, "texture": "#1"} - } - }, - { - "from": [7.80264, 13.525, -12.625], - "to": [8.30264, 14.025, -12.125], + "from": [7.55264, 13.025, 7.375], + "to": [8.55264, 13.525, 10.375], "rotation": {"angle": 0, "axis": "y", "origin": [9.40352, 10.7, 7.5]}, "faces": { - "east": {"uv": [0.5, 9.75, 0.75, 10], "texture": "#1"}, - "west": {"uv": [0.5, 9.75, 0.75, 10], "texture": "#1"}, - "up": {"uv": [0.75, 9.75, 1, 10], "texture": "#1"}, - "down": {"uv": [1, 9.75, 1.25, 10], "texture": "#1"} + "north": {"uv": [11, 1.75, 11.25, 1.25], "rotation": 90, "texture": "#1"}, + "east": {"uv": [12.5, 1.25, 11, 1.5], "texture": "#1"}, + "south": {"uv": [12.25, 1.25, 12.5, 1.75], "rotation": 90, "texture": "#1"}, + "west": {"uv": [11, 1.5, 12.5, 1.75], "texture": "#1"}, + "up": {"uv": [11, 1.25, 12.5, 1.75], "rotation": 90, "texture": "#1"}, + "down": {"uv": [0, 0, 0.25, 0.625], "texture": "#1"} } }, { - "from": [7.80264, 14.025, -12.625], - "to": [8.30264, 13.525, -12.125], + "from": [7.55264, 13.025, 12.375], + "to": [8.55264, 13.525, 14.875], "rotation": {"angle": 0, "axis": "y", "origin": [9.40352, 10.7, 7.5]}, "faces": { - "east": {"uv": [0.5, 9.75, 0.75, 10], "texture": "#1"}, - "west": {"uv": [0.5, 9.75, 0.75, 10], "texture": "#1"}, - "up": {"uv": [1, 9.75, 1.25, 10], "texture": "#1"}, - "down": {"uv": [0.75, 9.75, 1, 10], "texture": "#1"} + "north": {"uv": [11.25, 1.25, 11.5, 0.75], "rotation": 90, "texture": "#1"}, + "east": {"uv": [12.5, 0.75, 11.25, 1], "texture": "#1"}, + "south": {"uv": [12.25, 0.75, 12.5, 1.25], "rotation": 90, "texture": "#1"}, + "west": {"uv": [11.25, 1, 12.5, 1.25], "texture": "#1"}, + "up": {"uv": [11.25, 0.75, 12.5, 1.25], "rotation": 90, "texture": "#1"}, + "down": {"uv": [0, 0, 0.25, 0.625], "texture": "#1"} } }, { - "from": [7.92764, 13.025, -12.625], - "to": [8.17764, 13.525, -12.125], + "from": [7.55264, 12.525, 16.875], + "to": [8.55264, 13.525, 19.375], "rotation": {"angle": 0, "axis": "y", "origin": [9.40352, 10.7, 7.5]}, "faces": { - "north": {"uv": [1.75, 9.75, 2, 10], "texture": "#1"}, - "east": {"uv": [1.25, 9.75, 1.5, 10], "texture": "#1"}, - "south": {"uv": [1.5, 9.75, 1.75, 10], "texture": "#1"}, - "west": {"uv": [1.25, 9.75, 1.5, 10], "texture": "#1"} + "north": {"uv": [14.25, 1.5, 14.75, 2], "texture": "#1"}, + "east": {"uv": [13, 1, 14.25, 1.5], "texture": "#1"}, + "south": {"uv": [14.25, 1, 14.75, 1.5], "texture": "#1"}, + "west": {"uv": [14.25, 1, 13, 1.5], "texture": "#1"}, + "up": {"uv": [13, 2, 14.25, 1.5], "rotation": 90, "texture": "#1"}, + "down": {"uv": [0, 0, 0.25, 0.625], "texture": "#1"} } } ], @@ -298,7 +254,7 @@ "translation": [-9, 0, -10] }, "firstperson_lefthand": { - "scale": [0, 0, 0] + "translation": [-9, 0, -10] }, "gui": { "rotation": [90, 45, -90], @@ -336,46 +292,34 @@ "children": [ 6, 7, - 8, - 9, - 10, - 11, - 12, { "name": "zatvor", "origin": [7.5, 0, 0], "color": 0, - "children": [13] - }, - 14, - 15, - 16, - 17 + "children": [] + } ] }, { "name": "stvol", "origin": [0, 0, 0], "color": 0, - "children": [18, 19, 20, 21, 22, 23] + "children": [] } ] - }, - { - "name": "Left Arm", - "origin": [5, 22, 0], - "rotation": [10, 0, 0], - "color": 0, - "children": [] - }, - { - "name": "Right Arm", - "origin": [5, 22, 0], - "rotation": [10, 0, 0], - "color": 0, - "children": [] } ] - } + }, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18 ] } \ No newline at end of file diff --git a/first_person_hand_models/assets/minecraft/shaders/core/entity.fsh b/first_person_hand_models/assets/minecraft/shaders/core/entity.fsh new file mode 100644 index 0000000..055c408 --- /dev/null +++ b/first_person_hand_models/assets/minecraft/shaders/core/entity.fsh @@ -0,0 +1,82 @@ +#version 330 + +#moj_import +#moj_import + +uniform sampler2D Sampler0; + +in float sphericalVertexDistance; +in float cylindricalVertexDistance; + +#ifdef PER_FACE_LIGHTING +in vec4 vertexPerFaceColorBack; +in vec4 vertexPerFaceColorFront; +#else +in vec4 vertexColor; +#endif + +in vec4 lightMapColor; +in vec4 overlayColor; +in vec2 texCoord0; +in vec2 texCoord1; +in vec4 corner0; +in vec4 corner1; + +out vec4 fragColor; + +const vec3 HAND_MODEL_SCALE = vec3(0.471, 0.515, 1.515); + +const vec3 modelScaleF = 0.5 * HAND_MODEL_SCALE; +const vec3 modelScaleS = modelScaleF + (0.25 / 8.0) * HAND_MODEL_SCALE; +const vec3 hRefF = vec3(length(modelScaleF.xz), length(modelScaleF.yz), length(modelScaleF.xy)); +const vec3 hRefS = vec3(length(modelScaleS.xz), length(modelScaleS.yz), length(modelScaleS.xy)); + +bool testDim(float h, float hRef) { + return abs(h - hRef) < 0.001; +} +bool testDims(float h, vec3 hRef) { + return testDim(h, hRef.x) || testDim(h, hRef.y) || testDim(h, hRef.z); +} + +void main() { + vec2 texCoord = texCoord0; + + if (corner0.w != 0.0 && corner1.w != 0.0) { + float h = length(corner0.xyz / corner0.w - corner1.xyz / corner1.w); + if (testDims(h, hRefF) || testDims(h, hRefS)) { + texCoord = texCoord1; + } + } + + vec4 color = texture(Sampler0, texCoord); + +#ifdef ALPHA_CUTOUT + if (color.a < ALPHA_CUTOUT) { + discard; + } +#endif + +#ifdef PER_FACE_LIGHTING + color *= (gl_FrontFacing ? vertexPerFaceColorFront : vertexPerFaceColorBack) * ColorModulator; +#else + color *= vertexColor * ColorModulator; +#endif + +#ifndef NO_OVERLAY + color.rgb = mix(overlayColor.rgb, color.rgb, overlayColor.a); +#endif + +#ifndef EMISSIVE + color *= lightMapColor; +#endif + fragColor = apply_fog( + color, + sphericalVertexDistance, + cylindricalVertexDistance, + FogEnvironmentalStart, + FogEnvironmentalEnd, + FogRenderDistanceStart, + FogRenderDistanceEnd, + FogColor + ); +} diff --git a/first_person_hand_models/assets/minecraft/shaders/core/entity.vsh b/first_person_hand_models/assets/minecraft/shaders/core/entity.vsh new file mode 100644 index 0000000..07b393d --- /dev/null +++ b/first_person_hand_models/assets/minecraft/shaders/core/entity.vsh @@ -0,0 +1,143 @@ +#version 330 + +#moj_import +#moj_import +#moj_import +#moj_import + +in vec3 Position; +in vec4 Color; +in vec2 UV0; +in ivec2 UV1; +in ivec2 UV2; +in vec3 Normal; + +uniform sampler2D Sampler0; +uniform sampler2D Sampler1; +uniform sampler2D Sampler2; + +out float sphericalVertexDistance; +out float cylindricalVertexDistance; + +#ifdef PER_FACE_LIGHTING +out vec4 vertexPerFaceColorBack; +out vec4 vertexPerFaceColorFront; +#else +out vec4 vertexColor; +#endif + +out vec4 lightMapColor; +out vec4 overlayColor; +out vec2 texCoord0; +out vec2 texCoord1; +out vec4 corner0; +out vec4 corner1; + +out vec2 distanc; + +const ivec4 armUV[] = ivec4[]( + ivec4(40, 52, 36, 64), // left + ivec4(36, 64, 32, 52), // bottom + ivec4(44, 64, 48, 52), // right + ivec4(44, 52, 40, 48), // top + ivec4(40, 52, 44, 64), // east + ivec4(36, 52, 40, 48) // top +); + +const ivec4 slimArmUV[] = ivec4[]( + ivec4(39, 52, 36, 64), + ivec4(43, 64, 46, 52), + ivec4(36, 64, 32, 52), + ivec4(42, 52, 39, 48), + ivec4(39, 52, 43, 64), + ivec4(36, 52, 39, 48) +); + +const bool armRotateUV[] = bool[]( + false, false, true, true, true, true +); + +const bool armFlipUV[] = bool[]( + false, false, true, false, true, false +); + +const bool armMirrorUV[] = bool[]( + true, false, false, false, false, false +); + +bool isSlim() { + vec4 samp1 = texture(Sampler0, vec2(54.0 / 64.0, 20.0 / 64.0)); + vec4 samp2 = texture(Sampler0, vec2(55.0 / 64.0, 20.0 / 64.0)); + return samp1.a == 0.0 || + (((samp1.r + samp1.g + samp1.b) == 0.0) && + ((samp2.r + samp2.g + samp2.b) == 0.0) && + samp1.a == 1.0 && samp2.a == 1.0); +} + +void main() { + gl_Position = ProjMat * ModelViewMat * vec4(Position, 1.0); + + sphericalVertexDistance = fog_spherical_distance(Position); + cylindricalVertexDistance = fog_cylindrical_distance(Position); + distanc = vec2(cylindricalVertexDistance); +#ifdef PER_FACE_LIGHTING + vec2 light = minecraft_compute_light(Light0_Direction, Light1_Direction, Normal); + vertexPerFaceColorBack = minecraft_mix_light_separate(-light, Color); + vertexPerFaceColorFront = minecraft_mix_light_separate(light, Color); +#elif defined(NO_CARDINAL_LIGHTING) + vertexColor = Color; +#else + vertexColor = minecraft_mix_light(Light0_Direction, Light1_Direction, Normal, Color); +#endif + +#ifndef EMISSIVE + lightMapColor = texelFetch(Sampler2, UV2 / 16, 0); +#endif + overlayColor = texelFetch(Sampler1, UV1, 0); + + texCoord0 = UV0; +#ifdef APPLY_TEXTURE_MATRIX + texCoord0 = (TextureMat * vec4(UV0, 0.0, 1.0)).xy; +#endif + + texCoord1 = texCoord0; + + int part = gl_VertexID / 48 % 2; + int face = (gl_VertexID % 48) / 4; + int vertex = gl_VertexID % 4; + bool slim = isSlim(); + + if (ProjMat[2][3] != 0 && abs(ModelViewMat[3][3] - 1.0) < 0.001) { + ivec4 uvData = slim ? slimArmUV[face % 6] : armUV[face % 6]; + bool rotate = armRotateUV[face % 6]; + bool flip = armFlipUV[face % 6]; + bool mirror = armMirrorUV[face % 6]; + + if (part == 0) { + if (face >= 6) uvData.xz += 16; + } else { + uvData += ivec4(8, -32, 8, -32); + if (face >= 6) uvData.yw += 16; + } + + ivec2 uv; + switch (vertex) { + case 0: uv = uvData.xy; break; + case 1: uv = rotate ? uvData.xw : uvData.zy; break; + case 2: uv = uvData.zw; break; + case 3: uv = rotate ? uvData.zy : uvData.xw; break; + } + if (flip) { + uv = uvData.xy + uvData.zw - uv; + } + if (mirror) { + uv.x = uvData.x + uvData.z - uv.x; + } + + texCoord1 = vec2(uv) / 64.0; + } + + corner0 = corner1 = vec4(0.0); + if (gl_VertexID % 4 == 0) corner0 = vec4(Position, 1.0); + if (gl_VertexID % 4 == 2) corner1 = vec4(Position, 1.0); +}