Jump to content

Recommended Posts

Posted (edited)

Hi.

In my mod, I am rendering custom first-person arms when certain items are held. I managed to do this and it works and looks quite well. However, there is one major issue - the arms and the held item can clip through blocks, mobs, etc.. So I looked at how Minecraft renders its arms, and figured out, that it "disables depth" ( using GlStateManager.disableDepth() ) so the arms are rendered on top of everything else + it also enables culling ( GlStateManager.enableCull() ). I call these before rendering the arms (and also their "opposite functions" after rendering the arms), and it works - the arms are rendered as the vanilla ones. However, it doesn't work with complex items.

It seems that this disables the "depth check" even between vertices that are part of the item, so the faces that are hidden and face the camera are rendered on top.

 

My code: https://pastebin.com/qR8kJJDF

 

EDIT: The problem almost surely is not with my models, as I tested it with vanilla items, and the same glitch occurred, though since Minecraft items are flat it is not this much visible.

 

d.png

 

b.png

c.png

e.png

Edited by Nuparu00
Better picture
  • Like 1
  • 2 weeks later...
Posted (edited)
On 12/6/2019 at 8:52 AM, Nuparu00 said:

the arms and the held item can clip through blocks, mobs, etc

Could you show an example of this? I'm not sure what you mean.

 

On 12/6/2019 at 8:52 AM, Nuparu00 said:

that it "disables depth"

That seems odd. For example, when I disable depth in one of my rendering sections, the arms and rendering turn out like this. (It's an opaque sphere.)
2019-12-14_17_44_59.png.c1bb188f4a7f2db64e62869dbb480f33.png

 

I think you may have been looking in the wrong location there.

In fact, I can't find any reference to GlStateManager#disableDepth() within ItemRenderer#renderItemInFirstPerson()ItemRenderer#renderArmFirstPerson(), RenderPlayer#renderRightArm(), or ModelRenderer#doRender().

Moreover, cull is actually disabled in RenderLivingBase#doRender().

 

To solve your problem, then, I think you need to disable culling, and enable depth.

That might just get you back to your original issue, but I'd like to make sure I understand what that is before I try and help there.

2019-12-14_17.42.13.png

Edited by SerpentDagger

Fancy 3D Graphing Calculator mod, with many different coordinate systems.

Lightweight 3D/2D position/vector transformations library, also with support for different coordinate systems.

  • 2 weeks later...

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...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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