【发布时间】:2019-07-03 09:10:43
【问题描述】:
在this 链接的帮助下,我可以在我的纹理上应用投影。 现在我想从我的 glcontrol 的顶部和底部剪切/删除相等的区域,然后需要在剩余区域上应用相同的投影。我已经尝试过如下。但如图所示,投影时缺少顶部和底部曲线。 我怎样才能把它带回保留区?
precision highp float;
uniform sampler2D sTexture;
varying vec2 vTexCoord;
void main()
{
float img_h_px = 432.0; // height of the image in pixel
float area_h_px = 39.0; // area height in pixel
float w = area_h_px/img_h_px;
if (vTexCoord.y < w || vTexCoord.y > (1.0-w)){
gl_FragColor= vec4(1.0,0.0,1.0,1.0);
}
else
{
vec2 pos = vTexCoord.xy * 2.0 - 1.0;
float b = 0.5;
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 );
}
}
【问题讨论】:
标签: c# opengl glsl opentk coordinate-transformation