   FBO: Render position into a color target
  Hello all~I ran into a problem about rendering position into a color texture.I've got stuck almost three days... :(My object is to render the clip coordinates into a color texture, and retrieve the world position in later render pass.I use Cg shader and OpenGL FBO...I bind an RGBA16 color texture to FBO, then execute the first Cg render pass:void GEN_SCENEPOS_VS(float3 Position : POSITION,    out float4 oPos : POSITION,   out float4 oClipPos : TEXCOORD0){oPos = mul( matWVP, float4(Position.xyz , 1.0));oClipPos = mul( matWVP, float4(Position.xyz , 1.0));}float4 GEN_SCENEPOS_PS(float4 Pos : TEXCOORD0) : COLOR{Pos /= Pos.w;// Convert the range of x,y from [-1,1] -> [0,1]Pos.xy = Pos.xy * 0.5f + 0.5f;return Pos;}Then, I draw a screen align QUAD, read the data from the texture, and transform data back to the world coordinate:vertexOutput QUAD_VS(vertexInput IN) {    vertexOutput OUT;    // Output the position directly    OUT.HPosition = float4(IN.Position.xyz, 1.0);    OUT.TexCoord = IN.UV;    return OUT;}float4 QUAD_FETCH_POS_PS(vertexOutput IN) : COLOR{float4 pos = tex2D(ScenePosSampler, IN.TexCoord.xy);// Convert the range from [0,1]->[-1,1]pos.xy = (pos.xy - 0.5f) * 2.0f;// Transform to viewpos = mul(ProjIXform, float4(pos.xyz, 1.0) );pos.xyz = pos.xyz / pos.www;pos.w = 1.0;// Transform to worldpos = mul(ViewIXform, float4(pos.xyz, 1.0));return pos;}I've refer to a related thread and followed the instructions there.However, the result I've got is really weird!When I move/rotate the camera, the rendering result always changes(It should not change, since it's the world positions of all objects in the scene!). If I put all my code into the first pass, I would get the correct result. Therefore, I think the matrix ProjIXform and ViewIXform would not cause this weird result. I've also tried to bind an GL_FLOAT_RGBA16_NV texture to FBO, but the rendering result is still wrong!!Please help me out! This problem almost drives me crazy... :(Thank you in advance, any idea is welcome!! Please give me a direction! Thank you! :)SincerelyRyan[Edited by - Ryan47 on September 17, 2007 4:51:39 AM]