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

Conversation

yahel-ck
Copy link

Adds #define attrib_instancedFlag for each instanced attribute, mostly to allow declaring an attribute instead of a uniform when the specific attribute is instanced (like I did with u_worlTransform for example).

I tested it with this demo that implements instancing u_worldTransform: https://github.com/yahel-ck/libgdx_instancing_demo
The demo is using gdx-gltf to render, but it uses the same underlying LibGDX classes.
I tested it on VMs of iOS and Android, and on a physical Android device (Samsung S21).

It wouldn't take much work to implement the demo solely with LibGDX so let me know if you think it's necessary, or if there are any other tests I should make.
Thanks :)

Copy link
Contributor

@mgsx-dev mgsx-dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, there are some things that won't work i think :

  • overriding u_worldTrans by instanced data is not a good idea :
    • some may want to use both instance transform and modelInstance.transform together.
    • some other uniforms are computed based on renderable.worldTransform (eg. normalMatrix attribute).
  • some changes are missing for the depth shader (used to render shadows)
  • #define worldTrans_instancedFlagwill be generated 4 times because it requires 4 attributes with the same name. And tbh, i'm not fan of generating these flags automatically (it could clash with custom shader implementations).

I played around with this topic some times ago and end up with a new attribute used together with u_worldTrans, something like this :

#ifdef INSTANCE_TRANSFORM
attribute mat4 i_transform;
#endif

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants