diff --git a/README.md b/README.md
index b617f79..279eebd 100644
--- a/README.md
+++ b/README.md
@@ -1,25 +1,37 @@
# MCglTF
-A 3D model loader library which load glTF format file and prepare the required techniques to render the model for Minecraft Modding enviroment.
+
+A 3D model loader library which load glTF format file and prepare the required techniques to render the model for
+Minecraft Modding enviroment.
Various features from glTF spec are available but still remain a good compatibility and performance.
[](https://www.curseforge.com/minecraft/mc-mods/mcgltf) [](https://www.curseforge.com/minecraft/mc-mods/mcgltf) [](https://www.curseforge.com/minecraft/mc-mods/mcgltf)
+
## Usages
+
The example codes for rendering Block, Item, and Entity
+
- https://github.com/ModularMods/MCglTF-Example
+
## Features
+
- [x] GLTF format (Embedded resources or via ResourceLocation)
- [x] GLB format
- [x] UVs
- [x] Normals
- [x] Tangents
- [x] Vertex colors
-- [x] Materials (Require [OptiFine](https://github.com/ModularMods/MCglTF/wiki/How-to-make-PBR-Materials-working-with-OptiFine) or [Iris Shaders](https://github.com/ModularMods/MCglTF/wiki/How-to-make-PBR-Materials-working-with-Iris-Shaders) and supported ShaderPack for PBR and Normal map)
+- [x] Materials (
+ Require [OptiFine](https://github.com/ModularMods/MCglTF/wiki/How-to-make-PBR-Materials-working-with-OptiFine)
+ or [Iris Shaders](https://github.com/ModularMods/MCglTF/wiki/How-to-make-PBR-Materials-working-with-Iris-Shaders) and
+ supported ShaderPack for PBR and Normal map)
- [x] Textures
- [ ] Mutiple texture coordinates (For compatibility reason with Vanilla)
- [x] Rig
- [x] Animations (multiple)
- [x] Morph targets
- [x] Zero-scale node culling (https://github.com/KhronosGroup/glTF/pull/2059)
+
## Credit
+
- JglTF by javagl : https://github.com/javagl/JglTF
- Mikk Tangent Generator by jMonkeyEngine : https://github.com/jMonkeyEngine/jmonkeyengine
\ No newline at end of file
diff --git a/build.gradle b/build.gradle
index 1523221..e1e61ea 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,6 +1,6 @@
plugins {
- id 'fabric-loom' version '1.0-SNAPSHOT'
- id 'maven-publish'
+ id 'fabric-loom' version '1.0-SNAPSHOT'
+ id 'maven-publish'
}
sourceCompatibility = JavaVersion.VERSION_17
@@ -11,80 +11,77 @@ version = project.mod_version
group = project.maven_group
repositories {
- // Add repositories to retrieve artifacts from in here.
- // You should only use this when depending on other mods because
- // Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
- // See https://docs.gradle.org/current/userguide/declaring_repositories.html
- // for more information about repositories.
- maven {
- name = "Modrinth"
- url = "https://api.modrinth.com/maven"
-
- content {
- includeGroup "maven.modrinth"
- }
- }
- flatDir {
- dirs 'libs'
- }
+ // Add repositories to retrieve artifacts from in here.
+ // You should only use this when depending on other mods because
+ // Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
+ // See https://docs.gradle.org/current/userguide/declaring_repositories.html
+ // for more information about repositories.
+ maven {
+ name = "Modrinth"
+ url = "https://api.modrinth.com/maven"
+
+ content {
+ includeGroup "maven.modrinth"
+ }
+ }
+ flatDir {
+ dirs 'libs'
+ }
}
dependencies {
- // To change the versions see the gradle.properties file
- minecraft "com.mojang:minecraft:${project.minecraft_version}"
- mappings loom.officialMojangMappings()
- modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
+ // To change the versions see the gradle.properties file
+ minecraft "com.mojang:minecraft:${project.minecraft_version}"
+ mappings loom.officialMojangMappings()
+ modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
- // Fabric API. This is technically optional, but you probably want it anyway.
- modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
+ // Fabric API. This is technically optional, but you probably want it anyway.
+ modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
- // Uncomment the following line to enable the deprecated Fabric API modules.
- // These are included in the Fabric API production distribution and allow you to update your mod to the latest modules at a later more convenient time.
+ // Uncomment the following line to enable the deprecated Fabric API modules.
+ // These are included in the Fabric API production distribution and allow you to update your mod to the latest modules at a later more convenient time.
- // modImplementation "net.fabricmc.fabric-api:fabric-api-deprecated:${project.fabric_version}"
- modImplementation "maven.modrinth:iris:${project.iris_version}"
+ // modImplementation "net.fabricmc.fabric-api:fabric-api-deprecated:${project.fabric_version}"
+ modImplementation "maven.modrinth:iris:${project.iris_version}"
}
processResources {
- inputs.property "version", project.version
+ inputs.property "version", project.version
- filesMatching("fabric.mod.json") {
- expand "version": project.version
- }
+ filesMatching("fabric.mod.json") {
+ expand "version": project.version
+ }
}
tasks.withType(JavaCompile).configureEach {
- // Minecraft 1.18 (1.18-pre2) upwards uses Java 17.
- it.options.release = 17
+ // Minecraft 1.18 (1.18-pre2) upwards uses Java 17.
+ it.options.release = 17
}
java {
- // Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
- // if it is present.
- // If you remove this line, sources will not be generated.
- withSourcesJar()
+ // Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
+ // if it is present.
+ // If you remove this line, sources will not be generated.
+ withSourcesJar()
}
jar {
- from("LICENSE") {
- rename { "${it}_${project.archivesBaseName}"}
- }
+ from("LICENSE") {
+ rename { "${it}_${project.archivesBaseName}" }
+ }
}
// configure the maven publication
publishing {
- publications {
- mavenJava(MavenPublication) {
- from components.java
- }
- }
-
- // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
- repositories {
- // Add repositories to publish to here.
- // Notice: This block does NOT have the same function as the block in the top level.
- // The repositories here will be used for publishing your artifact, not for
- // retrieving dependencies.
- }
+ publications {
+ mavenJava(MavenPublication) {
+ from components.java
+ }
+ }
+
+ // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
+ repositories {
+
+ }
}
diff --git a/gradle.properties b/gradle.properties
index 952b2ff..e5d05b9 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -1,17 +1,14 @@
# Done to increase the memory available to gradle.
org.gradle.jvmargs=-Xmx4G
org.gradle.parallel=true
-
# Fabric Properties
- # check these on https://fabricmc.net/develop
- minecraft_version=1.20.4
- loader_version=0.16.3
-
+# check these on https://fabricmc.net/develop
+minecraft_version=1.20.4
+loader_version=0.16.3
# Mod Properties
- mod_version = 1.20.4-Fabric-2.1.0.0
- maven_group = com.modularmods.mcgltf
- archives_base_name = MCglTF
-
+mod_version=1.20.4-Fabric-2.2.0.0
+maven_group=com.modularmods.mcgltf
+archives_base_name=MCglTF
# Dependencies
- fabric_version=0.97.2+1.20.4
- iris_version=1.7.2+1.20.4
+fabric_version=0.97.2+1.20.4
+iris_version=1.7.2+1.20.4
diff --git a/settings.gradle b/settings.gradle
index b02216b..c556364 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -8,3 +8,5 @@ pluginManagement {
gradlePluginPortal()
}
}
+
+rootProject.name = "MCglTF"
\ No newline at end of file
diff --git a/src/main/java/com/modularmods/mcgltf/RenderedGltfModel.java b/src/main/java/com/modularmods/mcgltf/RenderedGltfModel.java
index bb4b3d0..76785d9 100644
--- a/src/main/java/com/modularmods/mcgltf/RenderedGltfModel.java
+++ b/src/main/java/com/modularmods/mcgltf/RenderedGltfModel.java
@@ -75,8 +75,8 @@ public class RenderedGltfModel {
* optifine/shaders.txt
*/
public static final int COLOR_MAP_INDEX = GL13.GL_TEXTURE0;
- public static int NORMAL_MAP_INDEX = GL13.GL_TEXTURE1;
- public static int SPECULAR_MAP_INDEX = GL13.GL_TEXTURE3;
+ public static int NORMAL_MAP_INDEX = GL13.GL_TEXTURE2;
+ public static int SPECULAR_MAP_INDEX = GL13.GL_TEXTURE1;
public static int MODEL_VIEW_MATRIX;
public static int MODEL_VIEW_MATRIX_INVERSE;
@@ -87,7 +87,7 @@ public class RenderedGltfModel {
public static final int vaUV0 = 2;
public static final int vaUV1 = 3;
public static final int vaUV2 = 4;
- public static final int vaNormal = 5;
+ public static final int vaNormal = 10;
protected static final Runnable vanillaDefaultMaterialCommand = () -> {
GL11.glBindTexture(GL11.GL_TEXTURE_2D, MCglTF.getInstance().getDefaultColorMap());
@@ -140,21 +140,38 @@ public class RenderedGltfModel {
static {
if(FabricLoader.getInstance().isModLoaded("iris")) {
- mc_midTexCoord = 7;
- at_tangent = 8;
+ mc_midTexCoord = 12;
+ at_tangent = 13;
shaderModDefaultMaterialCommand = () -> {
- GL13.glActiveTexture(COLOR_MAP_INDEX);
GL11.glBindTexture(GL11.GL_TEXTURE_2D, MCglTF.getInstance().getDefaultColorMap());
- if(NORMAL_MAP_INDEX != -1) {
- GL13.glActiveTexture(NORMAL_MAP_INDEX);
+
+ int currentProgram = GL11.glGetInteger(GL20.GL_CURRENT_PROGRAM);
+ int normalMapLocation = GL20.glGetUniformLocation(currentProgram, "normals");
+ if(normalMapLocation != -1) {
+ GL13.glActiveTexture(GL13.GL_TEXTURE0 + 2);
GL11.glBindTexture(GL11.GL_TEXTURE_2D, MCglTF.getInstance().getDefaultNormalMap());
+ GL20.glUniform1i(normalMapLocation, 2);
}
- if(SPECULAR_MAP_INDEX != -1) {
- GL13.glActiveTexture(SPECULAR_MAP_INDEX);
+ int specularMapLocation = GL20.glGetUniformLocation(currentProgram, "specular");
+ if(specularMapLocation != -1) {
+ GL13.glActiveTexture(GL13.GL_TEXTURE0 + 1);
GL11.glBindTexture(GL11.GL_TEXTURE_2D, MCglTF.getInstance().getDefaultSpecularMap());
+ GL20.glUniform1i(specularMapLocation, 1);
}
+
+ // Enhanced color attribute with proper alpha handling
GL20.glVertexAttrib4f(vaColor, 1.0F, 1.0F, 1.0F, 1.0F);
+
+ // Add entityColor uniform support for shader packs like SEUS PTGI
+ int entityColorLocation = GL20.glGetUniformLocation(currentProgram, "entityColor");
+ if (entityColorLocation != -1) {
+ GL20.glUniform4f(entityColorLocation, 1.0f, 1.0f, 1.0f, 0.0f);
+ }
+
+ // Ensure proper blending state for Iris rendering
+ GL11.glDisable(GL11.GL_BLEND);
+
GL11.glEnable(GL11.GL_CULL_FACE);
};
}
@@ -169,7 +186,20 @@ public class RenderedGltfModel {
GL11.glBindTexture(GL11.GL_TEXTURE_2D, MCglTF.getInstance().getDefaultNormalMap());
GL13.glActiveTexture(SPECULAR_MAP_INDEX);
GL11.glBindTexture(GL11.GL_TEXTURE_2D, MCglTF.getInstance().getDefaultSpecularMap());
+
+ // Enhanced color attribute with proper alpha handling
GL20.glVertexAttrib4f(vaColor, 1.0F, 1.0F, 1.0F, 1.0F);
+
+ // Add entityColor uniform support for shader packs like SEUS PTGI
+ int currentProgram = GL11.glGetInteger(GL20.GL_CURRENT_PROGRAM);
+ int entityColorLocation = GL20.glGetUniformLocation(currentProgram, "entityColor");
+ if (entityColorLocation != -1) {
+ GL20.glUniform4f(entityColorLocation, 1.0f, 1.0f, 1.0f, 0.0f);
+ }
+
+ // Ensure proper blending state for non-Iris rendering
+ GL11.glDisable(GL11.GL_BLEND);
+
GL11.glEnable(GL11.GL_CULL_FACE);
};
}
@@ -191,15 +221,15 @@ protected void processSceneModels(List gltfRenderData, List, List, List> commands = rootNodeModelToCommands.get(nodeModel);
List rootSkinningCommands;
List vanillaRootRenderCommands;
List shaderModRootRenderCommands;
if(commands == null) {
- rootSkinningCommands = new ArrayList();
- vanillaRootRenderCommands = new ArrayList();
+ rootSkinningCommands = new ArrayList<>();
+ vanillaRootRenderCommands = new ArrayList<>();
shaderModRootRenderCommands = new ArrayList();
processNodeModel(gltfRenderData, nodeModel, rootSkinningCommands, vanillaRootRenderCommands, shaderModRootRenderCommands);
rootNodeModelToCommands.put(nodeModel, Triple.of(rootSkinningCommands, vanillaRootRenderCommands, shaderModRootRenderCommands));
@@ -474,88 +504,95 @@ protected void processMeshPrimitiveModelIncludedTangent(List gltfRende
false,
tangentsAccessorModel.getByteStride(),
tangentsAccessorModel.getByteOffset());
- GL20.glEnableVertexAttribArray(at_tangent);
-
- AccessorModel colorsAccessorModel = attributes.get("COLOR_0");
- if(colorsAccessorModel != null) {
- colorsAccessorModel = obtainVec4ColorsAccessorModel(colorsAccessorModel);
- targetAccessorDatas = new ArrayList(morphTargets.size());
- if(createColorMorphTarget(morphTargets, targetAccessorDatas, "COLOR_0")) {
- colorsAccessorModel = bindColorMorphed(gltfRenderData, nodeModel, meshModel, renderCommand, colorsAccessorModel, targetAccessorDatas);
- }
- else {
- bindArrayBufferViewModel(gltfRenderData, colorsAccessorModel.getBufferViewModel());
- }
- GL20.glVertexAttribPointer(
- vaColor,
- colorsAccessorModel.getElementType().getNumComponents(),
- colorsAccessorModel.getComponentType(),
- false,
- colorsAccessorModel.getByteStride(),
- colorsAccessorModel.getByteOffset());
- GL20.glEnableVertexAttribArray(vaColor);
- }
-
- AccessorModel texcoordsAccessorModel = attributes.get("TEXCOORD_0");
- if(texcoordsAccessorModel != null) {
- targetAccessorDatas = new ArrayList(morphTargets.size());
- if(createTexcoordMorphTarget(morphTargets, targetAccessorDatas, "TEXCOORD_0")) {
- texcoordsAccessorModel = bindTexcoordMorphed(gltfRenderData, nodeModel, meshModel, renderCommand, texcoordsAccessorModel, targetAccessorDatas);
- }
- else {
- bindArrayBufferViewModel(gltfRenderData, texcoordsAccessorModel.getBufferViewModel());
- }
- GL20.glVertexAttribPointer(
- vaUV0,
- texcoordsAccessorModel.getElementType().getNumComponents(),
- texcoordsAccessorModel.getComponentType(),
- false,
- texcoordsAccessorModel.getByteStride(),
- texcoordsAccessorModel.getByteOffset());
- GL20.glEnableVertexAttribArray(vaUV0);
-
- AccessorModel texcoords1AccessorModel = attributes.get("TEXCOORD_1");
- if(texcoords1AccessorModel != null) {
- texcoordsAccessorModel = texcoords1AccessorModel;
- targetAccessorDatas = new ArrayList(morphTargets.size());
- if(createTexcoordMorphTarget(morphTargets, targetAccessorDatas, "TEXCOORD_1")) {
- texcoordsAccessorModel = bindTexcoordMorphed(gltfRenderData, nodeModel, meshModel, renderCommand, texcoordsAccessorModel, targetAccessorDatas);
+ GL20.glEnableVertexAttribArray(at_tangent);
+
+ AccessorModel colorsAccessorModel = attributes.get("COLOR_0");
+ if(colorsAccessorModel != null) {
+ colorsAccessorModel = obtainVec4ColorsAccessorModel(colorsAccessorModel);
+ targetAccessorDatas = new ArrayList(morphTargets.size());
+ if(createColorMorphTarget(morphTargets, targetAccessorDatas, "COLOR_0")) {
+ colorsAccessorModel = bindColorMorphed(gltfRenderData, nodeModel, meshModel, renderCommand, colorsAccessorModel, targetAccessorDatas);
+ }
+ else {
+ bindArrayBufferViewModel(gltfRenderData, colorsAccessorModel.getBufferViewModel());
+ }
+ GL20.glVertexAttribPointer(
+ vaColor,
+ colorsAccessorModel.getElementType().getNumComponents(),
+ colorsAccessorModel.getComponentType(),
+ false,
+ colorsAccessorModel.getByteStride(),
+ colorsAccessorModel.getByteOffset());
+ GL20.glEnableVertexAttribArray(vaColor);
+ }
+
+ AccessorModel texcoordsAccessorModel = attributes.get("TEXCOORD_0");
+ if(texcoordsAccessorModel != null) {
+ targetAccessorDatas = new ArrayList(morphTargets.size());
+ if(createTexcoordMorphTarget(morphTargets, targetAccessorDatas, "TEXCOORD_0")) {
+ texcoordsAccessorModel = bindTexcoordMorphed(gltfRenderData, nodeModel, meshModel, renderCommand, texcoordsAccessorModel, targetAccessorDatas);
+ }
+ else {
+ bindArrayBufferViewModel(gltfRenderData, texcoordsAccessorModel.getBufferViewModel());
+ }
+ GL20.glVertexAttribPointer(
+ vaUV0,
+ texcoordsAccessorModel.getElementType().getNumComponents(),
+ texcoordsAccessorModel.getComponentType(),
+ false,
+ texcoordsAccessorModel.getByteStride(),
+ texcoordsAccessorModel.getByteOffset());
+ GL20.glEnableVertexAttribArray(vaUV0);
+
+ AccessorModel texcoords1AccessorModel = attributes.get("TEXCOORD_1");
+ if(texcoords1AccessorModel != null) {
+ texcoordsAccessorModel = texcoords1AccessorModel;
+ targetAccessorDatas = new ArrayList(morphTargets.size());
+ if(createTexcoordMorphTarget(morphTargets, targetAccessorDatas, "TEXCOORD_1")) {
+ texcoordsAccessorModel = bindTexcoordMorphed(gltfRenderData, nodeModel, meshModel, renderCommand, texcoordsAccessorModel, targetAccessorDatas);
+ }
+ else {
+ bindArrayBufferViewModel(gltfRenderData, texcoordsAccessorModel.getBufferViewModel());
+ }
+ }
+ GL20.glVertexAttribPointer(
+ mc_midTexCoord,
+ texcoordsAccessorModel.getElementType().getNumComponents(),
+ texcoordsAccessorModel.getComponentType(),
+ false,
+ texcoordsAccessorModel.getByteStride(),
+ texcoordsAccessorModel.getByteOffset());
+ GL20.glEnableVertexAttribArray(mc_midTexCoord);
+ }
+
+ int mode = meshPrimitiveModel.getMode();
+ AccessorModel indices = meshPrimitiveModel.getIndices();
+ if(indices != null) {
+ int glIndicesBufferView = obtainElementArrayBuffer(gltfRenderData, indices.getBufferViewModel());
+ int count = indices.getCount();
+ int type = indices.getComponentType();
+ int offset = indices.getByteOffset();
+ renderCommand.add(() -> {
+ try {
+ GL30.glBindVertexArray(glVertexArray);
+ GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, glIndicesBufferView);
+ GL11.glDrawElements(mode, count, type, offset);
+ } finally {
+ GL20.glDisableVertexAttribArray(at_tangent);
+ }
+ });
}
else {
- bindArrayBufferViewModel(gltfRenderData, texcoordsAccessorModel.getBufferViewModel());
- }
- }
- GL20.glVertexAttribPointer(
- mc_midTexCoord,
- texcoordsAccessorModel.getElementType().getNumComponents(),
- texcoordsAccessorModel.getComponentType(),
- false,
- texcoordsAccessorModel.getByteStride(),
- texcoordsAccessorModel.getByteOffset());
- GL20.glEnableVertexAttribArray(mc_midTexCoord);
- }
-
- int mode = meshPrimitiveModel.getMode();
- AccessorModel indices = meshPrimitiveModel.getIndices();
- if(indices != null) {
- int glIndicesBufferView = obtainElementArrayBuffer(gltfRenderData, indices.getBufferViewModel());
- int count = indices.getCount();
- int type = indices.getComponentType();
- int offset = indices.getByteOffset();
- renderCommand.add(() -> {
- GL30.glBindVertexArray(glVertexArray);
- GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, glIndicesBufferView);
- GL11.glDrawElements(mode, count, type, offset);
- });
- }
- else {
- int count = positionsAccessorModel.getCount();
- renderCommand.add(() -> {
- GL30.glBindVertexArray(glVertexArray);
- GL11.glDrawArrays(mode, 0, count);
- });
- }
- }
+ int count = positionsAccessorModel.getCount();
+ renderCommand.add(() -> {
+ try {
+ GL30.glBindVertexArray(glVertexArray);
+ GL11.glDrawArrays(mode, 0, count);
+ } finally {
+ GL20.glDisableVertexAttribArray(at_tangent);
+ }
+ });
+ } }
protected void processMeshPrimitiveModelSimpleTangent(List gltfRenderData, NodeModel nodeModel, MeshModel meshModel, MeshPrimitiveModel meshPrimitiveModel, List renderCommand, Map attributes, AccessorModel positionsAccessorModel, AccessorModel normalsAccessorModel) {
int glVertexArray = GL30.glGenVertexArrays();
@@ -693,16 +730,24 @@ protected void processMeshPrimitiveModelSimpleTangent(List gltfRenderD
int type = indices.getComponentType();
int offset = indices.getByteOffset();
renderCommand.add(() -> {
- GL30.glBindVertexArray(glVertexArray);
- GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, glIndicesBufferView);
- GL11.glDrawElements(mode, count, type, offset);
+ try {
+ GL30.glBindVertexArray(glVertexArray);
+ GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, glIndicesBufferView);
+ GL11.glDrawElements(mode, count, type, offset);
+ } finally {
+ GL20.glDisableVertexAttribArray(at_tangent);
+ }
});
}
else {
int count = positionsAccessorModel.getCount();
renderCommand.add(() -> {
- GL30.glBindVertexArray(glVertexArray);
- GL11.glDrawArrays(mode, 0, count);
+ try {
+ GL30.glBindVertexArray(glVertexArray);
+ GL11.glDrawArrays(mode, 0, count);
+ } finally {
+ GL20.glDisableVertexAttribArray(at_tangent);
+ }
});
}
}
@@ -751,231 +796,237 @@ protected void processMeshPrimitiveModelMikkTangent(List gltfRenderDat
GL20.glEnableVertexAttribArray(vaNormal);
AccessorModel texcoordsAccessorModel = attributes.get("TEXCOORD_0");
- AccessorModel tangentsAccessorModel = obtainTangentsAccessorModel(meshPrimitiveModel, positionsAccessorModel, normalsAccessorModel, texcoordsAccessorModel);
- targetAccessorDatas = new ArrayList(morphTargets.size());
- if(createTangentMorphTarget(morphTargets, targetAccessorDatas, positionsAccessorModel, normalsAccessorModel, texcoordsAccessorModel, "TEXCOORD_0", tangentsAccessorModel)) {
- bindVec3FloatMorphed(gltfRenderData, nodeModel, meshModel, renderCommand, tangentsAccessorModel, targetAccessorDatas);
- }
- else {
- bindArrayBufferViewModel(gltfRenderData, tangentsAccessorModel.getBufferViewModel());
- }
- GL20.glVertexAttribPointer(
- at_tangent,
- tangentsAccessorModel.getElementType().getNumComponents(),
- tangentsAccessorModel.getComponentType(),
- false,
- tangentsAccessorModel.getByteStride(),
- tangentsAccessorModel.getByteOffset());
- GL20.glEnableVertexAttribArray(at_tangent);
-
- AccessorModel colorsAccessorModel = attributes.get("COLOR_0");
- if(colorsAccessorModel != null) {
- colorsAccessorModel = obtainVec4ColorsAccessorModel(colorsAccessorModel);
- targetAccessorDatas = new ArrayList(morphTargets.size());
- if(createColorMorphTarget(morphTargets, targetAccessorDatas, "COLOR_0")) {
- colorsAccessorModel = bindColorMorphed(gltfRenderData, nodeModel, meshModel, renderCommand, colorsAccessorModel, targetAccessorDatas);
- }
- else {
- bindArrayBufferViewModel(gltfRenderData, colorsAccessorModel.getBufferViewModel());
- }
- GL20.glVertexAttribPointer(
- vaColor,
- colorsAccessorModel.getElementType().getNumComponents(),
- colorsAccessorModel.getComponentType(),
- false,
- colorsAccessorModel.getByteStride(),
- colorsAccessorModel.getByteOffset());
- GL20.glEnableVertexAttribArray(vaColor);
- }
-
- targetAccessorDatas = new ArrayList(morphTargets.size());
- if(createTexcoordMorphTarget(morphTargets, targetAccessorDatas, "TEXCOORD_0")) {
- texcoordsAccessorModel = bindTexcoordMorphed(gltfRenderData, nodeModel, meshModel, renderCommand, texcoordsAccessorModel, targetAccessorDatas);
- }
- else {
- bindArrayBufferViewModel(gltfRenderData, texcoordsAccessorModel.getBufferViewModel());
- }
- GL20.glVertexAttribPointer(
- vaUV0,
- texcoordsAccessorModel.getElementType().getNumComponents(),
- texcoordsAccessorModel.getComponentType(),
- false,
- texcoordsAccessorModel.getByteStride(),
- texcoordsAccessorModel.getByteOffset());
- GL20.glEnableVertexAttribArray(vaUV0);
-
- AccessorModel texcoords1AccessorModel = attributes.get("TEXCOORD_1");
- if(texcoords1AccessorModel != null) {
- texcoordsAccessorModel = texcoords1AccessorModel;
- targetAccessorDatas = new ArrayList(morphTargets.size());
- if(createTexcoordMorphTarget(morphTargets, targetAccessorDatas, "TEXCOORD_1")) {
- texcoordsAccessorModel = bindTexcoordMorphed(gltfRenderData, nodeModel, meshModel, renderCommand, texcoordsAccessorModel, targetAccessorDatas);
- }
- else {
- bindArrayBufferViewModel(gltfRenderData, texcoordsAccessorModel.getBufferViewModel());
- }
- }
- GL20.glVertexAttribPointer(
- mc_midTexCoord,
- texcoordsAccessorModel.getElementType().getNumComponents(),
- texcoordsAccessorModel.getComponentType(),
- false,
- texcoordsAccessorModel.getByteStride(),
- texcoordsAccessorModel.getByteOffset());
- GL20.glEnableVertexAttribArray(mc_midTexCoord);
-
- int mode = meshPrimitiveModel.getMode();
- int count = positionsAccessorModel.getCount();
- renderCommand.add(() -> {
- GL30.glBindVertexArray(glVertexArray);
- GL11.glDrawArrays(mode, 0, count);
- });
- }
-
- protected void processMeshPrimitiveModelFlatNormalSimpleTangent(List gltfRenderData, NodeModel nodeModel, MeshModel meshModel, MeshPrimitiveModel meshPrimitiveModel, List renderCommand) {
- int glVertexArray = GL30.glGenVertexArrays();
- gltfRenderData.add(() -> GL30.glDeleteVertexArrays(glVertexArray));
- GL30.glBindVertexArray(glVertexArray);
-
- Pair