Reprinted please indicate the source: http://blog.csdn.net/tianhai110
Rendering to texture:
1. Create an empty effect;
2. Add the rendering target texture, add texture-> Add render texture
3. Add a rendering pass
4. Render pass0 to the texture and add render target-> rendertexture;
5. In pass1, reference the texture add texture object-> rendertexture; and rename it rtttexture;
6. Modify vertex shader and pixel shader of pass1;
Float4x4 matviewprojection; </P> <p> struct vs_input <br/>{< br/> float4 position: position0; <br/> float2 texcoord: texcoord0; <br/>}; </P> <p> struct vs_output <br/>{< br/> float4 position: position0; <br/> float2 texcoord: texcoord0; <br/>}; </P> <p> vs_output vs_main (vs_input input) <br/>{< br/> vs_output output; </P> <p> output. position = MUL (input. position, matviewprojection); <br/> output. texcoord = input. texcoord; </P> <p> return (output); </P> <p>}
PS:
Sampler2d rtttexture; <br/> float4 ps_main (float2 TEX: texcoord0): color0 <br/>{< br/> return tex2d (rtttexture, Tex) + float4 (0.6, 0.2, 0.5, 1); </P> <p>}
The running effect is as follows: