mirror of
https://github.com/GTNewHorizons/Angelica.git
synced 2026-11-21 21:02:15 +00:00
Set some defaults for tile entity rendering: (#1144)
This commit is contained in:
1 parent
1e458fa368
commit
d9a3e8b609
10 files changed
+20
-525
No files matched your search
@@ -1,10 +1,10 @@
|
||||
package com.gtnewhorizons.angelica.proxy;
|
||||
|
||||
import static com.gtnewhorizons.angelica.AngelicaMod.MOD_ID;
|
||||
import static com.gtnewhorizons.angelica.loading.AngelicaTweaker.LOGGER;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.vertex.DefaultVertexFormat;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.vertex.VertexFormat;
|
||||
import com.gtnewhorizon.gtnhlib.client.model.loading.ModelRegistry;
|
||||
import com.gtnewhorizons.angelica.compat.ModStatus;
|
||||
import com.gtnewhorizons.angelica.compat.bettercrashes.BetterCrashesCompat;
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
@@ -12,15 +12,13 @@ import com.gtnewhorizons.angelica.config.CompatConfig;
|
||||
import com.gtnewhorizons.angelica.debug.F3Direction;
|
||||
import com.gtnewhorizons.angelica.debug.FrametimeGraph;
|
||||
import com.gtnewhorizons.angelica.debug.TPSGraph;
|
||||
import com.gtnewhorizons.angelica.mixins.interfaces.IGameSettingsExt;
|
||||
import com.gtnewhorizons.angelica.dynamiclights.DynamicLights;
|
||||
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
import com.gtnewhorizons.angelica.glsm.debug.OpenGLDebugging;
|
||||
import com.gtnewhorizons.angelica.hudcaching.HUDCaching;
|
||||
import com.gtnewhorizons.angelica.models.VanillaModels;
|
||||
import com.gtnewhorizons.angelica.mixins.interfaces.IGameSettingsExt;
|
||||
import com.gtnewhorizons.angelica.render.CloudRenderer;
|
||||
import com.gtnewhorizons.angelica.rendering.AngelicaBlockSafetyRegistry;
|
||||
import com.gtnewhorizons.angelica.utils.AssetLoader;
|
||||
import com.gtnewhorizons.angelica.zoom.Zoom;
|
||||
import cpw.mods.fml.client.registry.ClientRegistry;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
@@ -39,7 +37,6 @@ import jss.notfine.core.Settings;
|
||||
import me.jellysquid.mods.sodium.client.SodiumDebugScreenHandler;
|
||||
import net.coderbot.iris.Iris;
|
||||
import net.coderbot.iris.client.IrisDebugScreenHandler;
|
||||
import net.coderbot.iris.vertices.IrisVertexFormats;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
@@ -76,7 +73,7 @@ public class ClientProxy extends CommonProxy {
|
||||
FMLCommonHandler.instance().bus().register(this);
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
|
||||
AssetLoader.load();
|
||||
ModelRegistry.registerModid(MOD_ID);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
@@ -102,8 +99,7 @@ public class ClientProxy extends CommonProxy {
|
||||
super.init(event);
|
||||
|
||||
if (AngelicaConfig.enableHudCaching) {
|
||||
FMLCommonHandler.instance().bus().register(HUDCaching.INSTANCE);
|
||||
MinecraftForge.EVENT_BUS.register(HUDCaching.INSTANCE);
|
||||
HUDCaching.init();
|
||||
}
|
||||
if (AngelicaConfig.enableSodium) {
|
||||
MinecraftForge.EVENT_BUS.register(SodiumDebugScreenHandler.INSTANCE);
|
||||
@@ -114,23 +110,6 @@ public class ClientProxy extends CommonProxy {
|
||||
Iris.INSTANCE.fmlInitEvent();
|
||||
FMLCommonHandler.instance().bus().register(Iris.INSTANCE);
|
||||
MinecraftForge.EVENT_BUS.register(Iris.INSTANCE);
|
||||
|
||||
VertexFormat.registerSetupBufferStateOverride((vertexFormat, l) -> {
|
||||
if (vertexFormat == DefaultVertexFormat.POSITION_COLOR_TEXTURE_LIGHT_NORMAL
|
||||
|| vertexFormat == DefaultVertexFormat.POSITION_COLOR_TEX_LIGHTMAP) {
|
||||
IrisVertexFormats.TERRAIN.setupBufferState(l);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
VertexFormat.registerClearBufferStateOverride(vertexFormat -> {
|
||||
if (vertexFormat == DefaultVertexFormat.POSITION_COLOR_TEXTURE_LIGHT_NORMAL
|
||||
|| vertexFormat == DefaultVertexFormat.POSITION_COLOR_TEX_LIGHTMAP) {
|
||||
IrisVertexFormats.TERRAIN.clearBufferState();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
FMLCommonHandler.instance().bus().register(this);
|
||||
@@ -139,8 +118,6 @@ public class ClientProxy extends CommonProxy {
|
||||
glsmKeyBinding = new KeyBinding("Print GLSM Debug", Keyboard.KEY_NONE, "Angelica");
|
||||
ClientRegistry.registerKeyBinding(glsmKeyBinding);
|
||||
|
||||
VanillaModels.init();
|
||||
|
||||
if (ModStatus.isBetterCrashesLoaded) {
|
||||
BetterCrashesCompat.init();
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ import me.jellysquid.mods.sodium.client.render.pipeline.context.ChunkRenderCache
|
||||
import me.jellysquid.mods.sodium.client.util.math.FrustumExtended;
|
||||
import me.jellysquid.mods.sodium.common.util.ListUtil;
|
||||
import net.coderbot.iris.block_rendering.BlockRenderingSettings;
|
||||
import net.coderbot.iris.gl.shader.ProgramCreator;
|
||||
import net.coderbot.iris.layer.GbufferPrograms;
|
||||
import net.coderbot.iris.pipeline.ShadowRenderer;
|
||||
import net.coderbot.iris.shadows.ShadowRenderingState;
|
||||
@@ -51,6 +52,7 @@ import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraftforge.client.MinecraftForgeClient;
|
||||
import org.joml.Vector3d;
|
||||
import org.lwjgl.opengl.GL20;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@@ -359,6 +361,9 @@ public class SodiumWorldRenderer {
|
||||
if(AngelicaConfig.enableIris) {
|
||||
final Block block = tileEntity.getWorldObj().getBlock(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord);
|
||||
CapturedRenderingState.INSTANCE.setCurrentBlockEntity(Block.getIdFromBlock(block));
|
||||
GL20.glVertexAttrib2s(ProgramCreator.MC_ENTITY, (short)-1, (short)-1);
|
||||
GL20.glVertexAttrib2f(ProgramCreator.MC_MID_TEX_COORD, 0.5f, 0.5f);
|
||||
GL20.glVertexAttrib4f(ProgramCreator.AT_TANGENT, 1.0f, 0.0f, 0.0f, 1.0f);
|
||||
GbufferPrograms.beginBlockEntities();
|
||||
}
|
||||
TileEntityRendererDispatcher.instance.renderTileEntity(tileEntity, partialTicks);
|
||||
|
||||
@@ -11,16 +11,22 @@ import org.lwjgl.opengl.GL20;
|
||||
import org.lwjgl.opengl.KHRDebug;
|
||||
|
||||
public class ProgramCreator {
|
||||
|
||||
private static final Logger LOGGER = LogManager.getLogger(ProgramCreator.class);
|
||||
|
||||
public static final int MC_ENTITY = 11;
|
||||
public static final int MC_MID_TEX_COORD = 12;
|
||||
public static final int AT_TANGENT = 13;
|
||||
public static final int AT_MIDBLOCK = 14;
|
||||
|
||||
public static int create(String name, GlShader... shaders) {
|
||||
int program = GL20.glCreateProgram();
|
||||
|
||||
// TODO: This is *really* hardcoded, we need to refactor this to support external calls to glBindAttribLocation
|
||||
RenderSystem.bindAttributeLocation(program, 11, "mc_Entity");
|
||||
RenderSystem.bindAttributeLocation(program, 12, "mc_midTexCoord");
|
||||
RenderSystem.bindAttributeLocation(program, 13, "at_tangent");
|
||||
RenderSystem.bindAttributeLocation(program, 14, "at_midBlock");
|
||||
RenderSystem.bindAttributeLocation(program, MC_ENTITY, "mc_Entity");
|
||||
RenderSystem.bindAttributeLocation(program, MC_MID_TEX_COORD, "mc_midTexCoord");
|
||||
RenderSystem.bindAttributeLocation(program, AT_TANGENT, "at_tangent");
|
||||
RenderSystem.bindAttributeLocation(program, AT_MIDBLOCK, "at_midBlock");
|
||||
|
||||
for (GlShader shader : shaders) {
|
||||
GL20.glAttachShader(program, shader.getHandle());
|
||||
|
||||
-95
@@ -1,95 +0,0 @@
|
||||
package net.coderbot.iris.sodium.vertex_format.entity_xhfp;
|
||||
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.buffer.VertexBufferView;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.buffer.VertexBufferWriterNio;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.formats.glyph.GlyphVertexSink;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.formats.quad.QuadVertexSink;
|
||||
import me.jellysquid.mods.sodium.client.util.Norm3b;
|
||||
import net.coderbot.iris.vertices.IrisVertexFormats;
|
||||
import net.coderbot.iris.vertices.NormalHelper;
|
||||
import org.joml.Vector3f;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
public class EntityVertexBufferWriterNio extends VertexBufferWriterNio implements QuadVertexSink, GlyphVertexSink {
|
||||
private static final int STRIDE = IrisVertexFormats.ENTITY.getVertexSize();
|
||||
|
||||
private final QuadViewEntity.QuadViewEntityNio quad = new QuadViewEntity.QuadViewEntityNio();
|
||||
private final Vector3f saveNormal = new Vector3f();
|
||||
|
||||
private int vertexCount;
|
||||
private float uSum;
|
||||
private float vSum;
|
||||
|
||||
public EntityVertexBufferWriterNio(VertexBufferView backingBuffer) {
|
||||
super(backingBuffer, ExtendedQuadVertexType.INSTANCE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeQuad(float x, float y, float z, int color, float u, float v, int light, int overlay, int normal) {
|
||||
int i = this.writeOffset;
|
||||
ByteBuffer buffer = this.byteBuffer;
|
||||
|
||||
vertexCount++;
|
||||
uSum += u;
|
||||
vSum += v;
|
||||
|
||||
buffer.putFloat(i, x);
|
||||
buffer.putFloat(i + 4, y);
|
||||
buffer.putFloat(i + 8, z);
|
||||
buffer.putInt(i + 12, color);
|
||||
buffer.putFloat(i + 16, u);
|
||||
buffer.putFloat(i + 20, v);
|
||||
buffer.putInt(i + 24, overlay);
|
||||
buffer.putInt(i + 28, light);
|
||||
|
||||
if (vertexCount == 4) {
|
||||
this.endQuad(normal);
|
||||
}
|
||||
|
||||
this.advance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeGlyph(float x, float y, float z, int color, float u, float v, int light) {
|
||||
writeQuad(x, y, z, color, u, v, light, 0, 0);
|
||||
}
|
||||
|
||||
private void endQuad(int normal) {
|
||||
this.vertexCount = 0;
|
||||
|
||||
int i = this.writeOffset;
|
||||
ByteBuffer buffer = this.byteBuffer;
|
||||
|
||||
uSum *= 0.25;
|
||||
vSum *= 0.25;
|
||||
|
||||
quad.setup(buffer, i, STRIDE);
|
||||
|
||||
float normalX, normalY, normalZ;
|
||||
|
||||
if (normal == 0) {
|
||||
NormalHelper.computeFaceNormal(saveNormal, quad);
|
||||
normalX = saveNormal.x;
|
||||
normalY = saveNormal.y;
|
||||
normalZ = saveNormal.z;
|
||||
normal = NormalHelper.packNormal(saveNormal, 0.0F);
|
||||
} else {
|
||||
normalX = Norm3b.unpackX(normal);
|
||||
normalY = Norm3b.unpackY(normal);
|
||||
normalZ = Norm3b.unpackZ(normal);
|
||||
}
|
||||
|
||||
int tangent = NormalHelper.computeTangent(normalX, normalY, normalZ, quad);
|
||||
|
||||
for (int vertex = 0; vertex < 4; vertex++) {
|
||||
buffer.putFloat(i + 36 - STRIDE * vertex, uSum);
|
||||
buffer.putFloat(i + 40 - STRIDE * vertex, vSum);
|
||||
buffer.putInt(i + 32 - STRIDE * vertex, normal);
|
||||
buffer.putInt(i + 44 - STRIDE * vertex, tangent);
|
||||
}
|
||||
|
||||
uSum = 0;
|
||||
vSum = 0;
|
||||
}
|
||||
}
|
||||
-93
@@ -1,93 +0,0 @@
|
||||
package net.coderbot.iris.sodium.vertex_format.entity_xhfp;
|
||||
|
||||
import static com.gtnewhorizon.gtnhlib.bytebuf.MemoryUtilities.*;
|
||||
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.buffer.VertexBufferView;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.buffer.VertexBufferWriterUnsafe;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.formats.glyph.GlyphVertexSink;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.formats.quad.QuadVertexSink;
|
||||
import me.jellysquid.mods.sodium.client.util.Norm3b;
|
||||
import net.coderbot.iris.vertices.IrisVertexFormats;
|
||||
import net.coderbot.iris.vertices.NormalHelper;
|
||||
import org.joml.Vector3f;
|
||||
|
||||
public class EntityVertexBufferWriterUnsafe extends VertexBufferWriterUnsafe implements QuadVertexSink, GlyphVertexSink {
|
||||
private static final int STRIDE = IrisVertexFormats.ENTITY.getVertexSize();
|
||||
|
||||
private final QuadViewEntity.QuadViewEntityUnsafe quad = new QuadViewEntity.QuadViewEntityUnsafe();
|
||||
private final Vector3f saveNormal = new Vector3f();
|
||||
|
||||
private int vertexCount;
|
||||
private float uSum;
|
||||
private float vSum;
|
||||
|
||||
public EntityVertexBufferWriterUnsafe(VertexBufferView backingBuffer) {
|
||||
super(backingBuffer, ExtendedQuadVertexType.INSTANCE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeQuad(float x, float y, float z, int color, float u, float v, int light, int overlay, int normal) {
|
||||
long i = this.writePointer;
|
||||
|
||||
vertexCount++;
|
||||
uSum += u;
|
||||
vSum += v;
|
||||
|
||||
memPutFloat(i, x);
|
||||
memPutFloat(i + 4, y);
|
||||
memPutFloat(i + 8, z);
|
||||
memPutInt(i + 12, color);
|
||||
memPutFloat(i + 16, u);
|
||||
memPutFloat(i + 20, v);
|
||||
memPutInt(i + 24, overlay);
|
||||
memPutInt(i + 28, light);
|
||||
|
||||
if (vertexCount == 4) {
|
||||
this.endQuad(normal);
|
||||
}
|
||||
|
||||
this.advance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeGlyph(float x, float y, float z, int color, float u, float v, int light) {
|
||||
writeQuad(x, y, z, color, u, v, light, 0, 0);
|
||||
}
|
||||
|
||||
private void endQuad(int normal) {
|
||||
this.vertexCount = 0;
|
||||
|
||||
long i = this.writePointer;
|
||||
|
||||
uSum *= 0.25;
|
||||
vSum *= 0.25;
|
||||
|
||||
quad.setup(writePointer, STRIDE);
|
||||
|
||||
float normalX, normalY, normalZ;
|
||||
|
||||
if (normal == 0) {
|
||||
NormalHelper.computeFaceNormal(saveNormal, quad);
|
||||
normalX = saveNormal.x;
|
||||
normalY = saveNormal.y;
|
||||
normalZ = saveNormal.z;
|
||||
normal = NormalHelper.packNormal(saveNormal, 0.0F);
|
||||
} else {
|
||||
normalX = Norm3b.unpackX(normal);
|
||||
normalY = Norm3b.unpackY(normal);
|
||||
normalZ = Norm3b.unpackZ(normal);
|
||||
}
|
||||
|
||||
int tangent = NormalHelper.computeTangent(normalX, normalY, normalZ, quad);
|
||||
|
||||
for (long vertex = 0; vertex < 4; vertex++) {
|
||||
memPutFloat(i + 36 - STRIDE * vertex, uSum);
|
||||
memPutFloat(i + 40 - STRIDE * vertex, vSum);
|
||||
memPutInt(i + 32 - STRIDE * vertex, normal);
|
||||
memPutInt(i + 44 - STRIDE * vertex, tangent);
|
||||
}
|
||||
|
||||
uSum = 0;
|
||||
vSum = 0;
|
||||
}
|
||||
}
|
||||
-34
@@ -1,34 +0,0 @@
|
||||
package net.coderbot.iris.sodium.vertex_format.entity_xhfp;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.vertex.VertexFormat;
|
||||
import com.gtnewhorizons.angelica.compat.toremove.VertexConsumer;
|
||||
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.buffer.VertexBufferView;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.formats.glyph.GlyphVertexSink;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.formats.glyph.writer.GlyphVertexWriterFallback;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.type.BlittableVertexType;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.type.VanillaVertexType;
|
||||
import net.coderbot.iris.vertices.IrisVertexFormats;
|
||||
|
||||
public class ExtendedGlyphVertexType implements VanillaVertexType<GlyphVertexSink>, BlittableVertexType<GlyphVertexSink> {
|
||||
public static final ExtendedGlyphVertexType INSTANCE = new ExtendedGlyphVertexType();
|
||||
|
||||
@Override
|
||||
public GlyphVertexSink createFallbackWriter(VertexConsumer vertexConsumer) {
|
||||
return new GlyphVertexWriterFallback(vertexConsumer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GlyphVertexSink createBufferWriter(VertexBufferView buffer, boolean direct) {
|
||||
return direct ? new GlyphVertexBufferWriterUnsafe(buffer) : new GlyphVertexBufferWriterNio(buffer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public VertexFormat getVertexFormat() {
|
||||
return IrisVertexFormats.TERRAIN;
|
||||
}
|
||||
|
||||
public BlittableVertexType<GlyphVertexSink> asBlittable() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
-34
@@ -1,34 +0,0 @@
|
||||
package net.coderbot.iris.sodium.vertex_format.entity_xhfp;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.vertex.VertexFormat;
|
||||
import com.gtnewhorizons.angelica.compat.toremove.VertexConsumer;
|
||||
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.buffer.VertexBufferView;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.formats.quad.QuadVertexSink;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.formats.quad.writer.QuadVertexWriterFallback;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.type.BlittableVertexType;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.type.VanillaVertexType;
|
||||
import net.coderbot.iris.vertices.IrisVertexFormats;
|
||||
|
||||
public class ExtendedQuadVertexType implements VanillaVertexType<QuadVertexSink>, BlittableVertexType<QuadVertexSink> {
|
||||
public static final ExtendedQuadVertexType INSTANCE = new ExtendedQuadVertexType();
|
||||
|
||||
@Override
|
||||
public QuadVertexSink createFallbackWriter(VertexConsumer vertexConsumer) {
|
||||
return new QuadVertexWriterFallback(vertexConsumer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QuadVertexSink createBufferWriter(VertexBufferView buffer, boolean direct) {
|
||||
return direct ? new EntityVertexBufferWriterUnsafe(buffer) : new EntityVertexBufferWriterNio(buffer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public VertexFormat getVertexFormat() {
|
||||
return IrisVertexFormats.ENTITY;
|
||||
}
|
||||
|
||||
public BlittableVertexType<QuadVertexSink> asBlittable() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
-94
@@ -1,94 +0,0 @@
|
||||
package net.coderbot.iris.sodium.vertex_format.entity_xhfp;
|
||||
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.buffer.VertexBufferView;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.buffer.VertexBufferWriterNio;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.formats.glyph.GlyphVertexSink;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.formats.quad.QuadVertexSink;
|
||||
import me.jellysquid.mods.sodium.client.util.Norm3b;
|
||||
import net.coderbot.iris.vertices.IrisVertexFormats;
|
||||
import net.coderbot.iris.vertices.NormalHelper;
|
||||
import org.joml.Vector3f;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
public class GlyphVertexBufferWriterNio extends VertexBufferWriterNio implements QuadVertexSink, GlyphVertexSink {
|
||||
private static final int STRIDE = IrisVertexFormats.TERRAIN.getVertexSize();
|
||||
|
||||
private final QuadViewEntity.QuadViewEntityNio quad = new QuadViewEntity.QuadViewEntityNio();
|
||||
private final Vector3f saveNormal = new Vector3f();
|
||||
|
||||
private int vertexCount;
|
||||
private float uSum;
|
||||
private float vSum;
|
||||
|
||||
public GlyphVertexBufferWriterNio(VertexBufferView backingBuffer) {
|
||||
super(backingBuffer, ExtendedGlyphVertexType.INSTANCE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeQuad(float x, float y, float z, int color, float u, float v, int light, int overlay, int normal) {
|
||||
int i = this.writeOffset;
|
||||
ByteBuffer buffer = this.byteBuffer;
|
||||
|
||||
vertexCount++;
|
||||
uSum += u;
|
||||
vSum += v;
|
||||
|
||||
buffer.putFloat(i, x);
|
||||
buffer.putFloat(i + 4, y);
|
||||
buffer.putFloat(i + 8, z);
|
||||
buffer.putInt(i + 12, color);
|
||||
buffer.putFloat(i + 16, u);
|
||||
buffer.putFloat(i + 20, v);
|
||||
buffer.putInt(i + 24, light);
|
||||
|
||||
if (vertexCount == 4) {
|
||||
this.endQuad(normal);
|
||||
}
|
||||
|
||||
this.advance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeGlyph(float x, float y, float z, int color, float u, float v, int light) {
|
||||
writeQuad(x, y, z, color, u, v, light, 0, 0);
|
||||
}
|
||||
|
||||
private void endQuad(int normal) {
|
||||
this.vertexCount = 0;
|
||||
|
||||
int i = this.writeOffset;
|
||||
ByteBuffer buffer = this.byteBuffer;
|
||||
|
||||
uSum *= 0.25;
|
||||
vSum *= 0.25;
|
||||
|
||||
quad.setup(byteBuffer, writeOffset, STRIDE);
|
||||
|
||||
float normalX, normalY, normalZ;
|
||||
|
||||
if (normal == 0) {
|
||||
NormalHelper.computeFaceNormal(saveNormal, quad);
|
||||
normalX = saveNormal.x;
|
||||
normalY = saveNormal.y;
|
||||
normalZ = saveNormal.z;
|
||||
normal = NormalHelper.packNormal(saveNormal, 0.0F);
|
||||
} else {
|
||||
normalX = Norm3b.unpackX(normal);
|
||||
normalY = Norm3b.unpackY(normal);
|
||||
normalZ = Norm3b.unpackZ(normal);
|
||||
}
|
||||
|
||||
int tangent = NormalHelper.computeTangent(normalX, normalY, normalZ, quad);
|
||||
|
||||
for (int vertex = 0; vertex < 4; vertex++) {
|
||||
buffer.putFloat(i + 36 - STRIDE * vertex, uSum);
|
||||
buffer.putFloat(i + 40 - STRIDE * vertex, vSum);
|
||||
buffer.putInt(i + 28 - STRIDE * vertex, normal);
|
||||
buffer.putInt(i + 44 - STRIDE * vertex, tangent);
|
||||
}
|
||||
|
||||
uSum = 0;
|
||||
vSum = 0;
|
||||
}
|
||||
}
|
||||
-92
@@ -1,92 +0,0 @@
|
||||
package net.coderbot.iris.sodium.vertex_format.entity_xhfp;
|
||||
|
||||
import static com.gtnewhorizon.gtnhlib.bytebuf.MemoryUtilities.*;
|
||||
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.buffer.VertexBufferView;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.buffer.VertexBufferWriterUnsafe;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.formats.glyph.GlyphVertexSink;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.formats.quad.QuadVertexSink;
|
||||
import me.jellysquid.mods.sodium.client.util.Norm3b;
|
||||
import net.coderbot.iris.vertices.IrisVertexFormats;
|
||||
import net.coderbot.iris.vertices.NormalHelper;
|
||||
import org.joml.Vector3f;
|
||||
|
||||
public class GlyphVertexBufferWriterUnsafe extends VertexBufferWriterUnsafe implements QuadVertexSink, GlyphVertexSink {
|
||||
private static final int STRIDE = IrisVertexFormats.TERRAIN.getVertexSize();
|
||||
|
||||
private final QuadViewEntity.QuadViewEntityUnsafe quad = new QuadViewEntity.QuadViewEntityUnsafe();
|
||||
private final Vector3f saveNormal = new Vector3f();
|
||||
|
||||
private int vertexCount;
|
||||
private float uSum;
|
||||
private float vSum;
|
||||
|
||||
public GlyphVertexBufferWriterUnsafe(VertexBufferView backingBuffer) {
|
||||
super(backingBuffer, ExtendedGlyphVertexType.INSTANCE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeQuad(float x, float y, float z, int color, float u, float v, int light, int overlay, int normal) {
|
||||
long i = this.writePointer;
|
||||
|
||||
vertexCount++;
|
||||
uSum += u;
|
||||
vSum += v;
|
||||
|
||||
memPutFloat(i, x);
|
||||
memPutFloat(i + 4, y);
|
||||
memPutFloat(i + 8, z);
|
||||
memPutInt(i + 12, color);
|
||||
memPutFloat(i + 16, u);
|
||||
memPutFloat(i + 20, v);
|
||||
memPutInt(i + 24, light);
|
||||
|
||||
if (vertexCount == 4) {
|
||||
this.endQuad(normal);
|
||||
}
|
||||
|
||||
this.advance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeGlyph(float x, float y, float z, int color, float u, float v, int light) {
|
||||
writeQuad(x, y, z, color, u, v, light, 0, 0);
|
||||
}
|
||||
|
||||
private void endQuad(int normal) {
|
||||
this.vertexCount = 0;
|
||||
|
||||
long i = this.writePointer;
|
||||
|
||||
uSum *= 0.25;
|
||||
vSum *= 0.25;
|
||||
|
||||
quad.setup(writePointer, STRIDE);
|
||||
|
||||
float normalX, normalY, normalZ;
|
||||
|
||||
if (normal == 0) {
|
||||
NormalHelper.computeFaceNormal(saveNormal, quad);
|
||||
normalX = saveNormal.x;
|
||||
normalY = saveNormal.y;
|
||||
normalZ = saveNormal.z;
|
||||
normal = NormalHelper.packNormal(saveNormal, 0.0F);
|
||||
} else {
|
||||
normalX = Norm3b.unpackX(normal);
|
||||
normalY = Norm3b.unpackY(normal);
|
||||
normalZ = Norm3b.unpackZ(normal);
|
||||
}
|
||||
|
||||
int tangent = NormalHelper.computeTangent(normalX, normalY, normalZ, quad);
|
||||
|
||||
for (long vertex = 0; vertex < 4; vertex++) {
|
||||
memPutFloat(i + 36 - STRIDE * vertex, uSum);
|
||||
memPutFloat(i + 40 - STRIDE * vertex, vSum);
|
||||
memPutInt(i + 28 - STRIDE * vertex, normal);
|
||||
memPutInt(i + 44 - STRIDE * vertex, tangent);
|
||||
}
|
||||
|
||||
uSum = 0;
|
||||
vSum = 0;
|
||||
}
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
package net.coderbot.iris.vertices;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.vertex.DefaultVertexFormat;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.vertex.VertexFormat;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.vertex.VertexFormatElement;
|
||||
|
||||
public class IrisVertexFormats {
|
||||
public static final VertexFormatElement ENTITY_ELEMENT;
|
||||
public static final VertexFormatElement MID_TEXTURE_ELEMENT;
|
||||
public static final VertexFormatElement TANGENT_ELEMENT;
|
||||
public static final VertexFormatElement MID_BLOCK_ELEMENT;
|
||||
|
||||
public static final VertexFormat TERRAIN;
|
||||
public static final VertexFormat ENTITY;
|
||||
|
||||
static {
|
||||
ENTITY_ELEMENT = new VertexFormatElement(11, VertexFormatElement.Type.SHORT, VertexFormatElement.Usage.GENERIC, 2);
|
||||
MID_TEXTURE_ELEMENT = new VertexFormatElement(12, VertexFormatElement.Type.FLOAT, VertexFormatElement.Usage.GENERIC, 2);
|
||||
TANGENT_ELEMENT = new VertexFormatElement(13, VertexFormatElement.Type.BYTE, VertexFormatElement.Usage.GENERIC, 4);
|
||||
MID_BLOCK_ELEMENT = new VertexFormatElement(14, VertexFormatElement.Type.BYTE, VertexFormatElement.Usage.GENERIC, 3);
|
||||
|
||||
ImmutableList.Builder<VertexFormatElement> terrainElements = ImmutableList.builder();
|
||||
ImmutableList.Builder<VertexFormatElement> entityElements = ImmutableList.builder();
|
||||
|
||||
terrainElements.add(DefaultVertexFormat.POSITION_ELEMENT); // 12
|
||||
terrainElements.add(DefaultVertexFormat.COLOR_ELEMENT); // 16
|
||||
terrainElements.add(DefaultVertexFormat.TEXTURE_ELEMENT); // 24
|
||||
terrainElements.add(DefaultVertexFormat.LIGHT_ELEMENT); // 28
|
||||
terrainElements.add(DefaultVertexFormat.NORMAL_ELEMENT); // 31
|
||||
terrainElements.add(DefaultVertexFormat.PADDING_ELEMENT); // 32
|
||||
terrainElements.add(ENTITY_ELEMENT); // 36
|
||||
terrainElements.add(MID_TEXTURE_ELEMENT); // 44
|
||||
terrainElements.add(TANGENT_ELEMENT); // 48
|
||||
terrainElements.add(MID_BLOCK_ELEMENT); // 51
|
||||
terrainElements.add(DefaultVertexFormat.PADDING_ELEMENT); // 52
|
||||
|
||||
entityElements.add(DefaultVertexFormat.POSITION_ELEMENT); // 12
|
||||
entityElements.add(DefaultVertexFormat.COLOR_ELEMENT); // 16
|
||||
entityElements.add(DefaultVertexFormat.TEXTURE_ELEMENT); // 24
|
||||
entityElements.add(DefaultVertexFormat.LIGHT_ELEMENT); // 28
|
||||
entityElements.add(DefaultVertexFormat.NORMAL_ELEMENT); // 31
|
||||
entityElements.add(DefaultVertexFormat.PADDING_ELEMENT); // 32
|
||||
entityElements.add(MID_TEXTURE_ELEMENT); // 40
|
||||
entityElements.add(TANGENT_ELEMENT); // 44
|
||||
|
||||
TERRAIN = new VertexFormat(terrainElements.build());
|
||||
ENTITY = new VertexFormat(entityElements.build());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user