Direct3d/C# - Blur area under a rectangle drawn on a sprite

女生的网名这么多〃 提交于 2019-12-24 08:09:43

问题


Any idea how to do it? I am drawing a rectangle that is supposed to be a half-transparent window. I managed to do the transparency by drawing a half-transparent texture, but I also want to blur whatever is under the window.

Normally (eg. using GDI) I would create a bitmap of the area, blur it and paint it as the background of my window. With Direct3D I don't even know how to get the area with whatever is already rendered on it. Or even there can be a different approach, can't it. Please help.


回答1:


The D3D way is to use a pixel shader to "blur" the area underneath your rect.

This link shows you how to use a pixel shader in C#.
And this link has a guassian blur pixel shader.




回答2:


It DOES require having your backbuffer as a texture. You can then render the whole thing to a NEW texture and blur the relevant part before putting your semi-trans window over the new texture.

Edit: AFAIK you can't use the Draw function inside a shader. You will need to write your own sprite renderer. The Begin and Draw set up a whole load of states that will break your usage of a vertex shader.



来源:https://stackoverflow.com/questions/1541961/direct3d-c-blur-area-under-a-rectangle-drawn-on-a-sprite

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!