Sodium Core Shader Support
[!IMPORTANT] 本模组不再接收任何更新。自 Sodium 0.9.0 和 Minecraft 26.2 起,Sodium 允许在不使用此模组的情况下更改其光影!如果某个整合包在 Sodium 上无法正常工作,这意味着该整合包必须更新到特定的 Sodium 0.9.x 版本。
目前计划将此模组更新至旧版 Sodium/Minecraft(例如 1.21.x)的版本。
启用资源包替换 Sodium 的核心光影,类似于资源包能够替换原版核心光影的方式。 如果你喜欢我的模组,请考虑通过请我喝咖啡来支持开发:
用户文档
Sodium Core Shader Support 允许资源包用它们自己的光影替换 Sodium 的核心光影。这不意味着本模组能让所有原版资源包在 Sodium 上工作。只有那些明确声明与 Sodium Core Shader Support 兼容的资源包才能正常工作。
如果你使用的是受支持的资源包,你可以像激活其他资源包一样简单地激活它。
资源包不兼容
在重新加载资源后,Sodium 可能会在右上角显示消息 The following resource packs are incompatible with Sodium 并列出你当前活动的核心光影。即使资源包支持 Sodium Core Shader Support 且可以正常使用,这条消息始终会出现,可以忽略。
资源包列表
这是一份可在 Sodium 上使用的资源包的小列表。如果你自己创建了资源包,欢迎在我的 GitHub 上提交 Issue 将其添加到此列表中!
- Energy Shaders [Java]
- Night Vision Shaders [Java]
- Re-Shaded (自 Re-Shaded 1.3 版本起)
光影开发者文档
重要的是要理解,你的原版光影不能直接复制到 Sodium 光影中。Sodium 拥有自己的块和云的光影:
- assets/sodium/shaders/
| - clouds.fsh
| - clouds.vsh
| - blocks/
| - block_layer_opaque.fsh
| - block_layer_opaque.vsh
| - include/
| - fog.glsl
| - chunk_material.glsl
| - chunk_matrices.glsl
| - chunk_vertex.glsl
除非你想更改 Sodium 的云,否则 block_layer_opaque 通常是最重要的部分。
除非你知道自己在做什么,否则你不应该去触碰 chunk_material.glsl、chunk_matrices.glsl 和 chunk_vertex.glsl。
获取 Sodium 光影源代码
要获取特定 Sodium 版本的光影源代码,请下载该版本的 .jar 文件并将其像 .zip 归档文件一样解压。在解压后的归档文件中,你会找到一个包含上述目录结构的 assets 文件夹。
block_layer_opaque
block_layer_opaque 用于所有方块和方块实体。原版的等效项是 terrain.fsh 和 terrain.vsh(在较旧的 Minecraft 版本中,等效项是 rendertype_solid、rendertype_cutout、rendertype_cutout_mipped 等)。
此外,Sodium Core Shader Support 在 Sodium 光影的 block_layer_opaque.fsh 和 block_layer_opaque.vsh 中添加了一些地形类型的定义:
RENDER_PASS_SOLID: 实心方块RENDER_PASS_CUTOUT: 如树叶、草、玻璃等方块RENDER_PASS_TRANSLUCENT: 具有实际透明度的方块,例如水、蜂蜜、史莱姆等
此外,定义 SODIUM_CORE_SHADER_SUPPORT 将存在于所有光影中(mc >= 1.21.2 且版本 >= 1.3.8)。这些定义可以这样使用:
#ifdef RENDER_PASS_SOLID
// 实心物体的特殊着色
#endif
GameTime Uniform
从 Sodium Core Shader Support 1.4.0 版本开始,u_GameTime uniform 将出现在 block_layer_opaque.fsh 和 block_layer_opaque.vsh 中。它可以像原版 GameTime uniform 一样使用。使用以下代码将其添加到你的光影中:
uniform float u_GameTime;
SunAngle Uniform
从 Sodium Core Shader Support 1.5.0 版本开始,u_SunAngle uniform 也将出现在 block_layer_opaque.fsh 和 block_layer_opaque.vsh 中。它以弧度形式返回来自环境属性的太阳角度。使用以下代码将其添加到你的光影中:
uniform float u_SunAngle;
如何指定支持的 Sodium 版本
Sodium 的开发者会更改其内部着色器及与着色器相关的代码,且不会另行通知。因此,重要的是要说明你的整合包与哪些版本的 Sodium 和 Minecraft 兼容。这可以通过一个特殊的 versions.json 文件来实现。该文件应位于资源包的 assets/sodiumcoreshadersupport 新目录中,文件名为 versions.json。文件内容可能如下所示:
{
"supported-versions": {
"1.21": [ "0.5.11+mc1.21" ],
"1.21.1": [ "0.5.11+mc1.21" ]
}
}
在上述示例中,资源包表明它与 Minecraft 1.21 和 1.21.1 上的 Sodium 0.5.11 兼容。
更具体的抽象描述如下:
具体来说,versions.json 必须包含一个键为 supported-versions 的对象。
supported-versions 的值必须是一个映射(map),它将不同的 Minecraft 版本映射到允许的 Sodium 版本数组。
SodiumCoreShaderSupport 模组将检查已安装的 Sodium 版本是否包含在已安装的 Minecraft 版本对应的数组中。
-
如果 Minecraft 和/或 Sodium 版本不在
supported-versions内,则可以在发出警告消息的情况下激活该资源包。 -
如果用户未安装 Sodium,则可以激活该资源包。
-
如果不存在 versions.json 文件,则可以在发出警告消息的情况下激活该资源包。
-
如果 versions.json 格式不正确,整合包仍可激活,但会显示警告消息。
导入
Sodium 光影文件必须放在 assets/sodium/shaders 目录中。但你可以使用 #import 指令从 assets/minecraft/shaders 导入文件。以下代码将包含文件 assets/minecraft/shaders/include/test.glsl:
#import <minecraft:include/test.glsl>
通过这个技巧,你可以创建自定义的 GLSL 文件,并在你的光影(包括核心光影和 Sodium 光影)中使用 #import 导入它们。这些文件应包含主要的光影“逻辑”。一个同时适用于原版和 Sodium 的光影包示例可以在这里找到。
禁用剔除
自 1.5.0 版本起,可以通过 versions.json 禁用 Sodium 的视锥剔除和背面剔除。这对于任何需要屏幕外几何体,或旨在通过 block.vsh 转换视角以显示通常不在屏幕上的几何体(例如阴影、替代玩家视角等)的核心光影非常有用。
{
"supported-versions": { "1.21.11": ["0.8.7+mc1.21.11"] },
"disable-frustum-culling": true,
"disable-backface-culling": true
}
鸣谢
感谢 MR-CHOO 添加 SunAngle Uniform 以及禁用视锥剔除和背面剔除 的功能!
Sodium Core Shader Support
[!IMPORTANT] This mod does not receive any further updates. Since Sodium 0.9.0 and Minecraft 26.2, sodium allows changing of Sodium shaders without this mod! If a specific pack does not work on Sodium, it means that the pack must be updated to the specific sodium 0.9.x version.
It is currently not planned to update this mod to older sodium/minecraft versions (e.g. 1.21.x).
Enables resourcepacks to replace sodium's shaders, similar to resourcepacks being able to replace vanilla's core shaders. If you like my mods consider supporting the development by buying me a coffee:
Documentation for Users
Sodium Core Shader Support allows resourcepacks to replace sodiums core shaders with their own. That does not mean, that
this mod makes every vanilla resourcepack work on sodium. The resourcepacks will only work if they specifically state, that
they are compatible with sodium core shader support.
If you are using a supported resourcepack you can simply activate it like any other resourcepack.
Resourcepack incompatible
Sodium may display the message The following resource packs are incompatible with Sodium in the top right corner after
reloading resources and listing your active core
shaders. This message will always appear, even if the resourcepack supports sodium core shaders and can be ignored.
List of Resourcepacks
This is a small list of resourcepacks that work on sodium. If you have created a resourcepack yourself feel free to open an issue on my github to add it to this list!
- Energy Shaders [Java]
- Night Vision Shaders [Java]
- Re-Shaded (since re-shaded version 1.3)
Documentation for Shader Developers
It is important to understand that your vanilla shaders cannot just be copied to sodium shaders. Sodium has their own shaders for blocks and clouds:
- assets/sodium/shaders/
| - clouds.fsh
| - clouds.vsh
| - blocks/
| - block_layer_opaque.fsh
| - block_layer_opaque.vsh
| - include/
| - fog.glsl
| - chunk_material.glsl
| - chunk_matrices.glsl
| - chunk_vertex.glsl
Unless you want to change sodium clouds the block_layer_opaque are usually the most important ones.
You should not have to touch chunk_material.glsl, chunk_matrices.glsl and chunk_vertex.glsl unless you know what you
are doing.
Retrieving sodium shaders source code
To retrieve the sodium shader source code for a specific sodium version, download the .jar file of that version and
extract it like a .zip archive. Inside the extracted archive you will find a assets folder containing the directory
structure mentioned above.
block_layer_opaque
The block_layer_opaque is used for all blocks and block entities. The vanilla minecraft equivalent is terrain.fsh
and terrain.vsh (In older versions of minecraft the equivalent is rendertype_solid, rendertype_cutout, rendertype_cutout_mipped, ...).
Additionally, sodium core shader support adds a few defines in the sodium shaders block_layer_opaque.fsh
and block_layer_opaque.vsh for some terrain-types:
RENDER_PASS_SOLID: Solid BlocksRENDER_PASS_CUTOUT: Blocks like leaves, grass, glass, ...RENDER_PASS_TRANSLUCENT: Blocks with actual transparency, e.g. water, honey, slime, ...
Furthermore, the define SODIUM_CORE_SHADER_SUPPORT will be present in all shaders (mc >= 1.21.2 and version >= 1.3.8).
These defines can be used like this:
#ifdef RENDER_PASS_SOLID
// special shading for solid stuff
#endif
GameTime Uniform
As of Sodium Core Shader Support version 1.4.0 the u_GameTime uniform will be present in block_layer_opaque.fsh
and block_layer_opaque.vsh. It can be used just like the vanilla GameTime uniform. Add it to your shaders using:
uniform float u_GameTime;
SunAngle Uniform
As of Sodium Core Shader Support version 1.5.0 the u_SunAngle uniform will be present in block_layer_opaque.fsh
and block_layer_opaque.vsh as well. It returns the sun angle from environmental attributes in radians. Add it to your shaders using:
uniform float u_SunAngle;
How to specify which sodium versions are supported
The sodium devs will change their internal shaders and shader related code without further notice. That's why it is
important that you specify with which versions of sodium and minecraft your pack is compatible. This can be done in a special
versions.json file. It should be located in your resourcepack in a new directory assets/sodiumcoreshadersupport with
the file name versions.json inside. The contents of the file could look like this:
{
"supported-versions": {
"1.21": [ "0.5.11+mc1.21" ],
"1.21.1": [ "0.5.11+mc1.21" ]
}
}
In the above example the resourcepack states, that it is compatible with sodium 0.5.11 on minecraft 1.21 and 1.21.1.
An abstract description is below:
More specifically, versions.json must contain a question object with the key supported-versions.
The value of supported-versions must be a map, which maps different minecraft versions to an array of allowed sodium versions.
The SodiumCoreShaderSupport mod will check if the installed sodium version is contained in the array of the installed minecraft version.
- If the minecraft and/or sodium version is not inside
supported-versions, the pack can be activated with a warning message. - If the user does not have sodium installed the pack can be activated.
- If no versions.json is present, the pack can be activated with a warning message.
- If the versions.json is malformed, the pack can be activated with a warning message.
Imports
Sodium Shaders must be in assets/sodium/shaders directory. But you can #import files from
assets/minecraft/shaders using the #import directive. The following code will include
the file assets/minecraft/shaders/include/test.glsl:
#import <minecraft:include/test.glsl>
With this trick you can create custom glsl files, which you can #import in your shaders (in both core shaders and sodium shaders).
These files, should contain your main shader "logic". An example shaderpack, which
works with this trick on both vanilla and sodium, can be found here.
Disable Culling
Since version 1.5.0, sodium's frustum and backface culling can be disabled via versions.json. This is useful for any core shader that requires offscreen geometry, or that aims to transform the view in block.vsh to show geometry not typically on screen (e.g. shadows, alternate player POVs, etc.)
{
"supported-versions": { "1.21.11": ["0.8.7+mc1.21.11"] },
"disable-frustum-culling": true,
"disable-backface-culling": true
}
Credits
Thanks to MR-CHOO for adding the SunAngle Uniform and the option to disable frustum and backface culling!
下载 Sodium Core Shader Support
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Sodium Core Shader Support
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Sodium Core Shader Support
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Sodium Core Shader Support
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Sodium Core Shader Support
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Sodium Core Shader Support
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Sodium Core Shader Support
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Sodium Core Shader Support
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Sodium Core Shader Support
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Sodium Core Shader Support
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
- 已更新到 Sodium 0.8.12
关于这个资源的讨论、问题反馈与使用心得
还没有讨论,来发第一帖吧
你是这个资源的作者?登录后可认领此资源。
相似资源
模组
让你能够在世界中的任何位置定位结构。
模组
TerraFirmaCraft (TFC) 是一个全面转换模组,对生存模式进行了彻底的改造与重新设计。
模组
一堆修复
模组
如果游戏能告知重要的刷新点,会怎样?
模组
一款适用于你选择的加载器的 Minecraft VR 模组!
模组
为盔甲架添加图形用户界面,允许你配置其姿势和其他属性
评论 0
登录后参与评分
还没有评论,来抢沙发吧