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<coreSize; y++) { for(int x=0; x<coreSize; x++) { vec4 currentColor=texture2D(U_MainTexture, M_coord+vec2((-1+x)*texelOffset,(-1+y)*texelOffset)); color += currentColor * kernel[index++]; } } color /= 9.0; gl_FragColor = color; }
效果图
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<coreSize; y++) { for(int x=0; x<coreSize; x++) { vec4 currentColor=texture2D(U_MainTexture, M_coord+vec2((-1+x)*texelOffset,(-1+y)*texelOffset)); color += currentColor * kernel[index++]; } } //color /= 9.0; gl_FragColor = 4.0 * color + texture2D(U_MainTexture, M_coord); }
效果图
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<coreSize; y++) { for(int x=0; x<coreSize; x++) { vec4 currentColor=texture2D(U_MainTexture, M_coord+vec2((-1+x)*texelOffset,(-1+y)*texelOffset)); color += currentColor * kernel[index++]; } } //color /= 9.0; gl_FragColor = 4.0 * color + texture2D(U_MainTexture, M_coord); }
效果图
另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。
当前名称:基于Qt的OpenGL可编程管线学习(18)-平滑、锐化、边缘检测-创新互联
转载来于:https://www.cdcxhl.com/article42/dhdehc.html
成都网站建设公司_创新互联,为您提供品牌网站建设、商城网站、网站设计公司、品牌网站设计、营销型网站建设、建站公司
声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联