Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add instanced attributes flags to GLSL prefix #7277

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -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
Expand Down
11 changes: 11 additions & 0 deletions gdx/src/com/badlogic/gdx/graphics/g3d/shaders/DefaultShader.java
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down