Skip to content

Commit e9f7555

Browse files
committed
v0.0.5 - multi-version support, lighting fixes, Sodium compat
- Stonecutter multi-version: 1.21 through 26.1.2 (15 versions) - Fixed lighting on merged quads (4x4 subdivision for smooth AO) - Fixed API version boundaries for 1.21.2+, 1.21.5+, 1.21.6+, 1.21.9+ - Sodium compatibility across all versions - F3 debug overlay with DebugScreenEntries for 1.21.9+ - Wireframe debug via DebugRenderer mixin for 1.21.9/1.21.10 - Version-specific terrain shaders for each MC version range - GitHub Actions CI + automated Modrinth release - Cloth Config now optional - Package renamed to hi.sierra.greedy_meshing
1 parent 01dbe05 commit e9f7555

103 files changed

Lines changed: 5565 additions & 2023 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/build.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
branches: [master]
6+
pull_request:
7+
branches: [master]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
- name: Set up JDK 25
16+
uses: actions/setup-java@v4
17+
with:
18+
java-version: '25'
19+
distribution: 'temurin'
20+
21+
- name: Setup Gradle
22+
uses: gradle/actions/setup-gradle@v4
23+
24+
- name: Grant execute permission for gradlew
25+
run: chmod +x gradlew
26+
27+
- name: Build all versions
28+
run: ./gradlew build
29+
30+
- name: Upload artifacts
31+
uses: actions/upload-artifact@v4
32+
with:
33+
name: greedy-meshing-jars
34+
path: versions/*/build/libs/*.jar
35+
if-no-files-found: error

.github/workflows/release.yml

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
env:
9+
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
10+
11+
jobs:
12+
release:
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: write
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Set up JDK 25
20+
uses: actions/setup-java@v4
21+
with:
22+
java-version: '25'
23+
distribution: 'temurin'
24+
25+
- name: Setup Gradle
26+
uses: gradle/actions/setup-gradle@v4
27+
28+
- name: Grant execute permission for gradlew
29+
run: chmod +x gradlew
30+
31+
- name: Build all versions
32+
run: ./gradlew build
33+
34+
- name: Get version from tag
35+
id: version
36+
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
37+
38+
- name: Collect JARs
39+
id: collect
40+
run: |
41+
mkdir -p release-jars
42+
for dir in versions/*/build/libs; do
43+
ver=$(echo "$dir" | cut -d/ -f2)
44+
for jar in "$dir"/*.jar; do
45+
[ -f "$jar" ] || continue
46+
# Skip sources jars
47+
case "$jar" in *-sources.jar) continue;; esac
48+
cp "$jar" "release-jars/greedy-meshing-${{ steps.version.outputs.VERSION }}+${ver}.jar"
49+
done
50+
done
51+
ls -la release-jars/
52+
53+
- name: Create GitHub Release
54+
uses: softprops/action-gh-release@v2
55+
with:
56+
files: release-jars/*.jar
57+
generate_release_notes: true
58+
59+
- name: Publish to Modrinth
60+
if: env.MODRINTH_TOKEN != ''
61+
run: |
62+
VERSION="${{ steps.version.outputs.VERSION }}"
63+
64+
declare -A MC_VERSIONS=(
65+
["1.21"]="1.21"
66+
["1.21.1"]="1.21.1"
67+
["1.21.2"]="1.21.2"
68+
["1.21.3"]="1.21.3"
69+
["1.21.4"]="1.21.4"
70+
["1.21.5"]="1.21.5"
71+
["1.21.6"]="1.21.6"
72+
["1.21.7"]="1.21.7"
73+
["1.21.8"]="1.21.8"
74+
["1.21.9"]="1.21.9"
75+
["1.21.10"]="1.21.10"
76+
["1.21.11"]="1.21.11"
77+
["26.1"]="26.1"
78+
["26.1.1"]="26.1.1"
79+
["26.1.2"]="26.1.2"
80+
)
81+
82+
for ver in "${!MC_VERSIONS[@]}"; do
83+
mc_ver="${MC_VERSIONS[$ver]}"
84+
jar_file="release-jars/greedy-meshing-${VERSION}+${ver}.jar"
85+
86+
if [ ! -f "$jar_file" ]; then
87+
echo "Skipping $ver - no jar found"
88+
continue
89+
fi
90+
91+
echo "Publishing $ver ($mc_ver)..."
92+
93+
# Upload file first
94+
file_hash=$(sha512sum "$jar_file" | cut -d' ' -f1)
95+
96+
curl -s -X POST "https://api.modrinth.com/v2/version" \
97+
-H "Authorization: $MODRINTH_TOKEN" \
98+
-F "data={
99+
\"name\": \"Greedy Meshing ${VERSION} for ${mc_ver}\",
100+
\"version_number\": \"${VERSION}+${mc_ver}\",
101+
\"game_versions\": [\"${mc_ver}\"],
102+
\"version_type\": \"release\",
103+
\"loaders\": [\"fabric\"],
104+
\"featured\": true,
105+
\"project_id\": \"greedy-meshing-mod\",
106+
\"file_parts\": [\"file\"],
107+
\"dependencies\": [
108+
{\"project_id\": \"P7dR8mSH\", \"dependency_type\": \"required\"},
109+
{\"project_id\": \"9s6osm5g\", \"dependency_type\": \"optional\"},
110+
{\"project_id\": \"mOgUt4GM\", \"dependency_type\": \"optional\"}
111+
]
112+
}" \
113+
-F "file=@${jar_file}" \
114+
&& echo " -> OK" || echo " -> FAILED"
115+
done

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2026 Sierra
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Greedy Meshing
2+
3+
A client-side Fabric mod that optimizes chunk rendering by merging adjacent identical block faces into larger quads using greedy meshing. This reduces the number of quads the GPU needs to render, improving frame rates in areas with large flat surfaces of the same block.
4+
5+
## How It Works
6+
7+
Instead of rendering each block face as a separate quad, Greedy Meshing scans each chunk section and merges eligible faces into larger combined quads. Only opaque, full-cube blocks with no block entities are eligible. Custom GLSL shaders reconstruct per-block UVs at render time so textures tile correctly across merged faces.
8+
9+
## Features
10+
11+
- Automatic merging of identical opaque block faces
12+
- Custom terrain shaders for correct texture tiling
13+
- Sodium compatibility
14+
- F3 debug overlay showing quad reduction stats
15+
- Debug wireframe overlay (configurable via Mod Menu)
16+
- Split-screen comparison mode (greedy vs vanilla)
17+
18+
> **Note:** This mod is experimental. Some mods that modify chunk rendering or terrain shaders may be incompatible. If you experience visual glitches or crashes, try disabling Greedy Meshing in the config (`config/greedy_meshing.json` or via Mod Menu) to confirm it's the cause.
19+
>
20+
> **Shader packs** (Iris/OptiFine) are not fully supported. When a shader pack is active, the mod falls back to face-culling-only mode (no quad merging) since shader packs replace the terrain shaders that greedy meshing relies on.
21+
>
22+
> **Lighting** on large merged faces (especially on superflat) may look slightly different from vanilla. Merged quads have fewer vertices for the GPU to interpolate light between, so torch light and shadows can appear less smooth across large flat surfaces. This is an inherent tradeoff of greedy meshing.
23+
24+
## Supported Versions
25+
26+
| Minecraft | Loader | Status |
27+
|-----------|--------|--------|
28+
| 1.21 - 1.21.11 | Fabric | Supported |
29+
| 26.1 - 26.1.2 | Fabric | Supported |
30+
31+
Built with [Stonecutter](https://github.com/stonecutter-versioning/stonecutter) for multi-version support.
32+
33+
## Dependencies
34+
35+
- **Required:** [Fabric API](https://modrinth.com/mod/fabric-api)
36+
- **Optional:** [Cloth Config](https://modrinth.com/mod/cloth-config) + [Mod Menu](https://modrinth.com/mod/modmenu) (for in-game config screen), [Sodium](https://modrinth.com/mod/sodium) (compatible)
37+
38+
## Installation
39+
40+
1. Install [Fabric Loader](https://fabricmc.net/)
41+
2. Download the jar for your Minecraft version from [Modrinth](https://modrinth.com/mod/greedy-meshing) or [GitHub Releases](https://github.com/programmer1o1/GreedyMeshingMod/releases)
42+
3. Place the jar in your `mods/` folder along with Fabric API and Cloth Config
43+
44+
## Configuration
45+
46+
Open the config screen via Mod Menu, or edit `config/greedy_meshing.json`:
47+
48+
- **Enabled** - Toggle greedy meshing on/off
49+
- **Debug Wireframe** - Show merged quad outlines
50+
- **Debug Comparison** - Split-screen greedy vs vanilla view
51+
- **Mesh Opacity** - Wireframe overlay opacity
52+
53+
## Building from Source
54+
55+
```bash
56+
git clone https://github.com/programmer1o1/GreedyMeshingMod.git
57+
cd GreedyMeshingMod
58+
./gradlew build
59+
```
60+
61+
Jars are output to `versions/<version>/build/libs/`.
62+
63+
## License
64+
65+
[MIT](LICENSE)
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#version 150
2+
3+
#moj_import <minecraft:fog.glsl>
4+
#moj_import <minecraft:dynamictransforms.glsl>
5+
6+
uniform sampler2D Sampler0;
7+
8+
in float sphericalVertexDistance;
9+
in float cylindricalVertexDistance;
10+
in vec4 vertexColor;
11+
in vec2 texCoord0;
12+
13+
out vec4 fragColor;
14+
15+
void main() {
16+
vec4 color = texture(Sampler0, texCoord0) * vertexColor * ColorModulator;
17+
#ifdef ALPHA_CUTOUT
18+
if (color.a < ALPHA_CUTOUT) {
19+
discard;
20+
}
21+
#endif
22+
fragColor = apply_fog(color, sphericalVertexDistance, cylindricalVertexDistance, FogEnvironmentalStart, FogEnvironmentalEnd, FogRenderDistanceStart, FogRenderDistanceEnd, FogColor);
23+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#version 150
2+
3+
#moj_import <minecraft:fog.glsl>
4+
#moj_import <minecraft:dynamictransforms.glsl>
5+
#moj_import <minecraft:projection.glsl>
6+
7+
in vec3 Position;
8+
in vec4 Color;
9+
in vec2 UV0;
10+
in ivec2 UV2;
11+
in vec3 Normal;
12+
13+
uniform sampler2D Sampler2;
14+
15+
out float sphericalVertexDistance;
16+
out float cylindricalVertexDistance;
17+
out vec4 vertexColor;
18+
out vec2 texCoord0;
19+
20+
vec4 minecraft_sample_lightmap(sampler2D lightMap, ivec2 uv) {
21+
return texture(lightMap, clamp(uv / 256.0, vec2(0.5 / 16.0), vec2(15.5 / 16.0)));
22+
}
23+
24+
void main() {
25+
vec3 pos = Position + ModelOffset;
26+
gl_Position = ProjMat * ModelViewMat * vec4(pos, 1.0);
27+
28+
sphericalVertexDistance = fog_spherical_distance(pos);
29+
cylindricalVertexDistance = fog_cylindrical_distance(pos);
30+
vertexColor = Color * minecraft_sample_lightmap(Sampler2, UV2);
31+
texCoord0 = UV0;
32+
}

0 commit comments

Comments
 (0)