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

Warning about gl_InstanceID and uniform block (buffer?) object fields #136

Open
ibsusu opened this issue Apr 25, 2022 · 2 comments
Open

Comments

@ibsusu
Copy link

ibsusu commented Apr 25, 2022

Hello,

I've been doing some research about uniform block objects and instancing with OGL. Right now Geometry raises a warning for anything that's contained inside of a uniform block object. It also raises a warning for gl_InstanceID.

attribute vec3 position;
attribute vec3 offset;

uniform Group {
      uniform vec3 groupPos[10];
      uniform vec3 groupRotation[10];
};

void main() {
    vec3 pos = position;
    pos += groupPosition[gl_InstanceID]+ offset + groupRotation[gl_InstanceID];
    gl_Position = projectionMatrix * modelViewMatrix * vec4(pos, 1.0);
}

Secondly, on this line right here:

if (attr.needsUpdate) this.updateAttribute(attr);

It chokes on gl_InstanceID. I just did a check to see if it's that name and bail out if it is.

If I make a PR that provided better support for instancing and Uniform Block Objects would that be ok? The reason I'm interested in doing it this way is because I can get really good performance and modify groups of instances of different geometries with a single change. BTW this code won't work on Firefox atm. Firefox doesn't support vectors in uniform block objects for some reason. uniform vec3 groupPos[10];. Safari and Chrome are fine though.

If there's another way to do this let me know please.

@gordonnl
Copy link
Contributor

UBO support would be an excellent feature for OGL, absolutely! Especially with Webgl2 starting to gain universal support with the addition of safari.
At the moment there would still be a need to create a WebGL1 fallback, however I'm still interested to see your implementation in any case!

@ibsusu
Copy link
Author

ibsusu commented May 28, 2022

I'll need a bit but this is definitely on my todo list. Close this if you want to remove clutter.

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

No branches or pull requests

2 participants