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,
maybe this post can help you:
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:
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..
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.
----------begin_max5_patcher---------- 1105.3oc0Z1sbahCEG+Z6mBMd1KS7nOvfYuJ8kn2rSmLXP1VIxRtH4X2sSe2 WPBZvoXi5VLHOYBLH.wQ+3ny4+Q3uOcxrUxST0LveC9GvjIee5jIllJaXR0w SlsK4TJOQYtrY6nJUxF5rGrmSSOoMsmSSx.YukcH8U07cx2pu.Vl4zxUu7HZ YciqkBsHYG0bpOSyyRDIMOmh8ulygfygUMKNriI3TswJvUMtOmpnBchlIEOm SS01QR.lTbefkQkagUa.e48dRdPW2Un5tJQmtkI1znaHPy8RLaQPSehhZzS1 tQ+s8T6MLaF3Kkm4GSmVt4g+PjVLzxJdD6OnAqYbMMGHjBZafMruAq6LplN1 cX7PCo87DAE7HpErPPiFVp3AI1raA7VQkWX54oTNeEWl9ZKH.G6BBRk7yFl4 ximc7uChJ5qirL8V60BaEbAWAbAFVEXQFFFaNJ7ZjiyT5YOTPv5++eQRA8XA v9E2qR.uKQmyN0Fc6s.ZnV4DtaNgM6VZcvhuFlJFIOWORtAPZCethmrBrVJA OUDthB1vU7GyoEYDnye4jB7TRVxdM.BdJisCfA359gyDzT4Agt4XtIlitsyi uBlw1vajHKfsYTHnt37F9ykv4PN0KX8BPfyrNbzYM4tl0HHXoyvNXrgMN9tF 1XH.svYZSFcZuvancNPuktJQroszZ8ltI3uqto5X.VYSK6NqV+JlzVDCSskd wZXhGOo1VMkglsw2rpQtxzyupKoBq0RPVLZRgvmUBheHE5MVFUZKMoHVVa7J Xr4UkzQDI5tS6X.rXxfyg8widXezccR1kvhXNNSa3XSaz8sVcTXglFry7FM5 hZPifd8Kk+d8ANWklSoBve01JBMdKHjsb8JjEEdqRdqka1vaK+7OCB5Ptiqs tVmGQKp6wAqz0sGmSonbv6KHPyU6azlHD2jIj3tSmZ0c2yAadk9sVnRvsUJe Pmd7VpDP5lJkdJOz1t9Nj7QlHSd7BByFOcrAMqQbYvH4FotRggg2V1.uLarE 8TsnmMqKr2SVmSEYz7K3bDMxNGUZahw2ZmiRXrduZyAVKTn8U89S4rDdqL.0 Wq4MrYgdVWBRvUSh12yNzfUE+QySTTvpVPS7s0Aoyvs1peiHt6eTu2Ll9YC8 q3CDreTeT8MOp9zP0aGNsGecGUmKAuqNu4Xbr0VZmOD5Zdiy3h4ZM0Z7geK. lmVY6mCKk7PdZc2U+IZ.u+HynJMSX9r7Mtnx07nwEskkkQEMC7uiksWV7Rqx HtvqNWsoxetAcaSKFVaJzAa5CvzOroPOzlB7Pah3g1D1CsIn+YSnA9cWr+Ee p7S+3cwLW3eu69f6qeLui3ey6BbvjF12bNAog0WxE26g0SxEuaz.aStDYJdP MoxmFpCKJbvsHRGVzxg04F6ehlvD+SbINv+Dgi8vhUvtTTGdXiCPP9mM4TA4 3kCdzIbGlTzfaQPuxhbwU5OQ9cwA+X5+AJBasPB -----------end_max5_patcher-----------
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.
Forums > Jitter