Learn rendermonkey (5) Step by Step-render to texture (RTT)

Source: Internet
Author: User

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:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.