What might be causing that?
--
Dr Jon D Harrop, Flying Frog Consultancy Ltd.
http://www.ffconsultancy.com/products/?u
I suppose you're passing it as a uniform. Unfortunately at least Nvidia
has taken the approach of treating uniforms as constants and recompiling
the whole shader whenever a uniform changes. You probably see delays
caused by framerate drops due to recompiling.
Philipp
Ugh, is there another way for me to pass them in?
Use a varying.
Philipp
Aren't varyings supposed to transport data from the vertex shader to the
fragment shader? Do you suggest passing the time as uniform to the
vertex shader and from there as varying to the pixel shader? If so, that
would improve performance only if the vertex shader is significantly
simpler than the fragment shader, wouldn't it?
Malte
Don't use a uniform. Use vertex attributes to pass it to the vertex
shader and a varying to pass it from the vertex to the fragment shader.
Philipp
> Don't use a uniform. Use vertex attributes to pass it to the vertex
> shader and a varying to pass it from the vertex to the fragment shader.
How can you pass a single "global" value as a vertex attribute? Do you
mean that the data needs to be set on each vertex? If the change in
the uniform causes a recompile, then NVIDIA needs to fix the problem.
I personally haven't looked for any similar performance glitch but I
just recently started using uniforms that change multiple times for
each update.
Can you clarify?
ts
In hardware skinning area, using Uniform values to change matrices used by
the shader is the way to go (at least with all ressources i've read and my
homework i got working). Those matrices are recalculated each frame, using
the time and interpolation coupled to the animation sequences.
On the other hand, I have multiple static VBOs (vertex position, color, and
bones indices + bones weights) which never change between frames.
So, the only thing that it takes me to display a model each frame is to
recalculate the bones position, and update them to the shader via Uniforms.
On a graphic card having room for ~ 12-24 bones matrices, which is common,
but could be up to 80, and a model having at least 100 bones, it means that
you have to split your model into at least 5 batch, each having a couple of
Uniform updates to change the bones matrices.
Moving those global values to vertex attributes would need 4 more vertex
attributes (each vertex have up to 4 bones weights/indices), which would need
much more graphic card memory and VBOs data pre-fetching performance hits,
and even more if you want to display the same model multiple times in a scene.
I doubt that people which first moved this previously CPU-done work onto the
GPU (multiplying the vertex by the bones matrices indexed by bones indices)
lost performance by doing this.
So i guess that if you have a "global value", you should put in a Uniform,
and if it does a huge performance hit, it's an issue with the driver.
It tooks me a lot of time to find and read good documentation on hw skinning,
so, if some people are more interested in this area, feel free to throw an
eye through a set of copy-and-paste stuff i mostly took from gamedev.net
forums: http://hyrule.folays.net/skinning/ , and also this paper:
http://home.comcast.net/~tom_forsyth/papers/fast_vert_cache_opt.html
--
folays