How to run C++ code on the GPU?
Hello, I would like to generate procedural textures using RenderTargets. I could always do it on the CPU (at least that's where I suppose the BeginDrawCanvasToRenderTarget method is executed), but I wonder if there is a faster way to do it? Can I draw on RenderTargets from the GPU? Or using compute shaders? I know I'm shooting in the dark here, but I'm hoping you guy can give me some ideas where to aim.
Thank you :)
asked Nov 26 '18 at 12:08 AM in C++ Programming
I must admit I haven't used RenderTargets yet, but here's some general knowledge on procedural textures :) You can create procedural texture in materials. The speed will probably depend on how you are using it. If you are generating texture on CPU and then sending it to GPU to use it in material than it would be faster to generate it on GPU obviously :)
Getting generated texture from GPU to CPU is always a pain so you might need to consider if that's worth your time.
Texture generated on GPU is a bit different than in CPU in my experience. Consider GPU is a highly paralleled environment you are not really creating a texture as a 2D array, but rather computing what value should given pixel/vertex have. This saves up some storage time, allows you to sample procedural texture in parallel and use it right away in the material.
If you want to use it outside of GPU, you might be able to code it into PostProcess material probably, but it will still not might be worth it.
Hope it helps.
Follow this question
Once you sign in you will be able to subscribe for any updates here