PDA

View Full Version : Passing RenderTexture to Cg



rcpedersen
04-11-2005, 09:03 AM
Hi,

I am experiencing problems with passing a RenderTexture ( www.gpgpu.org/developer (http://www.gpgpu.org/developer) ) to a Cg shader in a consecutive render pass. The basics of my rendering is,


rt1->BeginCapture();
// render
rt1->EndCapture();

rt2->BeginCapture();
// Cg, see below
// render
rt2->EndCapture();

RenderFloatBuffer(&rt2);Sending the rt1 texture to Cg I do with the following calls


g_prtFrontfaces->Bind();
g_prtFrontfaces->EnableTextureTarget();
cgGLEnableProfile(g_cgProfileFP);
cgGLBindProgram(g_cgFragDirection);
cgGLSetTextureParameter(g_cgParmFrontfaces, g_prtFrontfaces->GetTextureID());
cgGLEnableTextureParameter(g_cgParmFrontfaces);My fragment shader is very trivial,



float4 raydirection( fragment_t fragment_s,
uniform sampler2D texture
) : COLOR0
{
float4 result;
float3 frontface;
float3 backface;
frontface = tex2D(texture, fragment_s.coordinate.xy).rgb;
//frontface.rgb = texRECT(texture, screen.xy);
backface.rgb = fragment_s.color.rgb;
//result.rgb = normalize(backface.rgb-frontface.rgb);
//result.a = length(backface.rgb-frontface.rgb);
result.rgb = frontface.rgb;
return result;
}I am capable of performing the following



rt1->BeginCapture();
// render
rt1->EndCapture();
RenderFloatBuffer(&rt1);But not transfering the rt1 to the next render pass and use it in a my Cg shader.

Any sugestions to what I might be doing wrong?