Forum

Is it possible to only process parts of a texture in pixel shader?


#1

Hey evvvveryone,
I’ve been thinking about this for some time now, but never found a way, so maybe someone can help…
Setup: Facing the camera I’m stacking quads front to back with alpha cutouts in their corresponding textures, so that in the renderer one can see parts of the second layer through “holes” in the first layer, and then again through other holes in the second layer down to the third layer and so on.
So there’s only very little portions of the third layer’s texture that can be seen. If I wanted to run my composited image through a pixel shader this wouldn’t be a problem, but wanting different effect settings on each layer I’d have to process each texture individually and it seems to me I’m wasting a lot of computational power in places that can’t even be seen in the final image.
So is there a way to only process those areas of a texture which can actually be seen?
Concepts like depth prepass or usage of depth stencil won’t work I think, as there’s no real geometries but only flat planes with alpha.
If you don’t know what I’m talking about, maybe this helps:
vvvvForum

Thanks in advvvvance :)


#2

in dx11 there is AlphaToCoverage which writes into the depth buffer depending on the alpha of a texture, this migh help you to enable/disable pixel shaders for certain areas.

however, pixel shaders that process textures are so fast, that i doubt that it would make much of a difference in the end. i would only start with such optimizations when you really get into performance problems.

if you have a laptop with two GPUs make sure vvvv runs on the dedicated card and not the integrated one.