I want to save the final rendering of my shadowed scene to a texture (see below). I would like to know how to render to an 800x600 texture directly in the shader. I am using the FX Composer from NVIDIA. I would've thought I could simply add the following as the final pass of the shader:
pass Bg <
string Script = "RenderColorTarget0=TexFinal;"
"RenderDepthStencilTarget=TexFinalDepthMap;"
"RenderPort=;"
"ClearSetColor=ClearColor;"
"ClearSetDepth=ClearDepth;"
"Clear=Color;"
"Clear=Depth;"
"Draw=buffer;";
> {
VertexShader = compile vs_1_1 ScreenQuadVS();
AlphaBlendEnable = false;
ZEnable = false;
PixelShader = compile ps_1_1 TexQuadPS(BgSampler);
}
both the ScreenQuadVS and TexQuadPS shaders can be found in the HLSL folder of the FX composer. Please let me know if you'd like me to include more code.
the final rendering with shadow information (i want to save this to a 800x600) texture :
http://i17.photobucket.com/albums/b95/julesthe/shadow_.jpg
FX Composer textures .. the one on the left is the shadow map .. the one on the right is supposed to be my 800x600 final rendered scene texture:
http://i17.photobucket.com/albums/b95/julesthe/textures_.jpg

Render final scene to Texture in Shader [FX Composer]
chenzhu
In this case your script part in the pass token seams right. Have you add the texture to your fx file It has to look similar like this:
string ResourceType = "2D";float3 Dimensions = float3( 800, 600, 0 );Saric Sead
Ralf .. had to go to bed last night .. it was late.
Anyway .. I attached 2 more images:
rendered with shadows:
http://i17.photobucket.com/albums/b95/julesthe/green_pre_alpha.jpg
shadows alpha-blend with background attempt:
http://i17.photobucket.com/albums/b95/julesthe/green.jpg
in the 3rd pass of my shader, I am trying to blend the results of the scene render (w/ shadows) with the background image (big green background). I simply wanted the block to "show through" everywhere it was white, and blend slightly darker where it appears gray. Any thoughts as to how I would accomplish proper blending (essentially I need to figure out how to NOT show the white part of the geometry in the scene and simply blend the gray part)
Here is the shader I use:
// this pass renders the background
pass Bg <
string Script = "RenderColorTarget0=;"
"ClearSetColor=ClearColor;"
"Clear=Color;"
"Draw=buffer;";
> {
VertexShader = compile vs_1_1 ScreenQuadVS();
AlphaBlendEnable = false;
ZEnable = false;
PixelShader = compile ps_1_1 TexQuadPS(BgSampler);
}
// this pass makes the shadow map
// finally blend the shadow and backgroundpass MakeShadow <
string Script = "RenderColorTarget0=ColorShadMap;"
"RenderDepthStencilTarget=ShadDepthTarget;"
"RenderPort=light0;"
"ClearSetColor=ShadowClearColor;"
"ClearSetDepth=ClearDepth;"
"Clear=Color;"
"Clear=Depth;"
"Draw=geometry;";
> {
VertexShader = compile vs_2_0 shadowGenVS(WorldXf,WorldITXf,ShadowViewProjXf);
ZEnable = true;
ZWriteEnable = true;
ZFunc = LessEqual;
CullMode = None;
// no pixel shader
}
pass UseShadow <
string Script = "RenderColorTarget0=;"
"RenderDepthStencilTarget=;"
"RenderPort=;"
//"ClearSetColor=ClearColor;"
"ClearSetDepth=ClearDepth;"
//"Clear=Color;"
"Clear=Depth;"
"Draw=geometry;";
> {
VertexShader = compile vs_2_0 shadowUseVS(WorldXf,WorldITXf, WorldViewProjXf,
ShadowViewProjXf,ViewIXf,ShadBiasXf, SpotLightPos);
// blending here
AlphaBlendEnable = true;
SrcBlend =srcalpha;
DestBlend =invsrcColor;
ZEnable = true;
ZWriteEnable = true;
ZFunc = LessEqual;
CullMode = None;
PixelShader = compile ps_2_a useShadowPS();
}
vlad b
Min Wang
feel free to delete this post.
I managed to get it working .. I need to disable the alpha blending in the 3rd pass. It was the pixel shader in that pass that needed fixing.
lbGURU
Only to make sure I understand you right. You want to render this in a texture inside your own program and not inside FX Composer After this you need this texture for an other effect