diff --git a/gdx/res/com/badlogic/gdx/graphics/g3d/shaders/default.vertex.glsl b/gdx/res/com/badlogic/gdx/graphics/g3d/shaders/default.vertex.glsl index 3cbd6635590..e6b2c912edd 100644 --- a/gdx/res/com/badlogic/gdx/graphics/g3d/shaders/default.vertex.glsl +++ b/gdx/res/com/badlogic/gdx/graphics/g3d/shaders/default.vertex.glsl @@ -103,7 +103,11 @@ attribute vec2 a_boneWeight7; #endif #endif +#ifdef u_worldTrans_instancedFlag +attribute mat4 u_worldTrans; +#else uniform mat4 u_worldTrans; +#endif //u_worldTrans_instancedFlag #if defined(numBones) #if numBones > 0 diff --git a/gdx/src/com/badlogic/gdx/graphics/g3d/shaders/DefaultShader.java b/gdx/src/com/badlogic/gdx/graphics/g3d/shaders/DefaultShader.java index 25d20c3a1ab..de4b84ea923 100644 --- a/gdx/src/com/badlogic/gdx/graphics/g3d/shaders/DefaultShader.java +++ b/gdx/src/com/badlogic/gdx/graphics/g3d/shaders/DefaultShader.java @@ -20,6 +20,7 @@ import com.badlogic.gdx.graphics.Camera; import com.badlogic.gdx.graphics.GL20; import com.badlogic.gdx.graphics.VertexAttribute; +import com.badlogic.gdx.graphics.VertexAttributes; import com.badlogic.gdx.graphics.VertexAttributes.Usage; import com.badlogic.gdx.graphics.g3d.Attribute; import com.badlogic.gdx.graphics.g3d.Attributes; @@ -744,6 +745,16 @@ public static String createPrefix (final Renderable renderable, final Config con if ((attributesMask & FloatAttribute.AlphaTest) == FloatAttribute.AlphaTest) prefix += "#define " + FloatAttribute.AlphaTestAlias + "Flag\n"; if (renderable.bones != null && config.numBones > 0) prefix += "#define numBones " + config.numBones + "\n"; + + final VertexAttributes instancedAttrs = renderable.meshPart.mesh.getInstancedAttributes(); + if (instancedAttrs != null) { + final int attrsCount = instancedAttrs.size(); + for (int i = 0; i < attrsCount; i++) { + final VertexAttribute attr = instancedAttrs.get(i); + prefix += "#define " + attr.alias + "_instancedFlag\n"; + } + } + return prefix; }