Original Post
I'm doing rendering to texture in shaders to store positions of particles. I'm trying to create a DX version of Lutz Latta's "Building a million particle system". I've managed to to simple rendering of my billboards, but when I try to transfer my computed positions to my render target something goes wrong. I'm doing it like this (pseudo-code 'cause I don't have my project here): In cpp: In the shader: The values are correct in the first vertex shader pass, but they don't seem to be stored correctly when rendering them to the next texture. I'm drawing a quad to get the DrawPrimitive going. Is there anything I should think of when rendering to a texture? Size of texture? Format? Thanks in advance for help :)
// Create a render target texture of same width and height as the texture I'm
// getting old values from
CreateTexture(width, height, 1, D3DUSAGE_RENDERTARGET, FMT_A32R32G32B32,...)
// Store original render target (backbuffer)
// Get the surface of my texture
// Set surface as render target
// DrawPrimitive()...
// Set back buffer to render target
// Store position values in a another texture
// Get values in vertex shader
float4 pos = tex2Dlod(PositionMap, uvVertex);
float4 vel = tex2Dlod(VelocityMap, uvVertex);
pos += vel;
return pos;
// This position value should now be rendered to my render target texture