Drawing lines on the screen on WorldRenderEvents.LAST

When I enable shaders, lines rendering works with below code (but it looks like my lines are affected by postprocessing shaders):
var buffer = Tesselator.getInstance().getBuilder();
buffer.begin(VertexFormat.Mode.DEBUG_LINES, DefaultVertexFormat.POSITION_COLOR);
buffer.vertex(x, y, z).color(r, g, b, a).endVertex();
// other vertexes
vertexBuffer.drawWithShader(modelViewMatrix, projectionMatrix, GameRenderer.getPositionColorShader());
VertexBuffer.unbind();
var buffer = Tesselator.getInstance().getBuilder();
buffer.begin(VertexFormat.Mode.DEBUG_LINES, DefaultVertexFormat.POSITION_COLOR);
buffer.vertex(x, y, z).color(r, g, b, a).endVertex();
// other vertexes
vertexBuffer.drawWithShader(modelViewMatrix, projectionMatrix, GameRenderer.getPositionColorShader());
VertexBuffer.unbind();
However when I use my own custom lines renderer with my own shaders - nothing is rendered. It is very basic code with compiling shaders, creating program, VBO/VAO, uploading buffer, GL30.glDrawArrays(GL30.GL_LINES, 0, buffer.vertices());, etc Any idea why my low level code doesn't draw anything?
4 Replies
IMS
IMS9mo ago
this is due to how shaders inherently work sorry for the late reply btw shaders do not render to the main framebuffer ever, but rather to arbritary color textures with their own information they then composite this information together WorldRenderEvents.LAST is still too early you'd need to do it at the very end of renderLevel
Zergatul
Zergatul9mo ago
thanks for the reply!
shaders do not render to the main framebuffer ever, but rather to arbritary color textures with their own information
I am not switching framebuffers, does this mean I still draw to the wrong framebuffer while doing some draw calls from WorldRenderEvents.LAST?
you'd need to do it at the very end of renderLevel
Initially I was working with my own mixins to achieve effect of WorldRenderEvents.LAST event (because my mod is for both forge/fabric) but then ppl started complaining that my mod doesn't work with sodium I noticed my mixin into LevelRenderer.renderLevel doesn't get hit (I suppose because of sodium overwrites this method or something like this) Then I switched to WorldRenderEvents.LAST, which is somehow is getting triggered by sodium What would be the best way to draw something at the very end of renderLevel? Should I still switch to correct framebuffer here?
IMS
IMS9mo ago
Iris has special sanity checks, mods can never render stuff on their own when an Iris shader is meant to be active any writes to the main framebuffer will be disabled mixin into renderLevel RETURN should work fine
Zergatul
Zergatul9mo ago
thanks, I will try that it works perfectly, thanks again!
Want results from more Discord servers?
Add your server