min and max value in texture ?
i'm still relatively new in shaderland and I'm trying to slabify a patch I made in 'vanilla' jitter ages ago.
It all seems to work out fine, but I'm getting stuck trying to replicate some of jit.3m's functionality in/with a shader. I need to get minimum and maximum values of a texture.
Is that possible in a shader or do I have to go back to vanillajitterland for this ?
thanks for any insight,
Joost.
hello Joost:
maybe this post can help you:
http://www.gamedev.net/community/forums/topic.asp?topic_id=559942
Emmanuel
as should be apparent from reading the linked thread, this is not really something shaders are used for (without devising some sort of complicated multi-pass method).
generally, you should think of your shader as operating on a single pixel or vertex at a time.
I think it would be more expensive to calculate the min and max values from the shader, am i correct?
Ok, thanks a lot for the answers and the pointers. I'm aware 'global' properties of a texture like max and min are not typically things you should do with a shader, but I'm trying to avoid having to go back to the CPU. was hoping for a magical trick that doesn't exist.
The key to a possible solution is here:
http://http.developer.nvidia.com/GPUGems/gpugems_ch37.html
see the bit about reductions.
Jitter comes with a gp.reduce.jxs shader that is identical to the example given on that page, but I haven't figured out yet how to use it; my knowledge of openGL is not big enough for that to be obvious...
If anybody knows how to set up these reductions I would be very grateful if he/she would share it..
thanks,
Joost.
hey joost. i couldn't get the cg shader to work, but here's a glsl one that seems to do the trick.
shader and patch below.
Hey Rob, that's great.
Sorry for not paying attention to the forum for a while: I got to pretty much the same point as you a couple of days ago, wrote a glsl shader as an excercise and yes, it works. The only thing is that there is a *big* difference between the maximum this calculates and the maximum jit.3m calculates directly out of the jit.qt.movie. If you check the dishes movie, jit.3m gives a solid 255 255 255 255 and that is very different value than the maxima in the cellblock... Minimum same thing.
Perhaps it has to do with some kind of interpolation ?
hmm, had no idea why this is happening and found a way to get my slabbypatch to work without a maximum and a minimum. And yes, it is fast an gorgeous, so I'm happy and building a more robust version. Thanks for the help and advice..
hmm, when I read my post again I wonder why it would actually matter that jit.3m maxima are different from slab maxima. Perhaps that reflects a real situation (even though I don't understand why that happens) and in the end we only care about the slabmaxima here, don't we ?
Now I'm happy without them, so hopefully this will be of use in the future.
ciao,
Joost.