1

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.

George R
  • 3,784
  • 3
  • 34
  • 38
  • As a follow-up, i'm looking into OpenGL Framebuffer objects, which are rendered offscreen. I'll approach it with OpenTK (.NET <-> OpenGL). http://stackoverflow.com/questions/1483903/fragment-shader-rendering-to-off-screen-frame-buffer – George R Apr 20 '10 at 12:18

2 Answers2

1

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
  • 476,176
  • 80
  • 629
  • 1,111
  • Is Cuda or OpenCL available from within Silverlight? – AnthonyWJones Apr 19 '10 at 11:52
  • @AnthonyWJones: I'm really not sure. – Jerry Coffin Apr 19 '10 at 14:53
  • 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 Jul 01 '10 at 07:24
0

Hmm its a good question.

Anything that 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.

3Dave
  • 28,657
  • 18
  • 88
  • 151
AnthonyWJones
  • 187,081
  • 35
  • 232
  • 306