views:

117

answers:

2

As far as I know, certain mathematical functions like FFTs and perlin noise, etc. can be much faster when done on the GPU as a pixel shader. My question is, if I wanted to exploit this to calculate results and stream to bitmaps, could I do it without needing to actually display it in Silverlight or something?

More specifically, I was thinking of using this for large terrain generation involving lots of perlin and other noises, and post-processing like high passes and deriving normals from heightmaps, etc, etc.

+1  A: 

The short answer is yes. The longer answer is that you can set (for example) a texture as the render target, which deposits your results there.

Unless you're really set on using a shader to do the calculation, you might want to consider using something that's actually designed for this kind of job such as Cuda or OpenCL.

Jerry Coffin
Is Cuda or OpenCL available from within Silverlight?
AnthonyWJones
@AnthonyWJones: I'm really not sure.
Jerry Coffin
If silverlight supports DX11, then you could use compute shaders, though this will limit you to running on DX10 hardware (I believe there's a cut down version of compute shaders for DX10 level hardware, still need DX11 though). Otherwise, I'd say Cuda/OpenCL isn't supported (would need a 3rd party DLL and then that probably won't be viable if you are doing a web app or something similar).
Grant Peters
A: 

Hmm its a good question.

You anything that you can be displayed can be rendered using an instance of WriteableBitmap and its Render method. You can access the output using the Pixels byte array property.

However (assuming GPU acceleration is turned on and the content is appropriately marked to make use of the GPU) whether such a render will actually make use of the GPU when going to a WriteableBitmap instead of the display I don't know.

AnthonyWJones