Blending texture to backbuffer

Started by
3 comments, last by unbird 7 years, 7 months ago

Hi everyone!

I have a full-screen texture with UI.

I need to blend it to backbuffer.

UI texture and Backbuffer have the same resolution, sample count, and format.

The only solution came to my mind is do it over full-screen quad with shaders.

Is there a better way to do the job?

Thanks in advance.

PS: I use DX11

Advertisement

So, like a HUD?

Couple thoughts come to mind. You can put the HUD element in NDC space by omitting any transformations in your shader, or, better yet, you could just use a orthographic projection matrix for the HUD elements, render the HUD last while also disabling the Z-Buffer.

Marcus Hansen

So, like a HUD?

Couple thoughts come to mind. You can put the HUD element in NDC space by omitting any transformations in your shader, or, better yet, you could just use a orthographic projection matrix for the HUD elements, render the HUD last while also disabling the Z-Buffer.

I want to render all HUD elements in separate fullscreen texture.

After that I need to blend it with backbuffer.

I took the idea from here: DOOM (2016) - Graphics Study (User Interface section)

So I wonder, is there some shortcut method to blend 2 textures with the same size, format, and sample count in Direct3D?

Oh, I see like post-processing.

hmmm (there might be a better way to do it), in your pixel shader you could do something like this:

Where color1 would be your backbuffer, and color2 the offscreen texture for your HUD.


color1 = colorMapOne.Sample(sampler, texel.texCoord);
color2 = colorMapTwo.Sample(sampler, texel.texCoord);

blendColor = color1 * color2 * 2.0;

Marcus Hansen

So I wonder, is there some shortcut method to blend 2 textures with the same size, format, and sample count in Direct3D?

Nope. ID3D11DeviceContext::CopyResource comes closest but doesn't allow multi-sampled resources nor blending. So rendering a full-screen quad/triangle and blending it is.

This topic is closed to new replies.

Advertisement