Lightmap.java
net.minecraft.client.renderer.Lightmap
信息
- 全限定名:net.minecraft.client.renderer.Lightmap
- 类型:public class
- 包:net.minecraft.client.renderer
- 源码路径:src/main/java/net/minecraft/client/renderer/Lightmap.java
- 起始行号:L23
- 实现:AutoCloseable
- 职责:
TODO
字段/常量
-
TEXTURE_SIZE- 类型:
int - 修饰符:
public static final - 源码定位:
L24 - 说明:
TODO
- 类型:
-
LIGHTMAP_UBO_SIZE- 类型:
int - 修饰符:
private static final - 源码定位:
L25 - 说明:
TODO
- 类型:
-
texture- 类型:
GpuTexture - 修饰符:
private final - 源码定位:
L37 - 说明:
TODO
- 类型:
-
textureView- 类型:
GpuTextureView - 修饰符:
private final - 源码定位:
L38 - 说明:
TODO
- 类型:
-
ubo- 类型:
MappableRingBuffer - 修饰符:
private final - 源码定位:
L39 - 说明:
TODO
- 类型:
内部类/嵌套类型
- 无
构造器
public Lightmap() @ L41
- 构造器名:Lightmap
- 源码定位:L41
- 修饰符:public
参数:
- 无
说明:
TODO
方法
下面的方法块按源码顺序生成。
public GpuTextureView getTextureView() @ L49
- 方法名:getTextureView
- 源码定位:L49
- 返回类型:GpuTextureView
- 修饰符:public
参数:
- 无
说明:
TODO
public void close() @ L53
- 方法名:close
- 源码定位:L53
- 返回类型:void
- 修饰符:public
参数:
- 无
说明:
TODO
public void render(LightmapRenderState renderState) @ L60
- 方法名:render
- 源码定位:L60
- 返回类型:void
- 修饰符:public
参数:
- renderState: LightmapRenderState
说明:
TODO
public static float getBrightness(DimensionType dimensionType, int level) @ L92
- 方法名:getBrightness
- 源码定位:L92
- 返回类型:float
- 修饰符:public static
参数:
- dimensionType: DimensionType
- level: int
说明:
TODO
代码
@OnlyIn(Dist.CLIENT)
public class Lightmap implements AutoCloseable {
public static final int TEXTURE_SIZE = 16;
private static final int LIGHTMAP_UBO_SIZE = new Std140SizeCalculator()
.putFloat()
.putFloat()
.putFloat()
.putFloat()
.putFloat()
.putFloat()
.putVec3()
.putVec3()
.putVec3()
.putVec3()
.get();
private final GpuTexture texture;
private final GpuTextureView textureView;
private final MappableRingBuffer ubo;
public Lightmap() {
GpuDevice device = RenderSystem.getDevice();
this.texture = device.createTexture("Lightmap", 13, TextureFormat.RGBA8, 16, 16, 1, 1);
this.textureView = device.createTextureView(this.texture);
device.createCommandEncoder().clearColorTexture(this.texture, -1);
this.ubo = new MappableRingBuffer(() -> "Lightmap UBO", 130, LIGHTMAP_UBO_SIZE);
}
public GpuTextureView getTextureView() {
return this.textureView;
}
@Override
public void close() {
this.texture.close();
this.textureView.close();
this.ubo.close();
}
public void render(LightmapRenderState renderState) {
if (renderState.needsUpdate) {
ProfilerFiller profiler = Profiler.get();
profiler.push("lightmap");
CommandEncoder commandEncoder = RenderSystem.getDevice().createCommandEncoder();
try (GpuBuffer.MappedView view = commandEncoder.mapBuffer(this.ubo.currentBuffer(), false, true)) {
Std140Builder.intoBuffer(view.data())
.putFloat(renderState.skyFactor)
.putFloat(renderState.blockFactor)
.putFloat(renderState.nightVisionEffectIntensity)
.putFloat(renderState.darknessEffectScale)
.putFloat(renderState.bossOverlayWorldDarkening)
.putFloat(renderState.brightness)
.putVec3(renderState.blockLightTint)
.putVec3(renderState.skyLightColor)
.putVec3(renderState.ambientColor)
.putVec3(renderState.nightVisionColor);
}
try (RenderPass renderPass = commandEncoder.createRenderPass(() -> "Update light", this.textureView, OptionalInt.empty())) {
renderPass.setPipeline(RenderPipelines.LIGHTMAP);
RenderSystem.bindDefaultUniforms(renderPass);
renderPass.setUniform("LightmapInfo", this.ubo.currentBuffer());
renderPass.draw(0, 3);
}
this.ubo.rotate();
profiler.pop();
}
}
public static float getBrightness(DimensionType dimensionType, int level) {
float v = level / 15.0F;
float curvedV = v / (4.0F - 3.0F * v);
return Mth.lerp(dimensionType.ambientLight(), curvedV, 1.0F);
}
}引用的其他类
-
- 引用位置:
方法调用 - 关联成员:
Std140Builder.intoBuffer()
- 引用位置:
-
- 引用位置:
构造调用 - 关联成员:
Std140SizeCalculator()
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
RenderSystem.bindDefaultUniforms(), RenderSystem.getDevice()
- 引用位置:
-
- 引用位置:
字段
- 引用位置:
-
- 引用位置:
字段/返回值
- 引用位置:
-
- 引用位置:
字段/构造调用 - 关联成员:
MappableRingBuffer()
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
Mth.lerp()
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
Profiler.get()
- 引用位置:
-
- 引用位置:
参数
- 引用位置: