zoukankan      html  css  js  c++  java
  • 一步一步学RenderMonkey(5)--渲染到纹理(RTT) 【转】

    转载请注明出处:  http://blog.csdn.net/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. }  

    运行效果如下:

     

  • 相关阅读:
    吃货联盟项目
    字串符笔记
    带有参的方法
    js:自动亮起100盏灯
    JS字面量创建方式的优缺点
    为什么说对象字面量赋值比new Object()高效?
    javascript 字面量
    vue学习(一)、Vue.js简介
    Redis(二):c#连接Redis
    Redis(一):centos下安装。
  • 原文地址:https://www.cnblogs.com/mazhenyu/p/6676713.html
Copyright © 2011-2022 走看看