Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[1.19] Rendering a translucent cube in the world (Not filled all elements of the vertex)

Featured Replies

Posted

Hello all,

I have a mod that renders a cube the size of a chunk to simulate a "rain"-like effect. This worked well in 1.18.2 using borrowed code from the vanilla rain rendering.

That stopped working, so I'm trying to actually understand the rendering process, rather than just copy-paste-praying.

I copied the code from `LevelRenderer.renderLineBox` which worked perfectly in a `RenderLevelStageEvent` handler, but only rendered lines.

I switched the RenderType to translucent and now I'm getting an IllegalStateException with the message "Not filled all elements of the vertex".

 

I understand this means I am missing a value from the vertex builder chain, but I'm not sure what I'm missing here.

The DefaultVertexFormat for "block" (used by RenderType.transparent) specifies that it needs 6 values: position, color, uv0, uv2, normal, and padding.

   public static final VertexFormat BLOCK = new VertexFormat(ImmutableMap.<String, VertexFormatElement>builder().put("Position", ELEMENT_POSITION).put("Color", ELEMENT_COLOR).put("UV0", ELEMENT_UV0).put("UV2", ELEMENT_UV2).put("Normal", ELEMENT_NORMAL).put("Padding", ELEMENT_PADDING).build());

In my code, I am providing 6 values: vertex, color, uv, uv2, normal, and I believe padding is automatically implied.

VertexConsumer vertex = vc.vertex(matrix4f, f3, f1, f2);
vertex = vertex.color(r, g2, b2, a);
vertex = vertex.normal(matrix3f, 1.0F, 0.0F, 0.0F);
vertex = vertex.uv(0, 0);
vertex = vertex.uv2(0, 0);
vertex.endVertex();

But my "elementIndex" ends up being "4", causing the exception.

F571oxF.png

Here is the link to the entire file:

https://github.com/bradsk88/EurekaCraft/blob/c4a3eb76468fef861fbcfbe7423f59683f9537ec/src/main/java/ca/bradj/eurekacraft/client/ChunkStormCubeForgeRendering.java#L99

Can anyone spot what I'm doing wrong here?

Edited by bradsk88

  • 1 month later...
  • Author

Turns out the order of calls in the chain is important.  I had to update my calls to vertex to be in the same order as `VertexFormat BLOCK`

VertexConsumer vertex = vc.vertex(matrix4f, f3, f1, f2);
vertex = vertex.color(r, g2, b2, a);
vertex = vertex.uv(0, 0);
vertex = vertex.uv2(0, 0);
vertex = vertex.normal(matrix3f, 1.0F, 0.0F, 0.0F);
vertex.endVertex();

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.