-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/18.x/forge' into 19.2/forge
- Loading branch information
Showing
22 changed files
with
236 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
src/main/java/me/jellysquid/mods/sodium/client/model/vertex/type/ChunkVertexType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
src/main/java/me/jellysquid/mods/sodium/client/render/chunk/format/ChunkMeshAttribute.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
...in/java/me/jellysquid/mods/sodium/client/render/chunk/format/ChunkModelVertexFormats.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
package me.jellysquid.mods.sodium.client.render.chunk.format; | ||
|
||
import me.jellysquid.mods.sodium.client.render.chunk.format.full.VanillaModelVertexType; | ||
import me.jellysquid.mods.sodium.client.render.chunk.format.sfp.ModelVertexType; | ||
|
||
public class ChunkModelVertexFormats { | ||
public static final ModelVertexType DEFAULT = new ModelVertexType(); | ||
public static final VanillaModelVertexType VANILLA_LIKE = new VanillaModelVertexType(); | ||
} |
8 changes: 8 additions & 0 deletions
8
...a/me/jellysquid/mods/sodium/client/render/chunk/format/VanillaLikeChunkMeshAttribute.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package me.jellysquid.mods.sodium.client.render.chunk.format; | ||
|
||
public enum VanillaLikeChunkMeshAttribute { | ||
POSITION, | ||
COLOR, | ||
BLOCK_TEX_ID, | ||
LIGHT | ||
} |
33 changes: 33 additions & 0 deletions
33
...ysquid/mods/sodium/client/render/chunk/format/full/VanillaModelVertexBufferWriterNio.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package me.jellysquid.mods.sodium.client.render.chunk.format.full; | ||
|
||
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.render.chunk.format.ChunkModelVertexFormats; | ||
import me.jellysquid.mods.sodium.client.render.chunk.format.ModelVertexSink; | ||
|
||
import java.nio.ByteBuffer; | ||
|
||
public class VanillaModelVertexBufferWriterNio extends VertexBufferWriterNio implements ModelVertexSink { | ||
public VanillaModelVertexBufferWriterNio(VertexBufferView backingBuffer) { | ||
super(backingBuffer, ChunkModelVertexFormats.VANILLA_LIKE); | ||
} | ||
|
||
@Override | ||
public void writeVertex(float posX, float posY, float posZ, int color, float u, float v, int light, int chunkId) { | ||
int i = this.writeOffset; | ||
|
||
ByteBuffer buffer = this.byteBuffer; | ||
buffer.putFloat(i + 0, posX); | ||
buffer.putFloat(i + 4, posY); | ||
buffer.putFloat(i + 8, posZ); | ||
buffer.putInt(i + 12, color); | ||
|
||
buffer.putShort(i + 16, VanillaModelVertexType.encodeBlockTexture(u)); | ||
buffer.putShort(i + 18, VanillaModelVertexType.encodeBlockTexture(v)); | ||
buffer.putShort(i + 20, (short) chunkId); | ||
|
||
buffer.putInt(i + 24, light); | ||
|
||
this.advance(); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
...uid/mods/sodium/client/render/chunk/format/full/VanillaModelVertexBufferWriterUnsafe.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package me.jellysquid.mods.sodium.client.render.chunk.format.full; | ||
|
||
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.render.chunk.format.ChunkModelVertexFormats; | ||
import me.jellysquid.mods.sodium.client.render.chunk.format.ModelVertexSink; | ||
import org.lwjgl.system.MemoryUtil; | ||
|
||
public class VanillaModelVertexBufferWriterUnsafe extends VertexBufferWriterUnsafe implements ModelVertexSink { | ||
public VanillaModelVertexBufferWriterUnsafe(VertexBufferView backingBuffer) { | ||
super(backingBuffer, ChunkModelVertexFormats.VANILLA_LIKE); | ||
} | ||
|
||
@Override | ||
public void writeVertex(float posX, float posY, float posZ, int color, float u, float v, int light, int chunkId) { | ||
long i = this.writePointer; | ||
|
||
MemoryUtil.memPutFloat(i + 0, posX); | ||
MemoryUtil.memPutFloat(i + 4, posY); | ||
MemoryUtil.memPutFloat(i + 8, posZ); | ||
MemoryUtil.memPutInt(i + 12, color); | ||
|
||
MemoryUtil.memPutShort(i + 16, VanillaModelVertexType.encodeBlockTexture(u)); | ||
MemoryUtil.memPutShort(i + 18, VanillaModelVertexType.encodeBlockTexture(v)); | ||
MemoryUtil.memPutShort(i + 20, (short) chunkId); | ||
|
||
MemoryUtil.memPutInt(i + 24, light); | ||
|
||
this.advance(); | ||
} | ||
} |
67 changes: 67 additions & 0 deletions
67
...ava/me/jellysquid/mods/sodium/client/render/chunk/format/full/VanillaModelVertexType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package me.jellysquid.mods.sodium.client.render.chunk.format.full; | ||
|
||
import me.jellysquid.mods.sodium.client.gl.attribute.GlVertexAttributeFormat; | ||
import me.jellysquid.mods.sodium.client.gl.attribute.GlVertexFormat; | ||
import me.jellysquid.mods.sodium.client.model.vertex.buffer.VertexBufferView; | ||
import me.jellysquid.mods.sodium.client.model.vertex.type.BlittableVertexType; | ||
import me.jellysquid.mods.sodium.client.model.vertex.type.ChunkVertexType; | ||
import me.jellysquid.mods.sodium.client.render.chunk.format.ChunkMeshAttribute; | ||
import me.jellysquid.mods.sodium.client.render.chunk.format.ModelVertexSink; | ||
import me.jellysquid.mods.sodium.client.render.chunk.format.VanillaLikeChunkMeshAttribute; | ||
import net.minecraft.client.render.VertexConsumer; | ||
|
||
/** | ||
* Simple vertex format which uses single-precision floating point numbers to represent position and texture | ||
* coordinates. | ||
*/ | ||
public class VanillaModelVertexType implements ChunkVertexType<VanillaLikeChunkMeshAttribute> { | ||
public static final GlVertexFormat<VanillaLikeChunkMeshAttribute> VERTEX_FORMAT = GlVertexFormat.builder(VanillaLikeChunkMeshAttribute.class, 28) | ||
.addElement(VanillaLikeChunkMeshAttribute.POSITION, 0, GlVertexAttributeFormat.FLOAT, 3, false, false) | ||
.addElement(VanillaLikeChunkMeshAttribute.COLOR, 12, GlVertexAttributeFormat.UNSIGNED_BYTE, 4, true, false) | ||
.addElement(VanillaLikeChunkMeshAttribute.BLOCK_TEX_ID, 16, GlVertexAttributeFormat.UNSIGNED_SHORT, 4, false, false) | ||
.addElement(VanillaLikeChunkMeshAttribute.LIGHT, 24, GlVertexAttributeFormat.UNSIGNED_SHORT, 2, true, true) | ||
.build(); | ||
|
||
private static final int TEXTURE_MAX_VALUE = 65536; | ||
|
||
private static final float TEXTURE_SCALE = (1.0f / TEXTURE_MAX_VALUE); | ||
|
||
@Override | ||
public ModelVertexSink createFallbackWriter(VertexConsumer consumer) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
@Override | ||
public ModelVertexSink createBufferWriter(VertexBufferView buffer, boolean direct) { | ||
return direct ? new VanillaModelVertexBufferWriterUnsafe(buffer) : new VanillaModelVertexBufferWriterNio(buffer); | ||
} | ||
|
||
@Override | ||
public BlittableVertexType<ModelVertexSink> asBlittable() { | ||
return this; | ||
} | ||
|
||
@Override | ||
public GlVertexFormat<VanillaLikeChunkMeshAttribute> getCustomVertexFormat() { | ||
return VERTEX_FORMAT; | ||
} | ||
|
||
@Override | ||
public float getTextureScale() { | ||
return TEXTURE_SCALE; | ||
} | ||
|
||
static short encodeBlockTexture(float value) { | ||
return (short) (Math.min(0.99999997F, value) * TEXTURE_MAX_VALUE); | ||
} | ||
|
||
@Override | ||
public float getPositionOffset() { | ||
return 0; | ||
} | ||
|
||
@Override | ||
public float getPositionScale() { | ||
return 1; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.