Shaderboard
Shaderboard 允许原版资源包后处理光影通过 命名绑定(named bindings) 读取客户端记分板数值。
绑定在光影的 JSON 文件(即定义其 Passes 的文件)中声明。该模组会将每个绑定转换为一个真正的 GLSL uniform block 并附带 GPU 缓冲区,并在每一帧用实时的记分板数值重写这些缓冲区。随后,光影可以按需使用这些数值。
声明绑定
在 后处理 JSON 文件的根层级添加 "shaderboard:bindings" 数组,位于 "targets" 和 "passes" 旁边。以下是一个示例:
{
"targets": { ... },
"passes": [ ... ],
"shaderboard:bindings":
[
{
"uniform_name": "u_SteveScore",
"type": "shaderboard:scoreboard_objective",
"objective": "example_1",
"target": { "type": "player", "name": "Steve" }
}
]
}
参数说明:
uniform_name- 绑定所创建的 GLSL uniform block 的名称。type- 绑定类型。即绑定暴露的信息类型。
当 type 为 shaderboard:scoreboard_objective:
objective- 记分板目标名称。target- 定义要绑定哪个目标的分值。type- 要绑定的目标类型;本地玩家的分值(local_player)、特定玩家的分值(player)、最高分值(top_player),或固定大小的分值数组(array)。name- 当type为player时,此附加字段定义“哪位玩家”。
注意: 这仅仅是众多可能性中的一个示例;从传递分值数组到传递其他客户端信息等等。请参阅 wiki 以获取更多信息。
在 GLSL 中读取绑定的值
重要: 记分板分值是服务端的数据,默认情况下不会同步给客户端。为解决此问题,请使用以下两种解决方案之一:
/scoreboard objectives setdisplay ...- 使原版游戏通过将目标在屏幕上视觉显示来将目标的数值同步给客户端。/scoreboard objectives shaderboard:sync ...(v2.4.0+) - 此模组在后端同步目标数值给客户端的方法,无需使用setdisplay。需要在服务端安装此模组。
每个绑定的 uniform_name 都会成为一个 layout(std140) uniform block。其内容由绑定的 值类型 定义。标量记分板目标会产生单个 int:
layout(std140) uniform u_TopScore { int topScore; };
layout(std140) uniform u_SortedScoresAZ { int sortedScores[16]; };
void main()
{
//基础输出颜色
fragColor = texture(InSampler, texCoord);
//...在此处随意使用 'topScore' 和 'sortedScores'...
}
快速演示
此模组包含一个 ID 为 shaderboard:example_1 的示例 /posteffect。您可以按顺序使用以下命令进行尝试:
/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
此示例光影从 example_1 目标读取记分板数值,并以二进制条纹的形式渲染在屏幕上。
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
/posteffectcommand shaders. It does not target shaders from mods like Iris and Optifine.
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_SteveScore",
"type": "shaderboard:scoreboard_objective",
"objective": "example_1",
"target": { "type": "player", "name": "Steve" }
}
]
}
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".
Note: This is just one example of many possibilitis; from passing arrays of scores to passing other client-sided information, etc etc. Please refer to the wiki for more information.
Reading a binding's value in GLSL
Important: Scoreboard scores are server-sided and by default do not synchronize with clients. To resolve this, use one of the two following solutions:
/scoreboard objectives setdisplay ...- Makes the vanilla game synchronize an objective's values with the client by visually displaying it on-screen./scoreboard objectives shaderboard:sync ...(v2.4.0+) - This mod's way of synchronizing objective values with clients in the background, without needingsetdisplay. Requires installing this mod on the server-side.
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
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Shaderboard
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Shaderboard
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Shaderboard
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Shaderboard
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Shaderboard
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Shaderboard
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
正如您可能已经看到的,记分板值是服务器端的,这迫使玩家必须使用 setdisplay 才能让客户端看到这些值。然而,这样做很不方便,特别是当您希望将这些值保持在屏幕外时。这就是本次更新的作用所在!
- 添加了
/scoreboard objectives shaderboard:sync ...命令。它允许服务器在后台完全同步记分板目标与客户端的值。告别setdisplay!- 注意: 该功能在服务器端和客户端均为可选。使用此功能需要在服务器端安装本模组,但这是可选的,您也不需要使用此功能。不要求客户端安装本模组。
关于这个资源的讨论、问题反馈与使用心得
还没有讨论,来发第一帖吧
你是这个资源的作者?登录后可认领此资源。
相似资源
模组
一个用于收集生物掉落物的多区块模组。
模组
显示你正在注视的方块的信息。(适用于 Minecraft 1.16+ 的 Hwyla/Waila 分支)
模组
使用 JavaScript 编辑配方、添加自定义物品、编写世界事件!
模组
查看物品与配方
模组
在游戏画面角落显示附近世界地形、玩家、生物和实体的地图。可创建路径点,帮助你找到标记过的位置。
模组
AE2:一款流行的自动化与存储模组
评论 0
登录后参与评分
还没有评论,来抢沙发吧