Jump to content

  • Log In with Google      Sign In   
  • Create Account


Get and Set pixel colors from ID3D11Texture2D


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 Visje   Members   -  Reputation: 109

Like
0Likes
Like

Posted 18 September 2012 - 02:42 AM

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 Posted Image

Edited by Visje, 18 September 2012 - 02:44 AM.


Sponsor:

#2 Erik Rufelt   Crossbones+   -  Reputation: 3018

Like
1Likes
Like

Posted 18 September 2012 - 06:01 AM

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, 18 September 2012 - 06:05 AM.


#3 Visje   Members   -  Reputation: 109

Like
0Likes
Like

Posted 18 September 2012 - 06:52 AM

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, 18 September 2012 - 06:52 AM.


#4 Erik Rufelt   Crossbones+   -  Reputation: 3018

Like
1Likes
Like

Posted 18 September 2012 - 07:59 AM

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.

#5 Visje   Members   -  Reputation: 109

Like
0Likes
Like

Posted 18 September 2012 - 08:15 AM

Okay thanks :) this is working

Edited by Visje, 18 September 2012 - 08:37 AM.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS