Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
a69adec
Ensure depth test is configured when rendering clouds
jellysquid3 Nov 27, 2024
42ad933
Fix rounding error in ColorMixer#mix
jellysquid3 Dec 1, 2024
cff7ceb
Add additional optimized block models
muzikbike Nov 24, 2024
8f4aaaa
Avoid marking the section graph as dirty if state didn't change (#2886)
douira Dec 2, 2024
ca77679
Use larger bounding box for nearby sections in frustum check (#2879)
douira Dec 2, 2024
6e1aeae
Bump version to 0.6.1
jellysquid3 Dec 2, 2024
a858eba
Bump dependency versions
jellysquid3 Dec 2, 2024
f31c803
Update mod manifest
jellysquid3 Dec 3, 2024
6271966
Ensure ItemRenderContext.isDefaultTranslucent is initialized
jellysquid3 Dec 3, 2024
1a33ea6
Update compatible mods listing
jellysquid3 Dec 3, 2024
731a95f
Update mod manifest to restrict Minecraft versions
jellysquid3 Dec 3, 2024
366f0df
Update to Minecraft 1.21.4
IMS212 Nov 25, 2024
90188e8
Update NeoForge manifest for Minecraft 1.21.4
jellysquid3 Dec 3, 2024
6adc89c
Fix glyph effect orientation
IMS212 Dec 4, 2024
d818a6e
Fix hidden surface elimination in fluid rendering for waterlogged blo…
douira Dec 4, 2024
6e72c3d
Fix detection for specific Intel OpenGL ICDs
jellysquid3 Dec 4, 2024
26f4263
Avoid showing the incompatible driver error in some cases
jellysquid3 Dec 4, 2024
5bc21f0
Fix lambda mappings
IMS212 Dec 5, 2024
5929b38
Bump version and dependency requirements
jellysquid3 Dec 7, 2024
ca35ecb
Use correct coordinates for sorting chunk sections (#2924)
douira Dec 7, 2024
0bfae8b
Update README.md
jellysquid3 Dec 12, 2024
7dc491d
Update textures for Leaves variants
jellysquid3 Dec 15, 2024
99afc83
Clean up BitArray class
jellysquid3 Dec 15, 2024
da61519
Use link.caffeinemc.net domain for some URLs
jellysquid3 Dec 15, 2024
930c0c5
Use ShellExecuteW from message box callbacks
jellysquid3 Dec 15, 2024
0bc0261
Do not bake ambient lighting into cached per-face light data
jellysquid3 Dec 16, 2024
d9db477
Switch to Parchment mappings 2024.12.07
jellysquid3 Dec 17, 2024
6c75859
Bump version and dependencies
jellysquid3 Dec 17, 2024
0d4ab84
Do not cache ambient brightness at initialization
jellysquid3 Dec 17, 2024
3e04ad0
Bump version to 0.6.5
jellysquid3 Dec 17, 2024
a40937b
Fix transforms not being run on fast path
IMS212 Dec 22, 2024
2415900
Bump version to 0.6.6
jellysquid3 Dec 25, 2024
ffb8cba
Rename model texture references to match Vanilla (#2958)
muzikbike Dec 31, 2024
07ce020
Do not apply optimizations to sprites with special tickers
jellysquid3 Dec 29, 2024
7f25220
Aggressively optimize entity rendering
jellysquid3 Jan 2, 2025
1b0f7b9
Avoid quaternion transforms in particle rendering
jellysquid3 Jan 2, 2025
3186b1b
Add shader source line annotations (#2691)
douira Jan 2, 2025
614e928
Fixup model texture names for Hoppers (#2964)
Apollounknowndev Jan 4, 2025
62fad40
Rewrite injections in ItemRendererMixin to be less invasive (#2968)
lowercasebtw Jan 4, 2025
a15129c
Fix invalid texture name in Hopper model (#2966)
douira Jan 4, 2025
3af8680
Use correct pointer shifts on 32-bit platforms
jellysquid3 Jan 6, 2025
d74e421
Improve vertex sorting code and use radix sorts
jellysquid3 Jan 7, 2025
2d63bec
Try to handle exceptions during block entity iteration
jellysquid3 Jan 18, 2025
71c840f
Adjust texcoord epsilon depending on atlas size
jellysquid3 Jan 18, 2025
821d47f
Bump version to 0.6.7-rc.1
jellysquid3 Jan 18, 2025
ca4bbcb
Use 8 bits of sub-texel precision and fix off-by-one error
jellysquid3 Jan 18, 2025
1b54906
Fix Maven publishing artifact ID (#2989)
douira Jan 19, 2025
2fe7c8b
Workaround incorrect quad ordering caused by material downgrading
IMS212 Jan 23, 2025
4222e5d
Allow configuring the Radix sort to be stable
jellysquid3 Jan 24, 2025
010838a
Ensure arrays are unreachable in Radix sort fallback code
jellysquid3 Jan 25, 2025
c510742
Add debug mode for detecting illegal off-thread accesses
jellysquid3 Jan 25, 2025
214b0ad
Only hook RenderSystem#recordRenderCall in debug mode
jellysquid3 Jan 25, 2025
194cb11
Don't dump shaders by default in "developer" workspaces
jellysquid3 Jan 26, 2025
8849419
Add support for DelegateBakedModels with custom getQuads
IMS212 Jan 26, 2025
e5da7db
Add Javadoc to BugChecks.java
jellysquid3 Jan 28, 2025
aef6c33
Add vendor detection for Intel Xe2 graphics
jellysquid3 Feb 4, 2025
d096599
Merge branch 'latest-cdc' into dev-working
ThatMG393 Feb 5, 2025
681a85b
fix 32bit thing
ThatMG393 Feb 5, 2025
0c8d073
Update SectionRenderDataUnsafe.java
ThatMG393 Feb 5, 2025
31570c6
Update DefaultChunkRenderer.java
ThatMG393 Feb 5, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 53 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,53 @@
Sodium is a powerful rendering engine and optimization mod for the Minecraft client which improves frame rates and reduces
micro-stutter, while fixing many graphical issues in Minecraft.

### 📥 Installation
**This mod is the result of thousands of hours of development, and is made possible thanks to players like you.** If you
would like to show a token of your appreciation for my work, and help support the development of Sodium in the process,
then consider [buying me a coffee](https://caffeinemc.net/donate).

The latest version of Sodium can be downloaded from our official [Modrinth](https://modrinth.com/mod/sodium) and
[CurseForge](https://www.curseforge.com/minecraft/mc-mods/sodium) pages.
<a href="https://caffeinemc.net/donate"><img src="https://storage.ko-fi.com/cdn/kofi2.png?v=3" width="180"/></a>

---

### 📥 Downloads

#### Stable builds

The latest stable release of Sodium can be downloaded from our official [Modrinth](https://modrinth.com/mod/sodium) and
[CurseForge](https://www.curseforge.com/minecraft/mc-mods/sodium) pages.

#### Nightly builds (for developers)

We also provide bleeding-edge builds ("nightlies") which are useful for testing the very latest changes before they're
packaged into a release. These builds are only provided for other mod developers and users with expert skills, and do
not come with any support or warranty. It is often the case they have issues and lack compatibility with other mods.

The latest nightly build for each current branch of development can be downloaded below.

- Minecraft 1.21.4 (latest): [Download nightly](https://nightly.link/CaffeineMC/sodium/workflows/build-commit/dev/sodium-artifacts-dev.zip) or [View all builds](https://github.com/CaffeineMC/sodium/actions/workflows/build-commit.yml?query=branch%3Adev)
- Minecraft 1.21.3: [Download nightly](https://nightly.link/CaffeineMC/sodium/workflows/build-commit/1.21.3%2Fstable/sodium-artifacts-1.21.3-stable.zip) or [View all builds](https://github.com/CaffeineMC/sodium/actions/workflows/build-commit.yml?query=branch%3A1.21.3%2Fstable)
- Minecraft 1.21.1: [Download nightly](https://nightly.link/CaffeineMC/sodium/workflows/build-commit/1.21.1%2Fstable/sodium-artifacts-1.21.1-stable.zip) or [View all builds](https://github.com/CaffeineMC/sodium/actions/workflows/build-commit.yml?query=branch%3A1.21.1%2Fstable)

### 🖥️ Installation

Since the release of Sodium 0.6.0, both the _Fabric_ and _NeoForge_ mod loaders are supported. We generally recommend
that new users prefer to use the _Fabric_ mod loader, since it is more lightweight and stable (for the time being.)

For more information about downloading and installing the mod, please refer to our [Installation Guide](https://github.com/CaffeineMC/sodium/wiki/Installation).

### 🐛 Reporting Issues
### 🙇 Getting Help

You can report bugs and crashes by opening an issue on our [issue tracker](https://github.com/CaffeineMC/sodium/issues).
Before opening a new issue, use the search tool to make sure that your issue has not already been reported and ensure
that you have completely filled out the issue template. Issues that are duplicates or do not contain the necessary
information to triage and debug may be closed.
For technical support (including help with mod installation problems and game crashes), please use our
[official Discord server](https://caffeinemc.net/discord).

### 📬 Reporting Issues

If you do not need technical support and would like to report an issue (bug, crash, etc.) or otherwise request changes
(for mod compatibility, new features, etc.), then we encourage you to open an issue on the
[project issue tracker](https://github.com/CaffeineMC/sodium/issues).

Please note that while the issue tracker is open to feature requests, development is primarily focused on
improving hardware compatibility, performance, and finishing any unimplemented features necessary for parity with
improving compatibility, performance, and finishing any unimplemented features necessary for parity with
the vanilla renderer.

### 💬 Join the Community
Expand All @@ -36,45 +64,40 @@ We have an [official Discord community](https://caffeinemc.net/discord) for all

## ✅ Hardware Compatibility

We only provide support for graphics cards which have up-to-date drivers for OpenGL 4.6. Most graphics cards which have
been released since year 2010 are supported, such as the...
We only provide official support for graphics cards which have up-to-date drivers that are compatible with OpenGL 4.5
or newer. Most graphics cards released in the past 12 years will meet these requirements, including the following:

- AMD Radeon HD 7000 Series (GCN 1) or newer
- NVIDIA GeForce 400 Series (Fermi) or newer
- Intel HD Graphics 500 Series (Skylake) or newer

In some cases, older graphics cards may also work (so long as they have up-to-date drivers which have support for
OpenGL 3.3), but they are not officially supported, and may not be compatible with future versions of Sodium.
Nearly all graphics cards that are already compatible with Minecraft (which requires OpenGL 3.3) should also work
with Sodium. But our team cannot ensure compatibility or provide support for older graphics cards, and they may
not work with future versions of Sodium.

#### OpenGL Compatibility Layers

Devices which need to use OpenGL translation layers (such as GL4ES, ANGLE, etc) are not supported and will very likely
not work with Sodium. These translation layers do not implement required functionality and they suffer from underlying
driver bugs which cannot be worked around.

## 🛠️ Developer Guide

### Building from sources
## 🛠️ Building from sources

Sodium uses a typical Gradle project structure and can be compiled by simply running the default `build` task. The build
artifacts (typical mod binaries, and their sources) can be found in the `build/libs` directory.
Sodium uses the [Gradle build tool](https://gradle.org/) and can be built with the `gradle build` command. The build
artifacts (production binaries and their source bundles) can be found in the `build/mods` directory.

#### Requirements
The [Gradle wrapper](https://docs.gradle.org/current/userguide/gradle_wrapper.html#sec:using_wrapper) is provided for ease of use and will automatically download and install the
appropriate version of Gradle for the project build. To use the Gradle wrapper, substitute `gradle` in build commands
with `./gradlew.bat` (Windows) or `./gradlew` (macOS and Linux).

We recommend using a package manager (such as [SDKMAN](https://sdkman.io/)) to manage toolchain dependencies and keep
them up to date. For many Linux distributions, these dependencies will be standard packages in your software
repositories.
### Build Requirements

- OpenJDK 21
- We recommend using the [Eclipse Temurin](https://adoptium.net/) distribution, as it's known to be high quality
and to work without issues.
- Gradle 8.6.x (optional)
- The [Gradle wrapper](https://docs.gradle.org/current/userguide/gradle_wrapper.html#sec:using_wrapper) is provided
in this repository can be used instead of installing a suitable version of Gradle yourself. However, if you are
building many projects, you may prefer to install it yourself through a suitable package manager as to save disk
space and to avoid many different Gradle daemons sitting around in memory.
- We recommend using the [Eclipse Temurin](https://adoptium.net/) distribution as it's regularly tested by our developers and known
to be of high quality.
- Gradle 8.10.x
- Typically, newer versions of Gradle will work without issues, but the build script is only tested against the
version specified by the wrapper script.
version used by the [wrapper script](/gradle/wrapper/gradle-wrapper.properties).

## 📜 License

Expand Down
13 changes: 6 additions & 7 deletions buildSrc/src/main/kotlin/BuildConfig.kt
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import org.gradle.api.Project
import org.gradle.api.Project

object BuildConfig {
val MINECRAFT_VERSION: String = "1.21.3"
val NEOFORGE_VERSION: String = "21.3.40-beta"
val MINECRAFT_VERSION: String = "1.21.4"
val NEOFORGE_VERSION: String = "21.4.47-beta"
val FABRIC_LOADER_VERSION: String = "0.16.9"
val FABRIC_API_VERSION: String = "0.109.0+1.21.3"
val FABRIC_API_VERSION: String = "0.112.1+1.21.4"

// This value can be set to null to disable Parchment.
// TODO: Re-add Parchment
val PARCHMENT_VERSION: String? = null
val PARCHMENT_VERSION: String? = "2024.12.07"

// https://semver.org/
var MOD_VERSION: String = "0.6.0"
var MOD_VERSION: String = "0.6.7-rc.1"

fun createVersionString(project: Project): String {
val builder = StringBuilder()
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/multiloader-platform.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ publishing {
publications {
create<MavenPublication>("maven") {
groupId = project.group as String
artifactId = project.name as String
artifactId = rootProject.name + "-" + project.name
version = version

from(components["java"])
Expand Down
2 changes: 0 additions & 2 deletions common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ dependencies {
addDependentFabricModule("fabric-renderer-api-v1")
addDependentFabricModule("fabric-rendering-data-attachment-v1")

modCompileOnly("net.fabricmc.fabric-api:fabric-renderer-api-v1:3.2.9+1172e897d7")

// We need to be careful during pre-launch that we don't touch any Minecraft classes, since other mods
// will not yet have an opportunity to apply transformations.
configurationPreLaunch("org.lwjgl:lwjgl:3.3.3")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,33 @@
public class ColorMixer {
/**
* <p>Linearly interpolate between the {@param start} and {@param end} points, represented as packed unsigned 8-bit
* values within a 32-bit integer. The result is computed as <pre>(start * weight) + (end * (255 - weight))</pre>.</p>
* values within a 32-bit integer. The result is computed as <pre>(start * weight) + (end * (255 - weight))</pre>
* using fixed-point arithmetic and round-to-nearest behavior.</p>
*
* <p>The results are undefined if {@param weight} is not within the interval [0, 255].</p>

* @param start The start of the range to interpolate
* @param end The end of the range to interpolate
*
* <p>If {@param start} and {@param end} are the same value, the result of this function will always be that value,
* regardless of {@param weight}.</p>
*
* @param start The value at the start of the range to interpolate
* @param end The value at the end of the range to interpolate
* @param weight The weight value used to interpolate between color values (in 0..255 range)
* @return The color that was interpolated between the start and end points
*/
public static int mix(int start, int end, int weight) {
// Overflow is not possible, so adding the values is fine.
return mul(start, weight) + mul(end, ColorU8.COMPONENT_MASK - weight);
// De-interleave the 8-bit component lanes into high and low halves for each point.
// Multiply the start point by alpha, and the end point by 1-alpha, to produce Q8.8 fixed-point intermediates.
// Add the Q8.8 fixed-point intermediaries together to obtain the mixed values.
final long hi = ((start & 0x00FF00FFL) * weight) + ((end & 0x00FF00FFL) * (ColorU8.COMPONENT_MASK - weight));
final long lo = ((start & 0xFF00FF00L) * weight) + ((end & 0xFF00FF00L) * (ColorU8.COMPONENT_MASK - weight));

// Round the fixed-point values to the nearest integer, and interleave the high and low halves to
// produce the final packed result.
final long result =
(((hi + 0x00FF00FFL) >>> 8) & 0x00FF00FFL) |
(((lo + 0xFF00FF00L) >>> 8) & 0xFF00FF00L);

return (int) result;
}

/**
Expand Down Expand Up @@ -104,10 +119,19 @@ public static int mulComponentWise(int color0, int color1) {
* @return The result of the multiplication
*/
public static int mul(int color, int factor) {
final long result = (((((color & 0x00FF00FFL) * factor) + 0x00FF00FFL) >>> 8) & 0x00FF00FFL) |
(((((color & 0xFF00FF00L) * factor) + 0xFF00FF00L) >>> 8) & 0xFF00FF00L);
// De-interleave the 8-bit component lanes into high and low halves.
// Perform 8-bit multiplication to produce Q8.8 fixed-point intermediaries.
final long hi = (color & 0x00FF00FFL) * factor;
final long lo = (color & 0xFF00FF00L) * factor;

// Round the Q8.8 fixed-point values to the nearest integer, and interleave the high and low halves to
// produce the packed result.
final long result =
(((hi + 0x00FF00FFL) >>> 8) & 0x00FF00FFL) |
(((lo + 0xFF00FF00L) >>> 8) & 0xFF00FF00L);

return (int) result;

}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

public class ColorAttribute {
public static void set(long ptr, int color) {
MemoryUtil.memPutInt(ptr + 0, color);
MemoryUtil.memPutInt(ptr, color);
}

public static int get(long ptr) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

public class NormalAttribute {
public static void set(long ptr, int normal) {
MemoryUtil.memPutInt(ptr + 0, normal);
MemoryUtil.memPutInt(ptr, normal);
}

public static int get(long ptr) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@

public class PositionAttribute {
public static void put(long ptr, float x, float y, float z) {
MemoryUtil.memPutFloat(ptr + 0, x);
MemoryUtil.memPutFloat(ptr + 4, y);
MemoryUtil.memPutFloat(ptr + 8, z);
MemoryUtil.memPutFloat(ptr + 0L, x);
MemoryUtil.memPutFloat(ptr + 4L, y);
MemoryUtil.memPutFloat(ptr + 8L, z);
}

public static float getX(long ptr) {
return MemoryUtil.memGetFloat(ptr + 0);
return MemoryUtil.memGetFloat(ptr + 0L);
}

public static float getY(long ptr) {
return MemoryUtil.memGetFloat(ptr + 4);
return MemoryUtil.memGetFloat(ptr + 4L);
}

public static float getZ(long ptr) {
return MemoryUtil.memGetFloat(ptr + 8);
return MemoryUtil.memGetFloat(ptr + 8L);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import java.io.IOException;

public class LaunchWarn {
private static final String HELP_URL = "https://github.com/CaffeineMC/sodium/wiki/Installation";
private static final String HELP_URL = "https://link.caffeinemc.net/guides/sodium/installation";

private static final String RICH_MESSAGE =
"<html>" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ public record SodiumResourcePackMetadata(List<String> ignoredShaders) {
.apply(instance, SodiumResourcePackMetadata::new)
);
public static final MetadataSectionType<SodiumResourcePackMetadata> SERIALIZER =
MetadataSectionType.fromCodec("sodium", CODEC);
new MetadataSectionType<>("sodium", CODEC);
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ protected MixinConfig() {
this.addMixinRule("core", true); // TODO: Don't actually allow the user to disable this

this.addMixinRule("debug.checks", false);
this.addMixinRule("debug.checks.threading", false);

this.addMixinRule("features", true);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import org.apache.logging.log4j.Logger;
import org.lwjgl.opengl.GL20C;

import java.util.Arrays;

/**
* A compiled OpenGL shader object.
*/
Expand All @@ -15,17 +17,18 @@ public class GlShader extends GlObject {

private final ResourceLocation name;

public GlShader(ShaderType type, ResourceLocation name, String src) {
public GlShader(ShaderType type, ResourceLocation name, ShaderParser.ParsedShader parsedShader) {
this.name = name;

int handle = GL20C.glCreateShader(type.id);
ShaderWorkarounds.safeShaderSource(handle, src);
ShaderWorkarounds.safeShaderSource(handle, parsedShader.src());
GL20C.glCompileShader(handle);

String log = GL20C.glGetShaderInfoLog(handle);

if (!log.isEmpty()) {
LOGGER.warn("Shader compilation log for " + this.name + ": " + log);
LOGGER.warn("Shader compilation log for {}: {}", this.name, log);
LOGGER.warn("Include table: {}", Arrays.toString(parsedShader.includeIds()));
}

int result = GlStateManager.glGetShaderi(handle, GL20C.GL_COMPILE_STATUS);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
package net.caffeinemc.mods.sodium.client.gl.shader;

import com.google.common.base.Objects;
import net.caffeinemc.mods.sodium.client.services.PlatformRuntimeInformation;
import org.apache.commons.io.IOUtils;

import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import net.minecraft.resources.ResourceLocation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class ShaderLoader {
private static final Logger LOGGER = LoggerFactory.getLogger("Sodium-ShaderLoader");

private static final boolean OPTION_DEBUG_SHADERS =
Objects.equal(System.getProperty("sodium.debug.shaders.dump", "false"), "true");

/**
* Creates an OpenGL shader from GLSL sources. The GLSL source file should be made available on the classpath at the
* path of `/assets/{namespace}/shaders/{path}`. User defines can be used to declare variables in the shader source
Expand All @@ -19,7 +28,14 @@ public class ShaderLoader {
* @return An OpenGL shader object compiled with the given user defines
*/
public static GlShader loadShader(ShaderType type, ResourceLocation name, ShaderConstants constants) {
return new GlShader(type, name, ShaderParser.parseShader(getShaderSource(name), constants));
var parsedShader = ShaderParser.parseShader(getShaderSource(name), constants);

if (OPTION_DEBUG_SHADERS) {
LOGGER.info("Loaded shader {} with constants {}", name, constants);
LOGGER.info(parsedShader.src());
}

return new GlShader(type, name, parsedShader);
}

public static String getShaderSource(ResourceLocation name) {
Expand Down
Loading
Loading