Jump to content

  • Log In with Google      Sign In   
  • Create Account


Loop through an ID3D11Texture2D object


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
2 replies to this topic

#1 iedoc   Members   -  Reputation: 663

Like
0Likes
Like

Posted 26 February 2012 - 09:10 AM

I would like to know how to iterate through the texels of an ID3D11Texture2D object, so i can do an operation that replaces certain texels with that of another ID3D11Texture2D object.

What i'm really looking for is how to set every other pixel on the screen to one texture, and all the other pixels to the other texture. I thought the pixel shader would be a great place to do this, by setting every other pixel's alpha value to 0 from the first render target, and in the second render target set the other pixels alpha's to 0. but as far as i know you can't find the current pixel the pixel shader is working on, and you can't share data between iterations. I'm not looking for blending though, because i don't want the pixels to "bleed" onto the surrounding pixels.
Braynzar Soft - DirectX Lessons & Game Programming Resources!

Sponsor:

#2 MJP   Moderators   -  Reputation: 10226

Like
1Likes
Like

Posted 26 February 2012 - 08:09 PM

I'm a little confused on what your intended result should be...so have texture A and texture B, and you want to fill texture A with an interleaved mix of texture A and texture B pixels? If that's the case that should be really easy...just bind texture A as the render target, use SV_Position to get the pixel position being shaded, and based on that position you can conditionally call discard to not write to that pixel (or you can use an alpha value of 0, and enable alpha blending). Then if you don't discard, you can just sample the corresponding texel from texture B and output that value. Or if you wanted the result in texture C, you could just just sample both and pick which sample you want to use based on the pixel position.

#3 iedoc   Members   -  Reputation: 663

Like
0Likes
Like

Posted 26 February 2012 - 10:06 PM

That's exactly what i was looking for, thanks mjp. I had looked for a really long time but couldn't find how to get the pixel position (I didn't know SV_Position could be used in the pixel shader, I just thought that was only used to send the vertex position from the vs to the rs, but now that i'm thinking about it, I have come across using SV_Position in the pixel shader! just needed a refresher i suppose, haha). I know the operation i want to do is real simple, i just didn't know how to actually find the pixel position (i'm really not good with hlsl). thanks again
Braynzar Soft - DirectX Lessons & Game Programming Resources!




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