Apply baked-in lightmap data to rendering

- Fix ForgeHooksClient.fillNormal injecting data to lightmap
- Fix OBJModel not filling lightmap data
- Fix NewModelLoaderTest blockitem not linking with block
This commit is contained in:
tterrag 2019-12-30 16:12:14 -05:00
parent e1b0a8c153
commit 53747b0cb5
5 changed files with 21 additions and 9 deletions

View File

@ -9,3 +9,12 @@
Logger field_227884_f_ = LogManager.getLogger();
IVertexBuilder func_225582_a_(double p_225582_1_, double p_225582_3_, double p_225582_5_);
@@ -95,7 +95,7 @@
f5 = p_227890_3_[k] * p_227890_6_;
}
- int l = p_227890_7_[k];
+ int l = applyBakedLighting(p_227890_7_[k], bytebuffer);
float f9 = bytebuffer.getFloat(16);
float f10 = bytebuffer.getFloat(20);
Vector4f vector4f = new Vector4f(f, f1, f2, 1.0F);

View File

@ -742,7 +742,7 @@ public class ForgeHooksClient
for(int i = 0; i < 4; i++)
{
faceData[i * 8 + 6] = normal;
faceData[i * 8 + 7] = normal;
}
}

View File

@ -91,7 +91,7 @@ public interface IForgeVertexBuilder
ca = alpha;
}
int lightmapCoord = lightmapCoords[v];
int lightmapCoord = applyBakedLighting(lightmapCoords[v], bytebuffer);
float f9 = bytebuffer.getFloat(16);
float f10 = bytebuffer.getFloat(20);
Vector4f pos = new Vector4f(f, f1, f2, 1.0F);
@ -99,6 +99,13 @@ public interface IForgeVertexBuilder
((IVertexBuilder)this).func_225588_a_(pos.getX(), pos.getY(), pos.getZ(), cr, cg, cb, ca, f9, f10, overlayCoords, lightmapCoord, normal.getX(), normal.getY(), normal.getZ());
}
}
}
default int applyBakedLighting(int lightmapCoord, ByteBuffer data) {
int sl = (lightmapCoord >> 16) & 0xFFFF;
int bl = lightmapCoord & 0xFFFF;
sl = Math.max(sl, Short.toUnsignedInt(data.getShort(24)));
bl = Math.max(bl, Short.toUnsignedInt(data.getShort(26)));
return (sl << 16) | bl;
}
}

View File

@ -504,7 +504,7 @@ public class OBJModel implements IMultipartModelGeometry<OBJModel>
texture.getInterpolatedV((flipV ? (1 - texCoord0.y) : texCoord0.y) * 16)
);
break;
case 1:
case 2:
consumer.put(j, uv2.x, uv2.y);
break;
default:

View File

@ -19,9 +19,6 @@
package net.minecraftforge.debug.client.model;
import com.mojang.blaze3d.platform.GlStateManager;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.FourWayBlock;
@ -43,7 +40,6 @@ import net.minecraftforge.client.model.obj.OBJModel;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.util.NonNullLazy;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.fml.DistExecutor;
import net.minecraftforge.fml.RegistryObject;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
@ -78,7 +74,7 @@ public class NewModelLoaderTest
}
);
public static RegistryObject<Item> obj_item = ITEMS.register("obj_item", () ->
public static RegistryObject<Item> obj_item = ITEMS.register("obj_block", () ->
new BlockItem(obj_block.get(), new Item.Properties().group(ItemGroup.MISC)) {
@Override
public boolean canEquip(ItemStack stack, EquipmentSlotType armorType, Entity entity)