mirror of
https://github.com/FabricMC/fabric.git
synced 2025-04-03 10:39:57 -04:00
Fix Indigo item rendering ignores item color alpha and does not apply special glint transform (#3854)
* Fix #3853 * Revert parity change This disparity exists on purpose to make the behavior of BlendMode.TRANSLUCENT more consistent
This commit is contained in:
parent
a4aac4205b
commit
48fb158648
3 changed files with 63 additions and 3 deletions
fabric-renderer-indigo/src/client
java/net/fabricmc/fabric
impl/client/indigo/renderer/render
mixin/client/indigo/renderer
resources
|
@ -37,6 +37,7 @@ import net.minecraft.item.BlockItem;
|
|||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.math.MatrixUtil;
|
||||
import net.minecraft.util.math.random.Random;
|
||||
|
||||
import net.fabricmc.fabric.api.renderer.v1.material.BlendMode;
|
||||
|
@ -47,6 +48,7 @@ import net.fabricmc.fabric.impl.client.indigo.renderer.helper.ColorHelper;
|
|||
import net.fabricmc.fabric.impl.client.indigo.renderer.mesh.EncodingFormat;
|
||||
import net.fabricmc.fabric.impl.client.indigo.renderer.mesh.MutableQuadViewImpl;
|
||||
import net.fabricmc.fabric.impl.renderer.VanillaModelEncoder;
|
||||
import net.fabricmc.fabric.mixin.client.indigo.renderer.ItemRendererAccessor;
|
||||
|
||||
/**
|
||||
* The render context used for item rendering.
|
||||
|
@ -85,7 +87,9 @@ public class ItemRenderContext extends AbstractRenderContext {
|
|||
private boolean isDefaultTranslucent;
|
||||
private boolean isTranslucentDirect;
|
||||
private boolean isDefaultGlint;
|
||||
private boolean isGlintDynamicDisplay;
|
||||
|
||||
private MatrixStack.Entry dynamicDisplayGlintEntry;
|
||||
private VertexConsumer translucentVertexConsumer;
|
||||
private VertexConsumer cutoutVertexConsumer;
|
||||
private VertexConsumer translucentGlintVertexConsumer;
|
||||
|
@ -134,6 +138,7 @@ public class ItemRenderContext extends AbstractRenderContext {
|
|||
this.matrixStack = null;
|
||||
this.vertexConsumerProvider = null;
|
||||
|
||||
dynamicDisplayGlintEntry = null;
|
||||
translucentVertexConsumer = null;
|
||||
cutoutVertexConsumer = null;
|
||||
translucentGlintVertexConsumer = null;
|
||||
|
@ -160,6 +165,7 @@ public class ItemRenderContext extends AbstractRenderContext {
|
|||
}
|
||||
|
||||
isDefaultGlint = itemStack.hasGlint();
|
||||
isGlintDynamicDisplay = ItemRendererAccessor.fabric_callUsesDynamicDisplay(itemStack);
|
||||
}
|
||||
|
||||
private void renderQuad(MutableQuadViewImpl quad) {
|
||||
|
@ -179,7 +185,7 @@ public class ItemRenderContext extends AbstractRenderContext {
|
|||
|
||||
private void colorizeQuad(MutableQuadViewImpl quad, int colorIndex) {
|
||||
if (colorIndex != -1) {
|
||||
final int itemColor = 0xFF000000 | colorMap.getColor(itemStack, colorIndex);
|
||||
final int itemColor = colorMap.getColor(itemStack, colorIndex);
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
quad.color(i, ColorHelper.multiplyColor(itemColor, quad.color(i)));
|
||||
|
@ -254,6 +260,10 @@ public class ItemRenderContext extends AbstractRenderContext {
|
|||
}
|
||||
|
||||
private VertexConsumer createTranslucentVertexConsumer(boolean glint) {
|
||||
if (glint && isGlintDynamicDisplay) {
|
||||
return createDynamicDisplayGlintVertexConsumer(MinecraftClient.isFabulousGraphicsOrBetter() && !isTranslucentDirect ? TexturedRenderLayers.getItemEntityTranslucentCull() : TexturedRenderLayers.getEntityTranslucentCull());
|
||||
}
|
||||
|
||||
if (isTranslucentDirect) {
|
||||
return ItemRenderer.getDirectItemGlintConsumer(vertexConsumerProvider, TexturedRenderLayers.getEntityTranslucentCull(), true, glint);
|
||||
} else if (MinecraftClient.isFabulousGraphicsOrBetter()) {
|
||||
|
@ -264,9 +274,27 @@ public class ItemRenderContext extends AbstractRenderContext {
|
|||
}
|
||||
|
||||
private VertexConsumer createCutoutVertexConsumer(boolean glint) {
|
||||
if (glint && isGlintDynamicDisplay) {
|
||||
return createDynamicDisplayGlintVertexConsumer(TexturedRenderLayers.getEntityCutout());
|
||||
}
|
||||
|
||||
return ItemRenderer.getDirectItemGlintConsumer(vertexConsumerProvider, TexturedRenderLayers.getEntityCutout(), true, glint);
|
||||
}
|
||||
|
||||
private VertexConsumer createDynamicDisplayGlintVertexConsumer(RenderLayer layer) {
|
||||
if (dynamicDisplayGlintEntry == null) {
|
||||
dynamicDisplayGlintEntry = matrixStack.peek().copy();
|
||||
|
||||
if (transformMode == ModelTransformationMode.GUI) {
|
||||
MatrixUtil.scale(dynamicDisplayGlintEntry.getPositionMatrix(), 0.5F);
|
||||
} else if (transformMode.isFirstPerson()) {
|
||||
MatrixUtil.scale(dynamicDisplayGlintEntry.getPositionMatrix(), 0.75F);
|
||||
}
|
||||
}
|
||||
|
||||
return ItemRenderer.getDynamicDisplayGlintConsumer(vertexConsumerProvider, layer, dynamicDisplayGlintEntry);
|
||||
}
|
||||
|
||||
private class BakedModelConsumerImpl implements BakedModelConsumer {
|
||||
@Override
|
||||
public void accept(BakedModel model) {
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* Copyright (c) 2016, 2017, 2018, 2019 FabricMC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package net.fabricmc.fabric.mixin.client.indigo.renderer;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Invoker;
|
||||
|
||||
import net.minecraft.client.render.item.ItemRenderer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
@Mixin(ItemRenderer.class)
|
||||
public interface ItemRendererAccessor {
|
||||
@Invoker("usesDynamicDisplay")
|
||||
static boolean fabric_callUsesDynamicDisplay(ItemStack stack) {
|
||||
throw new AssertionError();
|
||||
}
|
||||
}
|
|
@ -8,9 +8,10 @@
|
|||
"client": [
|
||||
"BakedModelMixin",
|
||||
"BlockModelRendererMixin",
|
||||
"SectionBuilderMixin",
|
||||
"ChunkRendererRegionMixin",
|
||||
"ItemRendererMixin"
|
||||
"ItemRendererAccessor",
|
||||
"ItemRendererMixin",
|
||||
"SectionBuilderMixin"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
|
|
Loading…
Add table
Reference in a new issue