本文介绍了如何从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的底部和顶部切割/隐藏投影区域-openTK的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!