RenderMonkey 练习 第三天 【OpenGL renderToTexture】
渲染到纹理:
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 );
最新文章
- MetInfo 5.1 自动化getshell工具
- Java EE开发平台随手记3——Mybatis扩展2
- MetadataType来帮助entity framework自动生成的代码进行标注
- CMS 垃圾回收日志
- 虚拟机移动后重启网络时提示Device does not seem to be present
- bzoj3208
- ASP.NET-FineUI开发实践-17
- Oracle EBS-SQL (BOM-3):检查期间新增Bom数量.sql
- uvalive5818 uva12376 As Long as I Learn, I Live
- 修改项目工程名 iOS
- Mercurial简介
- assign retain copy
- Viewpager以及ViewPagerIndicator的相关使用
- 关于jmeter工具使用的总结
- Chatbot思考录
- Vue + webpack 项目实践
- (办公)eclipse连接github cannot open git-upload-pack(git-receive-pack)
- freeswitch源码安装
- table tr 加入背景色之后 去掉td之间的空隙
- vsftpd只能连接不能上传文件问题
热门文章
- 深入解析当下大热的前后端分离组件django-rest_framework系列二
- aliyun服务器ubuntu系统+MySQL+SqlDeveloper
- 关于rem的一点总结【原创】
- 64位直接加载个img 标签的src
- Simditor学习--vuejs集成simditor
- Java Control Statements
- jquery canvas 用户点击记录
- Codeforces 1082 A. Vasya and Book-题意 (Educational Codeforces Round 55 (Rated for Div. 2))
- ORACLE数据库创建动态表
- CodeForces 740D Alyona and a tree