re-add lighting
This commit is contained in:
+6
-1
@@ -1,7 +1,11 @@
|
||||
package com.seibel.distanthorizons.common.renderTest;
|
||||
|
||||
import com.mojang.blaze3d.vertex.VertexFormatElement;
|
||||
import com.seibel.distanthorizons.core.dataObjects.render.bufferBuilding.LodQuadBuilder;
|
||||
|
||||
/**
|
||||
* @see LodQuadBuilder
|
||||
*/
|
||||
public class DhVertexFormat
|
||||
{
|
||||
public static final VertexFormatElement SCREEN_POS = VertexFormatElement.register(/*id*/7, /*index*/0, VertexFormatElement.Type.FLOAT, VertexFormatElement.Usage.POSITION, /*count*/ 2);
|
||||
@@ -9,7 +13,8 @@ public class DhVertexFormat
|
||||
|
||||
public static final VertexFormatElement SHORT_POS = VertexFormatElement.register(/*id*/9, /*index*/0, VertexFormatElement.Type.USHORT, VertexFormatElement.Usage.POSITION, /*count*/ 3);
|
||||
public static final VertexFormatElement BYTE_PAD = VertexFormatElement.register(/*id*/10, /*index*/0, VertexFormatElement.Type.BYTE, VertexFormatElement.Usage.GENERIC, /*count*/ 1);
|
||||
public static final VertexFormatElement LIGHT = VertexFormatElement.register(/*id*/11, /*index*/0, VertexFormatElement.Type.UBYTE, VertexFormatElement.Usage.GENERIC, /*count*/ 1);
|
||||
/** contains light and micro-offset */
|
||||
public static final VertexFormatElement META = VertexFormatElement.register(/*id*/11, /*index*/0, VertexFormatElement.Type.USHORT, VertexFormatElement.Usage.GENERIC, /*count*/ 1);
|
||||
public static final VertexFormatElement RGBA_UBYTE_COLOR = VertexFormatElement.register(/*id*/12, /*index*/0, VertexFormatElement.Type.UBYTE, VertexFormatElement.Usage.COLOR, /*count*/ 4);
|
||||
public static final VertexFormatElement IRIS_MATERIAL = VertexFormatElement.register(/*id*/13, /*index*/0, VertexFormatElement.Type.BYTE, VertexFormatElement.Usage.GENERIC, /*count*/ 1);
|
||||
public static final VertexFormatElement IRIS_NORMAL = VertexFormatElement.register(/*id*/14, /*index*/0, VertexFormatElement.Type.BYTE, VertexFormatElement.Usage.GENERIC, /*count*/ 1);
|
||||
|
||||
+17
-5
@@ -18,6 +18,7 @@ import com.mojang.blaze3d.textures.*;
|
||||
import com.mojang.blaze3d.vertex.VertexFormat;
|
||||
import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhApiRenderParam;
|
||||
import com.seibel.distanthorizons.api.objects.math.DhApiVec3f;
|
||||
import com.seibel.distanthorizons.common.wrappers.misc.LightMapWrapper;
|
||||
import com.seibel.distanthorizons.core.config.Config;
|
||||
import com.seibel.distanthorizons.core.dataObjects.render.bufferBuilding.LodBufferContainer;
|
||||
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
||||
@@ -25,6 +26,7 @@ import com.seibel.distanthorizons.core.logging.DhLogger;
|
||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||
import com.seibel.distanthorizons.core.render.glObject.GLEnums;
|
||||
import com.seibel.distanthorizons.core.render.glObject.buffer.QuadElementBuffer;
|
||||
import com.seibel.distanthorizons.core.render.renderer.RenderParams;
|
||||
import com.seibel.distanthorizons.core.util.ColorUtil;
|
||||
import com.seibel.distanthorizons.core.util.RenderUtil;
|
||||
import com.seibel.distanthorizons.core.util.math.Mat4f;
|
||||
@@ -80,8 +82,7 @@ public class McLodRenderer implements IMcLodRenderer
|
||||
{
|
||||
this.vertexFormat = VertexFormat.builder()
|
||||
.add("vPosition", DhVertexFormat.SHORT_POS)
|
||||
.add("paddingOne", DhVertexFormat.BYTE_PAD)
|
||||
.add("light", DhVertexFormat.LIGHT)
|
||||
.add("meta", DhVertexFormat.META)
|
||||
.add("vColor", DhVertexFormat.RGBA_UBYTE_COLOR)
|
||||
.add("irisMaterial", DhVertexFormat.IRIS_MATERIAL)
|
||||
.add("irisNormal", DhVertexFormat.IRIS_NORMAL)
|
||||
@@ -116,7 +117,7 @@ public class McLodRenderer implements IMcLodRenderer
|
||||
pipelineBuilder.withVertexShader(Identifier.fromNamespaceAndPath("distanthorizons", "lod/vert"));
|
||||
pipelineBuilder.withFragmentShader(Identifier.fromNamespaceAndPath("distanthorizons", "lod/frag"));
|
||||
|
||||
//pipelineBuilder.withSampler("uLightMap"); // TODO
|
||||
pipelineBuilder.withSampler("uLightMap");
|
||||
|
||||
pipelineBuilder.withUniform("vertUniformBlock", UniformType.UNIFORM_BUFFER);
|
||||
pipelineBuilder.withUniform("fragUniformBlock", UniformType.UNIFORM_BUFFER);
|
||||
@@ -154,7 +155,7 @@ public class McLodRenderer implements IMcLodRenderer
|
||||
|
||||
@Override
|
||||
public void render(
|
||||
DhApiRenderParam renderEventParam,
|
||||
RenderParams renderEventParam,
|
||||
boolean opaquePass,
|
||||
DhApiVec3f modelOffset,
|
||||
IVertexBufferWrapper[] bufferList,
|
||||
@@ -338,8 +339,19 @@ public class McLodRenderer implements IMcLodRenderer
|
||||
//renderPass.popDebugGroup();
|
||||
|
||||
|
||||
//renderPass.bindTexture("uLightMap", );
|
||||
// bind MC color texture
|
||||
{
|
||||
LightMapWrapper lightMapWrapper = (LightMapWrapper) renderEventParam.lightmap;
|
||||
|
||||
GpuTextureView textureView = gpuDevice.createTextureView(lightMapWrapper.gpuTexture);
|
||||
GpuSampler gpuSampler = gpuDevice.createSampler(
|
||||
AddressMode.CLAMP_TO_EDGE, AddressMode.CLAMP_TO_EDGE, // U,V
|
||||
FilterMode.NEAREST, FilterMode.NEAREST, // minFilter, magFilter
|
||||
1, // maxAnisotropy
|
||||
OptionalDouble.empty() // maxLod
|
||||
);
|
||||
renderPass.bindTexture("uLightMap", textureView, gpuSampler);
|
||||
}
|
||||
|
||||
|
||||
renderPass.setUniform("vertUniformBlock", this.vertUniformBuffer);
|
||||
|
||||
+11
@@ -25,6 +25,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import com.mojang.blaze3d.pipeline.RenderTarget;
|
||||
import com.mojang.blaze3d.platform.NativeImage;
|
||||
import com.mojang.blaze3d.textures.GpuTexture;
|
||||
import com.seibel.distanthorizons.api.enums.config.EDhApiLodShading;
|
||||
import com.seibel.distanthorizons.common.wrappers.McObjectConverter;
|
||||
import com.seibel.distanthorizons.common.wrappers.misc.LightMapWrapper;
|
||||
@@ -488,6 +489,16 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper
|
||||
LightMapWrapper wrapper = this.lightmapByDimensionType.computeIfAbsent(dimensionType, (dimType) -> new LightMapWrapper());
|
||||
wrapper.setLightmapId(tetxureId);
|
||||
}
|
||||
public void setLightmapGpuTexture(GpuTexture gpuTexture, IClientLevelWrapper level)
|
||||
{
|
||||
// Using ClientLevelWrapper as the key would be better, but we don't have a consistent way to create the same
|
||||
// object for the same MC level and/or the same hash,
|
||||
// so this will have to do for now
|
||||
IDimensionTypeWrapper dimensionType = level.getDimensionType();
|
||||
|
||||
LightMapWrapper wrapper = this.lightmapByDimensionType.computeIfAbsent(dimensionType, (dimType) -> new LightMapWrapper());
|
||||
wrapper.setLightmapGpuTexture(gpuTexture);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getShade(EDhDirection lodDirection)
|
||||
|
||||
+8
@@ -20,6 +20,7 @@
|
||||
package com.seibel.distanthorizons.common.wrappers.misc;
|
||||
|
||||
import com.mojang.blaze3d.platform.NativeImage;
|
||||
import com.mojang.blaze3d.textures.GpuTexture;
|
||||
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftGLWrapper;
|
||||
@@ -38,6 +39,7 @@ public class LightMapWrapper implements ILightMapWrapper
|
||||
private static final DhLogger LOGGER = new DhLoggerBuilder().build();
|
||||
|
||||
private int textureId = 0;
|
||||
public GpuTexture gpuTexture = null;
|
||||
|
||||
|
||||
|
||||
@@ -99,6 +101,12 @@ public class LightMapWrapper implements ILightMapWrapper
|
||||
this.textureId = minecraftLightmapTextureId;
|
||||
}
|
||||
|
||||
public void setLightmapGpuTexture(GpuTexture gpuTexture)
|
||||
{
|
||||
// just use the MC texture ID
|
||||
this.gpuTexture = gpuTexture;
|
||||
}
|
||||
|
||||
//endregion
|
||||
|
||||
|
||||
|
||||
+1
-1
Submodule coreSubProjects updated: 3f509be195...200e089a33
+3
-2
@@ -94,8 +94,9 @@ public class MixinLightTexture
|
||||
#elif MC_VER < MC_1_21_5
|
||||
this.renderWrapper.setLightmapId(this.target.getColorTextureId(), clientLevel);
|
||||
#else
|
||||
GlTexture glTexture = (GlTexture) this.texture;
|
||||
this.renderWrapper.setLightmapId(glTexture.glId(), clientLevel);
|
||||
//GlTexture glTexture = (GlTexture) this.texture;
|
||||
//this.renderWrapper.setLightmapId(glTexture.glId(), clientLevel);
|
||||
this.renderWrapper.setLightmapGpuTexture(this.texture, clientLevel);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
+3
-2
@@ -86,8 +86,9 @@ public class MixinLightTexture
|
||||
GlTexture glTexture = (GlTexture) this.texture;
|
||||
renderWrapper.setLightmapId(glTexture.glId(), clientLevel);
|
||||
#else
|
||||
int id = NeoforgeTextureUnwrapper.getGlTextureIdFromGpuTexture(this.texture);
|
||||
renderWrapper.setLightmapId(id, clientLevel);
|
||||
//int id = NeoforgeTextureUnwrapper.getGlTextureIdFromGpuTexture(this.texture);
|
||||
//renderWrapper.setLightmapId(id, clientLevel);
|
||||
renderWrapper.setLightmapGpuTexture(this.texture, clientLevel);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user