如何从GLControl的底部和顶部切割/隐藏投影区域

编程入门 行业动态 更新时间:2024-10-09 13:30:00
本文介绍了如何从GLControl的底部和顶部切割/隐藏投影区域-openTK的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

借助此链接,我可以将图像投影为圆柱形状.是否可以删除或隐藏图像顶部和底部的投影区域,如下图所示?

With the help of this link, I can project an image in cylindrical shape. Can I able to remove or hide the projected area from top and bottom of image as shown in the image below?

推荐答案

您必须 discard 碎片取决于 u (.y)纹理坐标.

You have to discard fragmnts dependent on the u (.y) texture coordinate.

根据原始问题的片段着色器如何投影openGL控件的顶部和底部区域:

According to the fragment shader of the original question How to project top and bottom area of openGL control:

precision highp float; uniform sampler2D sTexture; varying vec2 vTexCoord; void main() { vec2 pos = vTexCoord.xy * 2.0 - 1.0; float b = 0.3; float v_scale = (1.0 + b) / (1.0 + b * sqrt(1.0 - pos.x*pos.x)); float u = asin( pos.x ) / 3.1415 + 0.5; float v = (pos.y * v_scale) * 0.5 + 0.5; if ( v < 0.0 || v > 1.0 ) discard; vec3 texColor = texture2D( u_texture, vec2(u, v) ).rgb; gl_FragColor = vec4( texColor.rgb, 1.0 ); }

大小必须由变量b限制:

if (abs(pos.y) * (1.0 + b) > 1.0) discard;

更多推荐

如何从GLControl的底部和顶部切割/隐藏投影区域

本文发布于:2023-05-28 00:46:06,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/308204.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:区域   GLControl

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!