How can I access and change texture data in SlimDX? I have a Texture2D and a Texture3D and I need to be able to go in and change either a single or group of pixels.
If you need to update textures once in awhile (e.g. while loading a new level), you can do it with UpdateSubresource. However, beware that this can cause a CPU-GPU sync point, which will trash your performance if you're doing it every frame.
If you need to update textures in real-time, a better way is to bind it as a render target and draw on it with a shader that performs the required alterations.
-
\$\begingroup\$ What if I want to change just a single or few pixels in a 3D texture? What's the fastest way to go about that? \$\endgroup\$ – Levi H Jul 6 '13 at 19:39
-
\$\begingroup\$ @jacker I haven't worked with 3D textures much, but I think you have to update each depth slice separately, as a 2D texture. \$\endgroup\$ – Nathan Reed Jul 6 '13 at 20:05
-
-
\$\begingroup\$ @jacker For a 2D texture it's like I said in the answer...is there something you need clarification on? \$\endgroup\$ – Nathan Reed Jul 8 '13 at 1:38