Jump to content
  • Advertisement
Sign in to follow this  
Visje

Get and Set pixel colors from ID3D11Texture2D

This topic is 2098 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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 Edited by Visje

Share this post


Link to post
Share on other sites
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. Edited by Erik Rufelt

Share this post


Link to post
Share on other sites
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 ? Edited by Visje

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!