渲染到纹理:

1. 新建一个OpenGL 空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;

顶点shader:

varying vec3 vNormal;
varying vec2 texcoord;

void main(void)
{
   gl_Position = ftransform();
   vNormal = gl_NormalMatrix * gl_Normal;
   texcoord = gl_MultiTexCoord0.xy;   
}

片元shader:

varying vec3 vNormal;
varying vec2 texcoord;
uniform sampler2D rttTexture;

void main(void)
{

#if 0

// 法线参与颜色计算,改善输出颜色
   vec3 N = normalize( vNormal ) * 0.5 + 0.5;
   gl_FragColor = vec4( N * (texture2D( rttTexture, texcoord ).rgb * 0.5 + 0.5), 1.0 );

#else
   gl_FragColor = texture2D( rttTexture, texcoord ) + vec4(0.3,0.3,0.3,1.0);

#endif
}

7.效果图

使用法线参与颜色计算,改善输出颜色 的效果

vec3 N = normalize( vNormal ) * 0.5 + 0.5;
   gl_FragColor = vec4( N * (texture2D( rttTexture, texcoord ).rgb * 0.5 + 0.5), 1.0 );

最新文章

  1. MetInfo 5.1 自动化getshell工具
  2. Java EE开发平台随手记3——Mybatis扩展2
  3. MetadataType来帮助entity framework自动生成的代码进行标注
  4. CMS 垃圾回收日志
  5. 虚拟机移动后重启网络时提示Device does not seem to be present
  6. bzoj3208
  7. ASP.NET-FineUI开发实践-17
  8. Oracle EBS-SQL (BOM-3):检查期间新增Bom数量.sql
  9. uvalive5818 uva12376 As Long as I Learn, I Live
  10. 修改项目工程名 iOS
  11. Mercurial简介
  12. assign retain copy
  13. Viewpager以及ViewPagerIndicator的相关使用
  14. 关于jmeter工具使用的总结
  15. Chatbot思考录
  16. Vue + webpack 项目实践
  17. (办公)eclipse连接github cannot open git-upload-pack(git-receive-pack)
  18. freeswitch源码安装
  19. table tr 加入背景色之后 去掉td之间的空隙
  20. vsftpd只能连接不能上传文件问题

热门文章

  1. 深入解析当下大热的前后端分离组件django-rest_framework系列二
  2. aliyun服务器ubuntu系统+MySQL+SqlDeveloper
  3. 关于rem的一点总结【原创】
  4. 64位直接加载个img 标签的src
  5. Simditor学习--vuejs集成simditor
  6. Java Control Statements
  7. jquery canvas 用户点击记录
  8. Codeforces 1082 A. Vasya and Book-题意 (Educational Codeforces Round 55 (Rated for Div. 2))
  9. ORACLE数据库创建动态表
  10. CodeForces 740D Alyona and a tree