   How does RenderToTexture Works in DirectX10
  HI!i'm trying to make render to texture work fine in directx10, and SM4i would like to ask for some tutorial or a guide to code that. i need to control each value i put in each pixel. For example: pixel(512,512)=value ...is there a way to do that?thanks in advance!Lucas.   
  Do you wish to decide the pixels on the CPU in your normal program, and transfer the image to the GPU texture, or do you wish to actually render geometry with D3D10, with your texture as a render target?With the second option I mean that you can do d3d10Device->Draw() and the rendered scene gets stored in a texture.The first method is if you calculate an image or something in C++ and want to use it as a texture when rendering later.   ;  hi erik!i mean the second option, i want to use the shaders to work from a texture i have previously load and generate new textures in the gpu, to use later to render a scene. So, how to use and take control in each pixel i will write in the texture from the pixel shader.To give more presicion, i want to implement the clipmap technique to render terrain, and i will have a texture with the heightmap with very low detail, and i want to generate new textures (smallers, just what i need) with levels with more detail.thanks in advance, Lucas.   ;  First you should create a texture with ID3D10Device::CreateTexture2D, and then a render target view for it, with I3D10Device::CreateRenderTargetView. You might also need to create a depth-buffer, if you need one for your rendering.Then you activate this render target with ID3D10Device::OMSetRenderTargets, and draw as usual when you draw to the screen, and it will be drawn to the texture.It's basically just the same as rendering to the screen, you just use a different texture surface for the render target.   ;  ok, thanks, i have an idea of that, but i would like to know how i would write (code) the shaders, vertex and pixel, to control the value i put in each pixel. As each pixel of my target texture i want to put a height value, i ask how to do that.for example, in vertex or pixel shaders i want to sample some values of the "input" texture, make same interpolation, and write the result in an specific pixel in the output texture...did i explain better?thanks!Lucas.   ;  There are two directions to take, gather and scatter.The first is to render a quad covering the entire render target, and for each pixel determine the suitable source pixels that generate its colour.The second is to determine for each source pixel where to output it. This can be done using a vertex shader, and rendering points. The vertex shader samples the texture (for example based on SV_VertexID), and output the position to draw at and the colour. The pixel shader then writes that colour.   