0
\$\begingroup\$

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.

\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

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.

\$\endgroup\$
4
  • \$\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, 2013 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\$ Jul 6, 2013 at 20:05
  • \$\begingroup\$ Ok well with a 2d texture then? \$\endgroup\$
    – Levi H
    Jul 7, 2013 at 19:47
  • \$\begingroup\$ @jacker For a 2D texture it's like I said in the answer...is there something you need clarification on? \$\endgroup\$ Jul 8, 2013 at 1:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .