将地球的卫星照片转换为球体上的纹理贴图 (OpenGL ES) [英] Convert satellite photos of Earth into texture maps on a sphere (OpenGL ES)

查看:46
本文介绍了将地球的卫星照片转换为球体上的纹理贴图 (OpenGL ES)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有 5 颗地球静止卫星,它们分布在赤道周围(不是等距,但几乎是)每天拍摄地球照片.每张照片的输出都是——惊喜!- 从远处拍摄的球体照片.

We have 5 geo-stationary satellites, spaced around the equator (not equally spaced, but almost) taking photos of Earth every day. The output of each photo is - surprise! - a photo of a sphere, taken from a long distance away.

我需要将这些照片重新组合成一个纹理贴图球体,但我不确定如何最好地做到这一点.关键问题:

I need to reassemble those photos into a single texture-mapped sphere, and I'm not sure how best to do this. Key problems:

  1. 这些照片 - 显然 - 离中心越远,就会严重扭曲,因为它们正在看球体
  2. 在一天中的不同时间拍摄了成百上千的组",每组 5 张照片.任何解决方案都必须是程序化的——我不能只是手工完成:(
  3. 输出平台是 iPad3:Open GL ES 2,纹理高达 4096x4096 - 但不如桌面 GPU 强大.我不太擅长着色器(尽管我已经完成了很多 OpenGL 预着色器)
  4. 照片本身是高分辨率的,我不确定是否可以同时加载所有 5 个纹理.我还为行星表面加载了非常高分辨率的纹理(在卫星照片下方).

