This is actually a follow up to this question How to capture the screen in DirectX 9 to a raw bitmap in memory without using D3DXSaveSurfaceToFile
The proponent of the best solution suggested that I should look at a shader program to capture the screen. How could I do that. I have no clue on how can I use a shader program to do that.
Answer
Shaders don't capture the screen in and of themselves. What's being suggested in the "shader based approach" is to:
1) Use render-to-texture or the like to render your entire scene to a single texture 2) Render that texture (with, say, a fullscreen quad) to your final output (or another texture if you want to chain effects or do multi-pass effects) using pixel and/or vertex shaders written in HLSL to apply your filtering effect instead of C++.
This has the advantage of keeping everything in GPU memory instead of spending your limited memory bandwidth copying everything from GPU to system memory (where C++ can work on it) and back (where it can be rendered.)
Methods of note for wrangling pixel shaders (commonly used for operations such as bluring, depth of field effects, tinting, you name it): D3DXCompileShaderFromFile, CreatePixelShader, SetPixelShader, SetPixelShaderConstantF
And for render targets: SetRenderTarget, BeginScene, and EndScene.
No comments:
Post a Comment