its simple, but i am not secure if my code is correct, this is what i have made.
the texture will be used on this way: each pixel is a vector.
What i need is a:
new Texture------the main thing
ShaderResouceView with an effectShaderResourceVariable---- to read it
RenderTargetView-------- to write to it
This are the variables used:
ID3D10Texture2D* VectorsBuffer;
ID3D10ShaderResourceView* g_pTexture2 = NULL;
ID3D10EffectShaderResourceVariable* g_pTx2 = NULL;
ID3D10RenderTargetView* g_pRenderTargetView2 = NULL;
Why don't you just run the code with a directx debug device?
If something is wrong dx will most likely print error messages to the console explaining to you what you're doing wrong.
questions!
Can i put a texture in a hlsl texture variable to read it and put it in the render target of that same hlsl code at the same time?
I have already a texture in an hlsl variable now how do i get a pixel of that texture and put it in a float3 if the resolution of the texture is 800X600? or whatever resolution.
please answer
for the second question can i do this inside the pixel shader method?
my texture is only RGB
[color=#000000]uint3 sampleCoord [color=#666600]=[color=#000000] uint3[color=#666600]([color=#000000]x[color=#666600],[color=#000000] y[color=#666600],[color=#000000] mipLevel[color=#666600]);
[color=#000000] float3 sample [color=#666600]=[color=#000000] texture[color=#666600].[color=#660066]Load[color=#666600]([color=#000000]sampleCoord[color=#666600]);
I have already a texture in an hlsl variable now how do i get a pixel of that texture and put it in a float3 if the resolution of the texture is 800X600? or whatever resolution.[/quote]
[/font]
What are you trying to do? That sounds like standard texture sampling to me.
Define a sampler state and use texture.sample() in dx10/dx11 or tex2d() in dx9.
There are other methods to get get pixels from specific mip levels or directly read specific samples from multisampled textures. http://msdn.microsoft.com/en-us/library/windows/desktop/bb509700(v=vs.85).aspx
i am using the texture as a place to put vectors where each pixel is a 3D vector, so then i want to make calculations with the vectors i have,
HOW DO I GET A PIXEL? i have the
Texture2D Vectors;
then inside the pixel shader metod i put this code to GET A PIXEL, can i?(this is my first question now)
[color=#000000]uint3 sampleCoord [color=#666600]=[color=#000000] uint3[color=#666600]([color=#000000]x[color=#666600],[color=#000000] y[color=#666600],[color=#000000] 1[color=#666600]);
[color=#000000]float3 sample [color=#666600]=[color=#000000] Vectors[color=#666600].[color=#660066]Load[color=#666600]([color=#000000]sampleCoord[color=#666600]);
so "sample" is the pixel at the (x, y) coordinate(is it?)
If that's true then i can continue and now i wanna modify the vectors depending on the calculations, how do i do that? writing them to another texture, yeah a render target texture.
Now in the .fx file what's the code to write a vector that is float3([color=#000000]float3 sample) into a pixel of the render target texture? the return value of the pixel shader method is the one that will be in a pixel of the render target texture, isnt it? then if for example my (Texture2D Vectors;) has only 3 pixels then, how do i run across those 3 pixels so i modify the 3 pixels? thats my second question because i am stuck there, the pixel shader method runs when.....?
A common way to modify texture data is to just run a fullscreen pass. (render a screenspace quad covering the whole screen)
This way every iteration of the pixelshader will match 1 pixel from the texture.
You can use texture coordinates from the fullscreen quad to sample the texture.
You'll have to bind another texture with the same dimensions to write to, as you cannot write to the texture you're currently reading.
You write to it by returning a value from the pixel shader.
If you need to perform multiple operations on the texture, you can ping pong between 2 textures of the same dimension.