├── .gitignore ├── LICENSE.txt ├── README.md └── pack ├── assets ├── example │ ├── font │ │ └── assets.json │ └── textures │ │ ├── icons.png │ │ └── map.png ├── minecraft │ └── shaders │ │ └── core │ │ ├── rendertype_text.fsh │ │ ├── rendertype_text.json │ │ └── rendertype_text.vsh └── minimap │ └── shaders │ └── include │ ├── minimap.glsl │ └── minimap_config.glsl └── pack.mcmeta /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_STORE 2 | .idea/ -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright © 2025 Reasonless 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the “Software”), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 7 | of the Software, and to permit persons to whom the Software is furnished to do so, 8 | subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 14 | INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 15 | PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 16 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 17 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 18 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Emily's Minimap Shader 2 | A minimap created within Minecraft's Core Shaders. 3 | 4 | ## Creating the minimap 5 | 1. Create a background texture to be used for the minimap. 6 | - Generate a **256x256** texture containing the background. 7 | - The background size can be configured in the shader's configuration file. 8 | 2. Add the background texture to your resource pack's font 9 | 3. Spawn a text display in the center of the 256x256 area. 10 | - The text display must have a scale of zero 11 | - The color of the text in the text display must be `#454D00` 12 | - **Note:** The view distance of the text display is smaller than the 256x256 area 13 | Now you should have a minimap displayed on screen while in view range. You are able to make larger backgrounds by placing entities at regular intervals. 14 | 15 | ## Adding icons to the minimap 16 | 1. Create a texture for your icon. 17 | - This can be any size that is a multiple of two between `2` and `128` 18 | 2. Add the texture to your resource pack's font 19 | 3. Spawn a text display where you want the icon to appear on the map 20 | - The text display must have a scale of zero 21 | - The color value of the text encodes two key properties: 22 | - The 2 most significant bits represent the Z-position of the icon minus 1. 23 | - The 6 least significant bits represent HALF the size of the texture minus 1. 24 | Now you should have icons displaying on your minimap. If you wish to center an icon on the minimap (an arrow showing the player) you can simply make the text display ride the player. 25 | 26 | ## Icon color cheatsheet 27 | | Z Index | **4x4** | **8x8** | **16x16** | **32x32** | 28 | |---------|-----------|-----------|-----------|-----------| 29 | | **1** | `#454D01` | `#454D03` | `#454D07` | `#454D0F` | 30 | | **2** | `#454D41` | `#454D43` | `#454D47` | `#454D4F` | 31 | | **3** | `#454D81` | `#454D83` | `#454D87` | `#454D8F` | 32 | | **4** | `#454DC1` | `#454DC3` | `#454DC7` | `#454DCF` | 33 | 34 | ## Configuring the shader 35 | The shader can be configured in the `assets/minimap/shaders/include/minimap_config.glsl` file, the following options include: 36 | - `MINIMAP_MAP_SCALE` :: Scale of the map 37 | - `MINIMAP_ICON_SCALE` :: Scale of the icons on the map, the icon positions are scaled by the map scale 38 | - `MINIMAP_X_POSITION` :: The X position that the map should render at 39 | - `MINIMAP_Y_POSITION` :: The Y position that the map should render at 40 | - `MINIMAP_WIDTH` :: The width of the minimap 41 | - `MINIMAP_HEIGHT` :: The height of the minimap 42 | - `TEXTURE_SIZE` :: The size of the background texture 43 | - `MINIMAP_SHAPE` :: The culling shape of the minimap (`SQUARE` or `CIRCLE`) 44 | 45 | # Information to know 46 | - The minimap doesn't scale with GUI scale as we don't have access to it. 47 | - This shader doesn't provide any decorations (minimap frame, background when you reach the border etc.) 48 | 49 | # Known caveats 50 | - Name tags of entities spawned after the minimap entities can sometimes show through the minimap. 51 | - If the player has a low render distance, the minimap can stop rendering at shorter distances. -------------------------------------------------------------------------------- /pack/assets/example/font/assets.json: -------------------------------------------------------------------------------- 1 | { 2 | "providers": [ 3 | { 4 | "type": "bitmap", 5 | "file": "example:map.png", 6 | "ascent": 256, 7 | "height": 256, 8 | "chars": [ 9 | "a" 10 | ] 11 | }, 12 | { 13 | "type": "bitmap", 14 | "file": "example:icons.png", 15 | "ascent": 16, 16 | "height": 16, 17 | "chars": [ 18 | "bcd" 19 | ] 20 | } 21 | ] 22 | } -------------------------------------------------------------------------------- /pack/assets/example/textures/icons.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Reasonlesss/minimap/c9b11b024c3c68c0dffb77499f25530e0c48045b/pack/assets/example/textures/icons.png -------------------------------------------------------------------------------- /pack/assets/example/textures/map.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Reasonlesss/minimap/c9b11b024c3c68c0dffb77499f25530e0c48045b/pack/assets/example/textures/map.png -------------------------------------------------------------------------------- /pack/assets/minecraft/shaders/core/rendertype_text.fsh: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | #moj_import 4 | 5 | uniform sampler2D Sampler0; 6 | 7 | uniform vec4 ColorModulator; 8 | uniform float FogStart; 9 | uniform float FogEnd; 10 | uniform vec4 FogColor; 11 | uniform vec2 ScreenSize; 12 | 13 | in float vertexDistance; 14 | in vec4 vertexColor; 15 | in vec2 texCoord0; 16 | 17 | out vec4 fragColor; 18 | 19 | #define FSH 20 | #moj_import 21 | 22 | void main() { 23 | if (applyMinimap()) { 24 | return; 25 | } 26 | vec4 color = texture(Sampler0, texCoord0) * vertexColor * ColorModulator; 27 | if (color.a < 0.1) { 28 | discard; 29 | } 30 | fragColor = linear_fog(color, vertexDistance, FogStart, FogEnd, FogColor); 31 | } -------------------------------------------------------------------------------- /pack/assets/minecraft/shaders/core/rendertype_text.json: -------------------------------------------------------------------------------- 1 | { 2 | "vertex": "minecraft:core/rendertype_text", 3 | "fragment": "minecraft:core/rendertype_text", 4 | "samplers": [ 5 | { "name": "Sampler0" }, 6 | { "name": "Sampler2" } 7 | ], 8 | "uniforms": [ 9 | { "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 ] }, 10 | { "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 ] }, 11 | { "name": "ColorModulator", "type": "float", "count": 4, "values": [ 1.0, 1.0, 1.0, 1.0 ] }, 12 | { "name": "FogStart", "type": "float", "count": 1, "values": [ 0.0 ] }, 13 | { "name": "FogEnd", "type": "float", "count": 1, "values": [ 1.0 ] }, 14 | { "name": "FogColor", "type": "float", "count": 4, "values": [ 0.0, 0.0, 0.0, 0.0 ] }, 15 | { "name": "FogShape", "type": "int", "count": 1, "values": [ 0 ] }, 16 | { "name": "ScreenSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] } 17 | ] 18 | } -------------------------------------------------------------------------------- /pack/assets/minecraft/shaders/core/rendertype_text.vsh: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | #moj_import 4 | 5 | in vec3 Position; 6 | in vec4 Color; 7 | in vec2 UV0; 8 | in ivec2 UV2; 9 | 10 | uniform sampler2D Sampler0; 11 | uniform sampler2D Sampler2; 12 | uniform mat4 ModelViewMat; 13 | uniform mat4 ProjMat; 14 | uniform vec2 ScreenSize; 15 | uniform int FogShape; 16 | 17 | out float vertexDistance; 18 | out vec4 vertexColor; 19 | out vec2 texCoord0; 20 | 21 | #define VSH 22 | #moj_import 23 | 24 | void main() { 25 | if (applyMinimap()) { 26 | return; 27 | } 28 | gl_Position = ProjMat * ModelViewMat * vec4(Position, 1.0); 29 | vertexDistance = fog_distance(Position, FogShape); 30 | vertexColor = Color * texelFetch(Sampler2, UV2 / 16, 0); 31 | texCoord0 = UV0; 32 | } -------------------------------------------------------------------------------- /pack/assets/minimap/shaders/include/minimap.glsl: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright © 2025 Reasonless 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the “Software”), to deal 6 | in the Software without restriction, including without limitation the rights 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | of the Software, and to permit persons to whom the Software is furnished to do so, 9 | subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in all 12 | copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 15 | INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 16 | PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 17 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 18 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 19 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | #moj_import 22 | 23 | // Constants 24 | #define SQUARE 0.0 25 | #define CIRCLE 1.0 26 | #define MINIMAP_INACTIVE 0.0 27 | #define MINIMAP_ACTIVE 1.0 28 | #define SIGNATURE_E 69.0 / 255.0 29 | #define SIGNATURE_M 77.0 / 255.0 30 | 31 | float getCameraYaw(mat4 viewMat) { 32 | vec4 left = vec4(1.0, 0.0, 0.0, 0.0) * viewMat; 33 | return atan(left.z, left.x) + radians(180.0); 34 | } 35 | 36 | vec2 getRelativePosition(vec3 position, mat4 viewMat) { 37 | return (inverse(viewMat) * vec4((viewMat * vec4(position, 1.0)).xyz, 0.0)).xz; 38 | } 39 | 40 | mat2 createRotationMat(float theta) { 41 | return mat2(cos(theta), -sin(theta), sin(theta), cos(theta)); 42 | } 43 | 44 | #ifdef VSH 45 | out float minimapActive; 46 | 47 | bool applyMinimap() { 48 | minimapActive = MINIMAP_INACTIVE; 49 | 50 | // We want to run the minimap code for hex codes 454D00 to 454DFF 51 | if (Color.x == SIGNATURE_E && Color.y == SIGNATURE_M) { 52 | // Set the texture coordinates 53 | texCoord0 = UV0; 54 | // Obtain data passed using the blue channel of the color. 55 | int blueChannel = int(Color.z * 255); 56 | bool isIcon = blueChannel > 0; 57 | int offset = isIcon ? ((blueChannel >> 0) & 0x3F) + 1 : (TEXTURE_SIZE / 2); 58 | float zPosition = -0.995 - (isIcon ? 0.001 * (((blueChannel >> 6) & 0x3) + 1) : 0.00); 59 | 60 | // Calculate necessary information for the minimap. 61 | vec2 pixelSize = 2.0 / ScreenSize; 62 | vec2 position = getRelativePosition(Position, ModelViewMat); 63 | mat2 rotation = createRotationMat(getCameraYaw(ModelViewMat)); 64 | 65 | /// Calculates the vertex position 66 | vec2 vertexPosition; 67 | switch (gl_VertexID % 4) { 68 | case 0: vertexPosition = vec2(-offset, offset); break; 69 | case 1: vertexPosition = vec2(-offset, -offset); break; 70 | case 2: vertexPosition = vec2(offset, -offset); break; 71 | case 3: vertexPosition = vec2(offset, offset); break; 72 | } 73 | 74 | // Apply transformation to the vertex positions. 75 | if (isIcon) { 76 | vertexPosition *= MINIMAP_ICON_SCALE; 77 | vertexPosition += vec2(-position.x, position.y) * rotation * MINIMAP_MAP_SCALE; 78 | } else { 79 | vertexPosition += vec2(-position.x, position.y); 80 | vertexPosition *= rotation; 81 | vertexPosition *= MINIMAP_MAP_SCALE; 82 | } 83 | 84 | // Position the minimap where the user wants it. 85 | vertexPosition += vec2(MINIMAP_X_POSITION + (MINIMAP_WIDTH / 2), -MINIMAP_Y_POSITION - (MINIMAP_HEIGHT / 2)); 86 | vertexPosition *= pixelSize; 87 | 88 | // Update the actual position of the vertex and set the color to white. 89 | gl_Position = vec4(vertexPosition.x - 1, vertexPosition.y + 1, zPosition, 1.0); 90 | vertexColor = vec4(vec3(1.0), Color.a); 91 | minimapActive = MINIMAP_ACTIVE; 92 | return true; 93 | } 94 | 95 | return false; 96 | } 97 | #endif 98 | #ifdef FSH 99 | in float minimapActive; 100 | 101 | bool applyMinimap() { 102 | if (minimapActive == MINIMAP_ACTIVE) { 103 | // Calculate the color of the minimap, ignoring fog. 104 | vec4 color = texture(Sampler0, texCoord0) * vertexColor * ColorModulator; 105 | if (color.a < 0.1) { 106 | discard; 107 | } 108 | fragColor = color; 109 | // Calculate x and y coordinates for readability 110 | float x = gl_FragCoord.x; 111 | float y = ScreenSize.y - gl_FragCoord.y; 112 | if (MINIMAP_SHAPE == SQUARE) { 113 | if (x < MINIMAP_X_POSITION) discard; 114 | if (y < MINIMAP_Y_POSITION) discard; 115 | if (x > MINIMAP_X_POSITION + MINIMAP_WIDTH) discard; 116 | if (y > MINIMAP_Y_POSITION + MINIMAP_HEIGHT) discard; 117 | } 118 | if (MINIMAP_SHAPE == CIRCLE) { 119 | float centerX = MINIMAP_X_POSITION + MINIMAP_WIDTH / 2.0; 120 | float centerY = MINIMAP_Y_POSITION + MINIMAP_HEIGHT / 2.0; 121 | float radius = min(MINIMAP_WIDTH, MINIMAP_HEIGHT) / 2.0; 122 | 123 | float distSquared = (x - centerX) * (x - centerX) + (y - centerY) * (y - centerY); 124 | 125 | if (distSquared > radius * radius) discard; 126 | } 127 | return true; 128 | } 129 | return false; 130 | } 131 | #endif -------------------------------------------------------------------------------- /pack/assets/minimap/shaders/include/minimap_config.glsl: -------------------------------------------------------------------------------- 1 | /* 2 | * Emily's Minimap Shader Configuration 3 | * 4 | * This file contains configuration options for Emily's Minimap Shader, 5 | * allowing you to define settings such as position, scale, size, and shape 6 | * of the minimap. 7 | * 8 | * If you need to style the minimap further, you may need to write a shader 9 | * to overlay additional text or elements on top of the minimap. 10 | * 11 | * Note: GUI scale is not accessible from within the shader. However, if you 12 | * need to scale the minimap dynamically based on screen size, the `ScreenSize` 13 | * uniform is available for this purpose. 14 | */ 15 | 16 | // Scaling factor for the terrain/background of the minimap. 17 | #define MINIMAP_MAP_SCALE 6 18 | 19 | // Scaling factor for icons displayed on the minimap. 20 | #define MINIMAP_ICON_SCALE 2 21 | 22 | // X-coordinate position of the minimap in pixels. 23 | #define MINIMAP_X_POSITION 50 24 | 25 | // Y-coordinate position of the minimap in pixels. 26 | #define MINIMAP_Y_POSITION 50 27 | 28 | // Width of the minimap in pixels. 29 | #define MINIMAP_WIDTH 300 30 | 31 | // Height of the minimap in pixels. 32 | #define MINIMAP_HEIGHT 300 33 | 34 | // The side length of the background texture in pixels 35 | #define TEXTURE_SIZE 256 36 | 37 | // Defines the shape of the minimap’s culling area. Options: SQUARE or CIRCLE. 38 | #define MINIMAP_SHAPE CIRCLE -------------------------------------------------------------------------------- /pack/pack.mcmeta: -------------------------------------------------------------------------------- 1 | { 2 | "pack": { 3 | "description": "Emily's Minimap Pack", 4 | "pack_format": 42 5 | } 6 | } --------------------------------------------------------------------------------