-
Notifications
You must be signed in to change notification settings - Fork 263
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
Missing and incorrect uniform block types #184
Comments
Thanks. UniformData.used is not a thing and built-in uniforms are skipped (or should be) Line 1069 in e48e3e1
|
Thank you for the fix! You're right; my mistake. I'm actually running into some problems with that built-in check. I was gonna do some more research and file a separate issue. Why is that a |
That would be a bug 😅 Do you have a shader where a built in shows up? I've never actually seen one. It would be helpful to test. |
Yes, I do, but it will take me some time to isolate a test case for you. I'm working with the |
Thanks! I was able to repo the issue locally and write a kind of test for it. The test failed until I fixed things though it only failed by luck that I pushed up a new version |
To be clear, I think, but not 100% sure, there is no reason to remove the built in from the uniform data being gathered. It won't be used and fixing the code so it skips getting info for that uniform is a minor headache (not a big deal but the loop index won't match uniform index). I know calling |
This works much better! Agreed about the strange aspect of the spec. This is a big help. I'm going to try to get multi-draw and UBOs working together in a non-trival case, and if I can suggest a good way to handle the massive arrays here, I'll file another issue. Thanks again. |
I think I see what you're getting at. If you make
You'll get one setter
You'll get I'm open to suggestions but off the top of my head, at some point if you're doing something too complicated you should consider maybe twgl isn't the solution? Or, just update the data yourself via If
I guess you could try to make a setter that took an object
Sounds like overkill to me. If you're doing something that complicated maybe you want to put the values in the buffer yourself? Just thinking out loud. I'm not sure what you were doing, only guessing based on your comments. If there as a simple and not too large solution I'm open to it. |
Yes, I think we're on the same page here. I think I'm gonna implement my own solution in place of I'm working with an example right now that has ~2000 entries in |
So I got curious. It wasn't too hard to write a setter like the one I described above. I only wrote it for regular uniforms so far but it works like this. Given uniforms like this
You can set them like this
I don't think it would be hard to make it work for uniform blocks too. But ..... is that better? For example, if you want to set only the color of the 2nd light, with
Where as I don't think there is any way to do that with
I'm not sure it's important to be able to set individual things. I can certainly keep your own object around
and then set just the color of the 2nd light with
|
Well I ended up checking it in for both regular uniforms and uniform blocks. Unlike the example above you just use You can now specify any valid path so for example, given
If you just want to update the second light you can do
But, ATM, not for leafs. In other words you can't do this
That's been true forever with twgl. If you had
You had to provide all 3 values for someFloat
There was no way to set just |
Wow, that's awesome. I will check it out. Thanks again! |
Looks like you have a small code syntax typo in README: twgl.setUniforms(progInfo, {
lights[1]: { intensity: 5.0, shininess: 100, color: [1, 0, 0, 1] },
}); should be: twgl.setUniforms(progInfo, {
'lights[1]': { intensity: 5.0, shininess: 100, color: [1, 0, 0, 1] },
}); Specifically, the property key should be a string. |
thanks! fixed |
Hi, thanks for this very helpful library. I found a few issues with the type annotations:
uniformBlockSpec
is mis-typed asuniformBlockSpace
onProgramInfo
Here. This shows up as an incorrect property name in the documentation and in code editor auto-complete.
UniformBlockSpec
is missingblockSpecs: { [key: string]: BlockSpec }
property.Looks like this exists in an old file but is no longer in the source, even though the property is still created by
createUniformBlockSpecFromProgram
. I can't find the commit where it was removed.UniformData
is missing a couple properties:name
andused
Both are created by
createUniformBlockSpecFromProgram
.name
seems to be optional, since it's not added to built-in uniforms. Not sure if that's deliberate though.The text was updated successfully, but these errors were encountered: