sp614x / optifine

1.77k stars 420 forks source link

[Question]Stencil test is invalid when rendering item in hand #7638

Closed 286799714 closed 2 months ago

286799714 commented 3 months ago

I am trying to enable stencil test while rendering a scope model so that it can have a better view. My attempt is as follows: when rendering the scope model, the lens is first rendered to write the stencil buffer, and then the stencil test is enabled so that fragments in scope view are discarded. here is my code: https://github.com/MCModderAnchor/TimelessAndClassicsZero/blob/1.18.2/src/main/java/com/tac/guns/client/model/BedrockAttachmentModel.java#L50 I was able to enable stencil buffering using the method provided by Forge, which works when shaders are disabled. But after the shaders being enabled, the stencil buffer becomes invalid. I analyzed the rendering process with Nsight and found that during the rendering of item in hand, the stencil buffer was not written, nor was it applied during the rendering process of optifine. If possible, can you provide me with some relevant information or possible solutions? thanks