Shaderboard
A Minecraft mod that exposes client-side scoreboard values to post-effect shaders via named bindings.
介绍
Shaderboard
Shaderboard lets vanilla resource-pack post-effect shaders read client-side scoreboard values through named bindings.
A binding is declared inside a post-effect’s JSON file (the same file that defines its passes). This mod turns each binding into a real GLSL uniform block with a GPU buffer, and rewrites those buffers with live scoreboard values every frame. Shaders can then use those values however they like.
> Note: This mod is for vanilla /posteffect command shaders. It does not target shaders from mods like Iris and Optifine.
> IMPORTANT: Scoreboard scores are server-sided and by default do not synchronize with clients. Use /scoreboard objectives setdisplay ... to get an objective’s scores to synchronize with clients, so post-effect shaders can read them.
Declaring bindings
Add a "shaderboard:bindings" array at the root of a post-effect JSON, next to "targets" and "passes". Here is an example:
{
"targets": { ... },
"passes": [ ... ],
"shaderboard:bindings":
[
{
"uniform_name": "u_TopScore",
"type": "shaderboard:scoreboard_objective",
"objective": "example_1",
"target": { "type": "top_player" }
},
{
"uniform_name": "u_MyScore",
"type": "shaderboard:scoreboard_objective",
"objective": "example_1",
"target": { "type": "local_player" }
},
{
"uniform_name": "u_SteveScore",
"type": "shaderboard:scoreboard_objective",
"objective": "example_1",
"target": { "type": "player", "name": "Steve" }
},
{
"uniform_name": "u_SortedScoresAZ",
"type": "shaderboard:scoreboard_objective",
"objective": "example_1",
"target":
{
"type": "array",
"count": 16,
"include_hidden": true,
"sort": [
{ "by": "name", "order": "ascending" }
],
"offset": 0
}
}
]
}
Where:
uniform_name– Name of the GLSL uniform block a binding creates.type– Binding type. I.e. the type of information a binding exposes.
When type is shaderboard:scoreboard_objective:
objective– Scoreboard objective name.target– Defines which score of an objective to bind.type– The type of target to bind to; local player’s score (local_player), a specific player’s score (player), the top score (top_player), or a fixed-size array of scores (array).name– Whentypeisplayer, this additional field defines "which player".include_hidden– Whentypeistop_playerorarray; Whether to include hidden scores (whose names start with#). Defaults tofalse.count– Required forarray: fixed array length, from1to128.sort– Whentypeisarray; optional array of sort keys. Each entry requiresby(nameorvalue) andorder(ascendingordescending).offset– Whentypeistop_playerorarray; number of sorted scores to skip. Defaults to0.
Reading a binding’s value in GLSL
Each binding’s uniform_name becomes a layout(std140) uniform block. Its contents are defined by the binding’s value type. Scalar scoreboard targets produce a single int:
layout(std140) uniform u_TopScore { int topScore; };
layout(std140) uniform u_SortedScoresAZ { int sortedScores[16]; };
void main()
{
//base output color
fragColor = texture(InSampler, texCoord);
//...use 'topScore' and 'sortedScores' however you'd like here...
}
Quick demo
This mod includes an example /posteffect of ID shaderboard:example_1. You may try it out using the following commands in order:
/posteffect add @p shaderboard:example_1
/scoreboard objectives add example_1 dummy "Example 1"
/scoreboard objectives setdisplay sidebar example_1
/scoreboard players set @p example_1 123
/scoreboard players set Steve example_1 456
This example shader reads scoreboard values from the example_1 objective and renders them on-screen as binary stripes.
常见问题
Shaderboard 支持哪些 Minecraft 版本?
Shaderboard 支持 Minecraft Java 版 26.3,可用的加载器:Fabric / NeoForge。下载时注意选择和你游戏版本一致的文件。
Shaderboard 怎么安装?
先用 PCL2 或 HMCL 启动器安装对应版本的 Fabric / NeoForge,再把下载的 .jar 文件放进游戏目录的 mods 文件夹,重新启动游戏即可。开启了版本隔离的,mods 文件夹在 versions/版本名 下面。
TheCSDev 的其他作品
查看全部 →更好的统计信息界面 Better Statistics Screen
一个改进统计信息界面并使其更实用的Minecraft模组。
TCDCommons API
TheCSDev 的个人前置库模组,用于 Minecraft 模组开发环境。
[📦] No Unused Chunks
一款通过丢弃未使用区块来缩小世界体积的 Minecraft 模组。
[📦] Chunk Copy (Fabric)
一款客户端模组,可从多人服务器下载(复制)地图。
评论
登录后评论和评分