I want to know how is the fastest way
to get whats the lowest alpha value in a texture
performance method
If the texture data never changes just do it at load time and store it out somewhere. Best case is that you'll be passing over the texels anyway so you can combine the computation with the pass; worst case is that you may need to copy it off to a staging resource, map that, and calculate from there. I don't know of any easy way to get the lowest alpha at runtime for dynamic textures; average alpha is easy as pie (just sample from the smallest mip level) but lowest? Nope.
It is a dynamic texture, I'm still looking for the fastest way to do it, not the easiest, i dont care about complexity. I have tought about rendering to another texture that is half the number of pixels of the original texture and to each pixel of this new texture will be rendered the lowest alpha bettwen 2 pixels of the original, and do this again and again until there is small number of pixels were its faster to read all of them and compare them in one pass(i mean in one shader method pass).
Downsampling to one pixel will work. That will be the fastest, assuming you only need the value on the GPU (e.g. for a shader to sample from).
Do you need this information on the CPU? If so, do you need to maintain interactive framerates? If not, just copy the texture data to CPU memory and run through it.
Do you need this information on the CPU? If so, do you need to maintain interactive framerates? If not, just copy the texture data to CPU memory and run through it.
I dont need the info in the CPU.
Can you help me on how to do that down sampling?
Is the that downsampling what i just write in my second comment or is another way.
Can you help me on how to do that down sampling?
Is the that downsampling what i just write in my second comment or is another way.
FWIW you may be able to speed that up a bit by downsampling by a factor of 4 or more each pass-- usually write bandwidth doesn't scale quite as well as read does (and you do a lot more writing with a 2x2 than with a 4x4 or greater, let alone need more passes/CPU time)
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement