Skip to content

Commit

Permalink
Bind the correct sampler for blit
Browse files Browse the repository at this point in the history
  • Loading branch information
Aeltumn committed Nov 13, 2024
1 parent 59d6013 commit b895419
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,11 @@ public boolean changeFunc(int srcRgb, int dstRgb, int srcAlpha, int dstAlpha) {
// If we are currently in a buffer with any custom blend
// state we go back to a normal buffer!
if (getBuffer(bufferIndex).getBlendState() != null && isNormal) {
// Re-enable blending and let it go through
SharedVertexBuffer.ignoreBlendStateHook = true;
GlStateManager._enableBlend();
SharedVertexBuffer.ignoreBlendStateHook = false;

var buffer = getBuffer(elementsWereDrawn ? ++bufferIndex : bufferIndex);
buffer.bind(guiGraphics);
buffer.updateBlendState(null);
Expand All @@ -299,9 +304,11 @@ public boolean changeFunc(int srcRgb, int dstRgb, int srcAlpha, int dstAlpha) {
if (elementsWereDrawn) allBuffersEmpty = false;
elementsWereDrawn = false;

// Change the actual blending state to one that just copies directly to the buffer!
// Change the actual blending by disabling it completely which is slightly faster
// than using a different blending function that just copies it directly (which is
// what we want, we want to do the blending later)
SharedVertexBuffer.ignoreBlendStateHook = true;
GlStateManager._blendFunc(GL14.GL_ONE, GL14.GL_ZERO);
GlStateManager._disableBlend();
SharedVertexBuffer.ignoreBlendStateHook = false;
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public static void draw(List<BufferData> textureIds) {

// Change the current shader, bind the texture, and run it
shader = Objects.requireNonNull(RenderSystem.setShader(CoreShaders.BLIT_SCREEN), "Regular blit shader not loaded");
shader.bindSampler("SamplerIn", texture.textureId());
shader.bindSampler("InSampler", texture.textureId());
buffer.drawWithShader(NULL_MATRIX, NULL_MATRIX, shader);

// Set it back to the regular blending function
Expand Down

0 comments on commit b895419

Please sign in to comment.