So theoretically speaking would it be possible to bind a buffer object as a uniform that I can treat like an arbitrary length array from GLSL. And bind in opengl like a uniform.
Let me give you an example of a use for this:
Bind this theoretical uniform as an array of 250 model matrices (not possible as a uniform array on most(any?) cards).
Call glDrawArraysInstanced with 250 as the input.
The shader can index into this array and use the correct matrix. This further reduces the number of calls for languages with expensive FFI (Java being my specific example).
I know textures can provide something like this. But unless I am mistaken, to do this with textures, I would have to sample the texture 16 (12 if I assumed some things) times to get the full matrix. I feel like this can be done hardware wise, because CUDA can apparently do it.
So any tips or hints?
But unless I am mistaken, to do this with textures, I would have to sample the texture 16 (12 if I assumed some things) times to get the full matrix.
What? Buffer textures can use RGBA formats. That’s 4 accesses per matrix. And you can make that 2 if you use quaternion+position “matrices” (whether that works depends on what these matrices are, of course).
I feel like this can be done hardware wise, because CUDA can apparently do it.
It doesn’t matter if hardware can do something, if there’s no API to allow you to do anything with it.
The closest you’re going to get with actual OpenGL is buffer textures. If you are willing to live in NVIDIA-land, then you can use NV_shader_buffer_load, which allows you to lock down a buffer object and pass GPU addresses around, which you can fetch from in a shader.
I knew I could count on you to respond quickly if I didn’t recheck my post for errors :p.
Those were exactly the answers I was looking for with the level of pompousness I have come to expect. Thank you!
You can also use uniform buffer objects, they are a bit faster and can be accessed without going through the texture samplers, but they are limited in their size.
This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.