一步一步学RenderMonkey(5)--渲染到纹理(RTT)

转载请注明出处:  http://blog.youkuaiyun.com/tianhai110

 

渲染到纹理:

1.      新建一个空effect;

2.      添加渲染目标纹理, Add Texture-> Add Render Texture

3.      添加一个渲染pass

4.      将pass0 渲染到纹理上,   add Render Target->renderTexture;

5.      在pass1中,引用纹理 Add Texture Object->renderTexture;   并改名为rttTexture;

6.       修改pass1的vertex shader 和pixel shader;

[c-sharp]  view plain copy
  1. float4x4 matViewProjection;  
  2.   
  3. struct VS_INPUT   
  4. {  
  5.    float4 Position : POSITION0;  
  6.    float2 Texcoord : TEXCOORD0;  
  7. };  
  8.   
  9. struct VS_OUTPUT   
  10. {  
  11.    float4 Position : POSITION0;  
  12.    float2 Texcoord : TEXCOORD0;  
  13. };  
  14.   
  15. VS_OUTPUT vs_main( VS_INPUT Input )  
  16. {  
  17.    VS_OUTPUT Output;  
  18.   
  19.    Output.Position = mul( Input.Position, matViewProjection );  
  20.    Output.Texcoord = Input.Texcoord;  
  21.      
  22.    return( Output );  
  23.      
  24. }  

PS:

[c-sharp]  view plain copy
  1. sampler2D rttTexture;  
  2. float4 ps_main( float2 tex:TEXCOORD0) : COLOR0  
  3. {     
  4.    return tex2D(rttTexture, tex) + float4( 0.6, 0.2, 0.5, 1);  
  5.      
  6. }  

 

运行效果如下:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值