Reputation: 183
I have two render targets that i draw to, and i want to combine (blend) them, easiest by alpha value maybe, to one picture using the gpu via directx. One target is the background, the other the data i want to plot.
I can't just plot the data over the background, because i don't want to store the data between new draws. That works well for other use cases. But now not anymore. So I append the data to the one target and it would be nice to just blend this two targets efficiently.
I'm a bit lost in the documentation and can't really find an example to relate. I'm using sharpdx
Any help appreciated, thanks
Upvotes: 1
Views: 489
Reputation: 444
If the 2 targets are independent, and you want to render one into the other. I suggest you do something similar to what I do.
Which is, make first render target (on the first pass) a texture resource and sample from it. As you render to the 2nd, sample from the first. I've done that in my current project to blend 2 or 3 sources together.
Upvotes: 0
Reputation: 111
You can easily combine to rendertargets in a shader. Just create two rendertargets with resource binding and render your scene to them, after that you pass the shaderresourceviews to the shader and combine them with your method of choice (multiply, adding etc.) All these things are typically used in "Deferred Shading".
Another source to see this approach in action, you can find here: RobyDX - SharpDX Samples
Upvotes: 0