基于Qt的OpenGL可编程管线学习(18)-平滑、锐化、边缘检测-创新互联
1、平滑

shader
// 平滑
uniform sampler2D U_MainTexture;
uniform sampler2D U_SubTexture;
varying vec2 M_coord;
void main()
{
vec4 color = vec4(0.0);
int coreSize = 3;
float texelOffset = 1 / 300.0;
float kernel[9];
kernel[6] = 1; kernel[7] = 1; kernel[8] = 1;
kernel[3] = 1; kernel[4] = 1; kernel[5] = 1;
kernel[0] = 1; kernel[1] = 1; kernel[2] = 1;
int index = 0;
for(int y = 0; y效果图

2、锐化
shader
// 锐化
uniform sampler2D U_MainTexture;
uniform sampler2D U_SubTexture;
varying vec2 M_coord;
void main()
{
vec4 color = vec4(0.0);
int coreSize = 3;
float texelOffset = 1 / 300.0;
float kernel[9];
kernel[6] = 0; kernel[7] = -1; kernel[8] = 0;
kernel[3] = -1; kernel[4] = 4; kernel[5] = -1;
kernel[0] = 0; kernel[1] = -1; kernel[2] = 0;
int index = 0;
for(int y = 0; y效果图

3、边缘检测
shader
// 边缘检测
uniform sampler2D U_MainTexture;
uniform sampler2D U_SubTexture;
varying vec2 M_coord;
void main()
{
vec4 color = vec4(0.0);
int coreSize = 3;
float texelOffset = 1 / 300.0;
float kernel[9];
kernel[6] = 0; kernel[7] = 1; kernel[8] = 0;
kernel[3] = 1; kernel[4] = -4; kernel[5] = 1;
kernel[0] = 0; kernel[1] = 1; kernel[2] = 0;
int index = 0;
for(int y = 0; y效果图

另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。
网页题目:基于Qt的OpenGL可编程管线学习(18)-平滑、锐化、边缘检测-创新互联
本文路径:http://www.jxjierui.cn/article/dhdehc.html


咨询
建站咨询
