Colored Light Helpers

基本信息

client/ 下两个客户端侧的着色辅助类(纯客户端,服务器不加载)。

类 文件 行
ColoredLightHelper client/ColoredLightHelper.java 253
EntityColoredLightHelper client/EntityColoredLightHelper.java 97

ColoredLightHelper:方块顶点着色

负责把 RGB 光照映射成给渲染器用的 float[3] 色调。

成员 说明
interface TintFunction 函数式接口,computeTint(br,bg,bb,sr,sg,sb,out) —— 方块 RGB + 天光 RGB → 色调
activeTintFunction private static volatile,默认 (…)-> TintBlendMode.current.computeTint(…)
setActiveTintFunction(TintFunction) 由 Angelica Compat 调用,把查表改道到 Angelica 的 TintRegistry
NO_TINT {1.0f, 1.0f, 1.0f}
VERTEX_TINTS float[4][3],角点序 TL / BL / BR / TR

复用缓冲区警告(源码明确写出): RESULT 与 VERTEX_TINTS 都是复用的返回缓冲, 调用方必须在同线程的下一次调用前消费完毕。

readLight 的返回布局 ≠ PackedColorLight

ColoredLightHelper.readLight 返回的是六通道合并值, 每通道 4 bit、紧邻排列(不是 PackedColorLight 的字节间隔 0x0R0G0B):

移位 通道
0 / 4 / 8 方块光 R / G / B
12 / 16 / 20 天光 R / G / B

对比 Packed Color Light 的 BLUE_SHIFT=0 / GREEN_SHIFT=8 / RED_SHIFT=16(通道相隔 8 bit)。 两套布局不能混用。

EntityColoredLightHelper:实体着色

用 GL 纹理合成器给实体上色,只占用 texture unit 2; unit 0(实体贴图)与 unit 1(lightmap)不动。 unit 2 把合成结果(GL_PREVIOUS)乘上一个常量 RGB 色调, 该色调来自实体位置的逐通道方块光。

成员 值
TINT_BUFFER BufferUtils.createFloatBuffer(4)
tintActive private static boolean
无着色时 getEntityTint 返回 NO_TINT({1,1,1})

getEntityTint(world, posX, posY, posZ, eyeHeight) 用 Math.floor 取整;world == null 或 readLight 返回 < 0(无彩色方块光 / 区块不可用) 时返回 NO_TINT。

天光按时间衰减

ColoredLightHelper 用 world.skylightSubtracted 调制天光分量:

final float sub = world.skylightSubtracted;
final float effSkyR = Math.max(0, maxSkyR - sub);

即天光通道各自减去 skylightSubtracted 并夹在 0 以下。 方块光分量不做此衰减(maxBlock* 直接传入 computeTint)。

若计算结果三通道都 >= 1.0f,直接返回 NO_TINT 跳过混合。

相关条目

源码

  • src/main/java/com/mitchej123/supernova/client/ColoredLightHelper.java
  • src/main/java/com/mitchej123/supernova/client/EntityColoredLightHelper.java