Get and Set pixel colors from ID3D11Texture2D

Started by
3 comments, last by Visje 11 years, 7 months ago
Hey guys, I'm trying to do a water like effect like this one :

(Processing uses a Java-Like langage)
http://www.openproce...rg/sketch/43543

The thing is that it works by replacing the color of one pixel from the texture on the back by another one when the pointer of the mouse is moved.

So my question is, do you know how I can get all the pixels from a texture and change their colors as I like (and not just a single pixel like in the Pixel Shader) ?

I have initialized and displayed a "ID3D11Texture2D", so I'm wondering if I can get the pixels from this texture...

Thanks smile.png
Advertisement
You can use UpdateSubresource to update a texture. You can use CopySubresource to copy the texture to another texture created with staging usage and CPU read access, which you can Map and obtain a pointer to when you want to read pixels back.

I guess for that you don't want to read pixels back though.. but do the water simulation in a shader and just tell it where the cursor is.. You can read multiple pixels in the pixel shader if you want to.
Thanks Erik, I just came across this topic where I found what I was looking for.

I'm just trying now to convert Byte into UINT32, if you have an idea on how to do it ?
If you have 4 bytes you can get the uint32 by byte[0] | (byte[1] << 8) | (byte[2] << 16) | (byte[3] << 24) (or the other way around, depending on byte order, where byte[0] is shifted 24 etc.
Okay thanks :) this is working

This topic is closed to new replies.

Advertisement