Rendering emissive meshes

Hey, could anyone please help me with a specific rendering bug? (1.20.1) I want to render emissive lines and quads that receive bloom post processing from shaders I tried the following, which should render the plane just like the eyes of an enderman:
WorldRenderEvents.BEFORE_ENTITIES.register(context -> {
MinecraftClient mc = MinecraftClient.getInstance();
MatrixStack matrixStack = context.matrixStack();
VertexConsumerProvider.Immediate immediate = mc.getBufferBuilders().getEntityVertexConsumers();
VertexConsumer vertexConsumer = immediate.getBuffer(RenderLayer.getText(new Identifier("minecraft", "textures/entity/enderman/enderman_eyes.png");));

matrixStack.push();

matrixStack.translate(-mc.gameRenderer.getCamera().getPos().x, -mc.gameRenderer.getCamera().getPos().y, -mc.gameRenderer.getCamera().getPos().z);
drawTri(matrixStack, vertexConsumer, new Vec3d(0, 100, 0), new Vec3d(5, 100, 5));

matrixStack.pop();
immediate.draw();
});
WorldRenderEvents.BEFORE_ENTITIES.register(context -> {
MinecraftClient mc = MinecraftClient.getInstance();
MatrixStack matrixStack = context.matrixStack();
VertexConsumerProvider.Immediate immediate = mc.getBufferBuilders().getEntityVertexConsumers();
VertexConsumer vertexConsumer = immediate.getBuffer(RenderLayer.getText(new Identifier("minecraft", "textures/entity/enderman/enderman_eyes.png");));

matrixStack.push();

matrixStack.translate(-mc.gameRenderer.getCamera().getPos().x, -mc.gameRenderer.getCamera().getPos().y, -mc.gameRenderer.getCamera().getPos().z);
drawTri(matrixStack, vertexConsumer, new Vec3d(0, 100, 0), new Vec3d(5, 100, 5));

matrixStack.pop();
immediate.draw();
});
And here the drawTri (it should be drawQuad):
private void drawTri(MatrixStack matrixStack, VertexConsumer vertexConsumer, Vec3d start, Vec3d end) {
float startX = (float) start.x;
float startY = (float) start.y;
float startZ = (float) start.z;

float endX = (float) end.x;
float endY = (float) end.y;
float endZ = (float) end.z;

int light = 0xF000F0; // Full brightness
int overlay = OverlayTexture.DEFAULT_UV;

// Texture coordinates - center of the texture
float textureU = (0.125f + (1f / 64f) / 2f);
float textureV = (0.375f + (1f / 32f) / 2f);

// Normal vector - upward direction
float normalX = 0.0f;
float normalY = 1.0f;
float normalZ = 0.0f;

int color = 255;

Matrix4f model = matrixStack.peek().getPositionMatrix();
Matrix3f normal = matrixStack.peek().getNormalMatrix();



vertexConsumer.vertex(model, startX, startY, startZ)
.color(color, color, color, 255)
.texture(textureU, textureV)
.overlay(overlay)
.light(light)
.normal(normal, normalX, normalY, normalZ)
.next();
vertexConsumer.vertex(model, startX, startY, endZ)
.color(color, color, color, 255)
.texture(textureU, textureV)
.overlay(overlay)
.light(light)
.normal(normal, normalX, normalY, normalZ)
.next();
vertexConsumer.vertex(model, endX, startY, endZ)
.color(color, color, color, 255)
.texture(textureU, textureV)
.overlay(overlay)
.light(light)
.normal(normal, normalX, normalY, normalZ)
.next();
vertexConsumer.vertex(model, endX, startY, startZ)
.color(color, color, color, 255)
.texture(textureU, textureV)
.overlay(overlay)
.light(light)
.normal(normal, normalX, normalY, normalZ)
.next();
}
private void drawTri(MatrixStack matrixStack, VertexConsumer vertexConsumer, Vec3d start, Vec3d end) {
float startX = (float) start.x;
float startY = (float) start.y;
float startZ = (float) start.z;

float endX = (float) end.x;
float endY = (float) end.y;
float endZ = (float) end.z;

int light = 0xF000F0; // Full brightness
int overlay = OverlayTexture.DEFAULT_UV;

// Texture coordinates - center of the texture
float textureU = (0.125f + (1f / 64f) / 2f);
float textureV = (0.375f + (1f / 32f) / 2f);

// Normal vector - upward direction
float normalX = 0.0f;
float normalY = 1.0f;
float normalZ = 0.0f;

int color = 255;

Matrix4f model = matrixStack.peek().getPositionMatrix();
Matrix3f normal = matrixStack.peek().getNormalMatrix();



vertexConsumer.vertex(model, startX, startY, startZ)
.color(color, color, color, 255)
.texture(textureU, textureV)
.overlay(overlay)
.light(light)
.normal(normal, normalX, normalY, normalZ)
.next();
vertexConsumer.vertex(model, startX, startY, endZ)
.color(color, color, color, 255)
.texture(textureU, textureV)
.overlay(overlay)
.light(light)
.normal(normal, normalX, normalY, normalZ)
.next();
vertexConsumer.vertex(model, endX, startY, endZ)
.color(color, color, color, 255)
.texture(textureU, textureV)
.overlay(overlay)
.light(light)
.normal(normal, normalX, normalY, normalZ)
.next();
vertexConsumer.vertex(model, endX, startY, startZ)
.color(color, color, color, 255)
.texture(textureU, textureV)
.overlay(overlay)
.light(light)
.normal(normal, normalX, normalY, normalZ)
.next();
}
which results in this:
No description
15 Replies
Sinan
SinanOP•17mo ago
In rethinking voxels, it receives shading and lighting, which I don't want, I would like it to be unlit (I also tried different renderlayers, none worked, all received shading in rethinking voxels, however in BSL they all seemed to 'work') ultimately, I'd like to render pixel HDR values >1 so that the bloom effect amplifies Or in other words: I just need some code that renders emissive lines and quads (emissive meaning unlit) that works with rethinking voxel shaders can anyone please help? :) (I also tried my own shader, copied the core shader of eyes, loaded it with my own renderlayer BUT when loading shaders, it disappeared)
Sinan
SinanOP•17mo ago
second solution in vanilla (seems fine)
No description
Sinan
SinanOP•17mo ago
(second solution with BSL or Rethinking Voxels, is just gone)
No description
Sinan
SinanOP•17mo ago
But I think the second solution is a deadend. Regarding the first (copying the RenderLayer of eye rendering), it works AWESOME in BSL shaders (left) but not at all with rethinking voxels (right)
Sinan
SinanOP•17mo ago
No description
Sinan
SinanOP•17mo ago
Any help is greatly appreciated 😊 (I added the vertexConsumer code) I fixed it!
IMS
IMS•17mo ago
this is the intended way, if it isn't working it's probably the shader itself ignoring anything that's not known spiders/endermen
Sinan
SinanOP•17mo ago
Actually I think it can't know what is a mob and what not?
IMS
IMS•17mo ago
it can
Sinan
SinanOP•17mo ago
I was just using RenderLayer.getText instead of getEyes, lmao
IMS
IMS•17mo ago
because iris provides that info
Sinan
SinanOP•17mo ago
Really?
IMS
IMS•17mo ago
yeah it does some injections to map an entity to an integer ID
Sinan
SinanOP•17mo ago
Damn, then the shader did not check for that
IMS
IMS•17mo ago
so individual entities can be singled out generally, shaders just assume eyes means emissive, because it's a lot of work to manually check everything
Want results from more Discord servers?
Add your server