我已经得到了:映射到球体上的单个矩形纹理(我的球体是包裹在球体中的标准网格,顶点均匀分布在表面上),所以......我尝试将球体的 5 张照片转换为一个单一的矩形地图(但到目前为止没有成功;虽然有人指出我在做一个极地罪经",看起来它可能会更好).

I've already got: a single rectangular texture mapped onto a sphere (my sphere is a standard mesh wrapped into a sphere, with vertices distributed evenly across the surface), so ... I tried converting 5 photos of spheres into a single rectangular map (but no success so far; although someone pointed me at doing a "polar sin warp" which looks like it might work better).

我还想过用 5 张照片制作立方体贴图来做一些时髦的事情,并聪明地决定为给定像素读取哪些照片,但我并不完全相信.

I've also thought of doing something funky with making a cube-map out of the 5 photos, and being clever about deciding which of the photos to read for a given pixel, but I'm not entirely convinced.

有没有更好的办法?我忽略了什么?或者有没有人有实现上述目标的具体方法?

Is there a better way? Something I've overlooked? Or has anyone got a concrete way of achieving the above?

推荐答案

我会用它做一个矩形纹理.

I would do a rectangular texture from it.

您将需要 2 个 2D 纹理/数组,一个用于 r,g,b 颜色求和 avg,一个用于计数 cnt.此外,我不相信我会使用 OpenGL/GLSL,因为在我看来 C/C++ 会更好.

You will need 2 x 2D textures/arrays one for r,g,b color summation avg and one for count cnt. Also I am not convinced that I would use OpenGL/GLSL for that it seems to me that C/C++ will be better for this.

我会这样做:

  1. 消隐目标纹理 (avg[][]=0, cnt[][]=0)
  2. 获取卫星位置/方向、时间

从位置和方向创建变换矩阵,以与照片相同的方式投射地球.然后从时间确定轮换.

from position and direction create transformation matrix which projects Earth the same ways as on photo. Then from time determine rotation shift.

循环遍历整个地球表面

只有两个嵌套循环 a - 旋转和 `b - 与赤道的距离.

just two nested loops a - rotation and `b - distance from equator.

a,b 得到 x,y,z 并变换矩阵 + 旋转位移(a-axis)

get x,y,z from a,b and transform matrix + rotation shift (a-axis)

也可以向后进行 a,b,z = f(x,y) 但它更棘手但更快更准确.您还可以在相邻的 (pixels/areas)[a][b]

also can do it backwards a,b,z = f(x,y) but it is more tricky but faster and more accurate. You can also interpolate x,y,z between neighboring (pixels/areas)[a][b]

添加像素

如果 x,y,z 在正面(z>0z<0 取决于相机 Z 方向)然后

if x,y,z is on the front side (z>0 or z<0 depends on the camera Z direction) then

avg[a][b]+=image[x][y]; cnt[a][b]++;

  • 从第 3 点开始的嵌套循环结束.

    循环遍历整个avg纹理以恢复平均颜色

    do loop through entire avg texture to restore average color

    if (cnt[a][b]) avg[a][b]/=cnt[a][b];
    

  • [注释]

    1. 可以测试复制的像素是否为:

    在白天或晚上获得(仅使用您想要的东西,不要将两者混合在一起!!!)也可以确定云(我认为灰色/白色不是雪)并忽略它们.

    Obtained during day or night (use only what you want and not mix both together!!!) also can determine clouds (i think gray/white-ish colors not snow) and ignore them.

    颜色不要溢出

    可以使用 3 个单独的纹理 r[][],g[][],b[][] 代替 avg 来避免这种情况

    can use 3 separate textures r[][],g[][],b[][] instead avg to avoid that

    可以忽略靠近地球边缘的区域以避免扭曲

    可以应用光照校正

    时间a,b坐标来归一化光照

    希望能帮到你……

    [Edit1] 正交投影

    所以这里很清楚我所说的正交投影是什么意思:

    so its clear here is what I mean by orthogonal projection:

    这是使用纹理(在网络上找不到更适合和免费的东西)并且想要使用真实的卫星图像而不是一些渲染......

    this is used texture (cant find nothing better suited and free on the web) and wanted to use real satellite image not some rendered ...

    这是我的正交投影应用

    • 红绿蓝线是地球坐标系(x,y,z轴)
    • (红、绿、蓝)-白线是卫星投影坐标系(x,y,z 轴)

    重点是将地球顶点坐标 (vx,vy,vz) 转换为卫星坐标 (x,y,z) 如果 z >= 0 那么它是处理纹理的有效顶点,所以直接从 x,y 计算纹理坐标,没有任何透视(正交).

    the point is to to convert earth vertex coordinates (vx,vy,vz) to satellite coordinates (x,y,z) if z >= 0 then its the valid vertex for processed texture so compute texture coordinates directly from x,y without any perspective (orthogonally).

    例如 tx=0.5*(+x+1); ... 如果 x 被缩放为 <-1,+1> 和可用的纹理是 tx <0,1> y 轴也是如此:ty=0.5*(-y+1); ... 如果 y 被缩放为 <-1,+1> 并且可用的纹理是 ty <0,1>> (我的相机具有相对于纹理矩阵的倒置 y 坐标系,因此 y 轴上的倒置符号)

    for example tx=0.5*(+x+1); ... if x was scaled to <-1,+1> and usable texture is tx <0,1> The same goes for y axis: ty=0.5*(-y+1); ... if y was scaled to <-1,+1> and usable texture is ty <0,1> (my camera has inverted y coordinate system respective to texture matrix therefore the inverted sign on y axis)

    如果 z <0 那么你正在处理超出纹理范围的顶点,所以忽略它......正如您在图像上看到的,纹理的外边界是扭曲的,因此您应该只使用内部(例如地球图像区域的 70%),您也可以根据与纹理中点的距离进行某种纹理坐标校正.完成此操作后,只需将所有卫星图像投影合并为一张图像即可.

    if the z < 0 then you are processing vertex out of texture range so ignore it ... as you can see on the image the outer boundaries of texture are distorted so you should use only the inside (for example 70% of earth image area) also you can do some kind of texture coordinates correction dependent on the distance from texture middle point. When you have this done then just merge all satellite image projection to one image and that is all.

    [Edit2] 好吧,我玩了一下,发现了这一点:

    Well I played with it a little and found out this:

    • 反向投影校正根本不适用于我的纹理,我认为这可能是经过后期处理的图像......
    • 基于中点距离的校正似乎不错,但使用的比例系数很奇怪不知道为什么在应该是 4 时乘以 6 我认为......

    • reverse projection correction do not work for my texture at all I think that is possible it is post processed image ...
    • middle point distance based correction seems be nice but the scale coefficient used is odd have no clue why to multiply by 6 when it should be 4 I think ...

    tx=0.5*(+(asin(x)*6.0/M_PI)+1); 
    ty=0.5*(-(asin(y)*6.0/M_PI)+1); 
    

    • 修正非线性投影(通过 asin)

    • 修正非线性投影边缘缩放
    • 失真比没有asin纹理坐标校正的情况要小得多
    • corrected nonlinear projection edge zoom
    • distortions are much much smaller then without asin texture coordinate corrections

    这篇关于将地球的卫星照片转换为球体上的纹理贴图 (OpenGL ES)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