Sign in to follow this  
Visje

Get and Set pixel colors from ID3D11Texture2D

Recommended Posts

Hey guys, I'm trying to do a water like effect like this one :

(Processing uses a Java-Like langage)
[url="http://www.openprocessing.org/sketch/43543"]http://www.openproce...rg/sketch/43543[/url]

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 [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img] Edited by Visje

Share this post


Link to post
Share on other sites
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 [url="http://www.gamedev.net/topic/583161-d3d11-creating-a-dynamic-texture/"]this[/url] 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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this