当前位置:网站首页>cocos2d-x-3.2 image graying effect
cocos2d-x-3.2 image graying effect
2022-07-31 06:01:00 【xuyid】
//dye grey
void GameTools::GrayShaderProgram(Node * node)
{
do{
const GLchar* pszFragSource =
"#ifdef GL_ES \n\
precision mediump float; \n\
#endif \n\
uniform sampler2D u_texture;\n\
varying vec2 v_texCoord; \n\
varying vec4 v_fragmentColor; \n\
void main(void) \n\
{ \n\
// Convert to greyscale usingNTSC weightings \n\
vec4 col = texture2D(u_texture, v_texCoord); \n\
float grey = dot(col.rgb, vec3(0.299, 0.587, 0.114)); \n\
gl_FragColor= vec4(grey, grey, grey, col.a); \n\
}";
GLProgram* pProgram = new GLProgram();
pProgram->initWithByteArrays(
ccPositionTextureColor_noMVP_vert
, pszFragSource);
node->setGLProgram(pProgram);
pProgram->release();
CHECK_GL_ERROR_DEBUG();
node->getGLProgram()->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION);
node->getGLProgram()->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_COLOR, GLProgram::VERTEX_ATTRIB_COLOR);
node->getGLProgram()->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_TEX_COORD, GLProgram::VERTEX_ATTRIB_TEX_COORD);
CHECK_GL_ERROR_DEBUG();
node->getGLProgram()->link();
CHECK_GL_ERROR_DEBUG();
node->getGLProgram()->updateUniforms();
CHECK_GL_ERROR_DEBUG();
} while (0);
}
边栏推荐
- Access database query
- js中的全局作用域与函数作用域
- flutter arr 依赖
- cocos2d-x-3.2创建项目方法
- Eternal blue bug reappears
- [Cloud native] Ribbon is no longer used at the bottom layer of OpenFeign starting from the 2020.0.X version
- 【云原生】SQL(及存储过程)跑得太慢怎么办?
- Gradle sync failed: Uninitialized object exists on backward branch 142
- cocos2d-x-3.x 修改和纪录
- quick-3.5 无法正常显示有混合纹理的csb文件
猜你喜欢

带你搞懂MySQL隔离级别,两个事务同时操作同一行数据会怎样?

Global scope and function scope in js

mysql password modification method in Linux (pro-test available)

What is the difference between NFT and digital collection?

Gradle sync failed: Uninitialized object exists on backward branch 142

通信原理——纠错编码 | 汉明码(海明码)手算详解

How MySQL - depots table?A look at will understand

Year-end summary - the years are quiet~

unicloud 云开发记录

GUCCI, LV and other luxury giant universe how to layout yuan, other brands should keep up with?
随机推荐
[Elastic-Job] Overview of Distributed Scheduling Tasks
Android software security and reverse analysis reading notes
Android软件安全与逆向分析阅读笔记
"limit" query in Oracle database
MySQL高级学习笔记
[Cloud Native] What should I do if SQL (and stored procedures) run too slowly?
SSH自动重连脚本
sqlmap injection tutorial common commands
Chinese garbled solution in UTF-8 environment in Powershell
ERROR Error: No module factory availabl at Object.PROJECT_CONFIG_JSON_NOT_VALID_OR_NOT_EXIST ‘Error
Tencent Cloud Lightweight Server deletes all firewall rules
unicloud 发布后小程序提示连接本地调试服务失败,请检查客户端是否和主机在同一局域网下
Getting to know regular expressions
ERROR Error: No module factory availabl at Object.PROJECT_CONFIG_JSON_NOT_VALID_OR_NOT_EXIST ‘Error
通信原理——纠错编码 | 汉明码(海明码)手算详解
quick-3.5 lua调用c++
js中的this指向与原型对象
VS2017 connects to MYSQL
quick-3.5 ActionTimeline的setLastFrameCallFunc调用会崩溃问题
this指向问题