-
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.
Add support for full-precision vertex format
- Loading branch information
Showing
22 changed files
with
252 additions
and
26 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, VanillaModelVertexType.encodeLightMapTexCoord(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, VanillaModelVertexType.encodeLightMapTexCoord(light)); | ||
|
||
this.advance(); | ||
} | ||
} |
Oops, something went wrong.