GLSL Shader to convert six textures to Equirectangular projection

倖福魔咒の 提交于 2019-12-04 20:42:46

Step 1: Copy your six textures into a cube map texture. You can do this by binding the textures to FBOs and using glBlitFramebuffer().

Step 2: Run the following fragment shader. You will need to vary the Coord attribute from (-1,-1) to (+1,+1) over the quad.

#version 330
// X from -1..+1, Y from -1..+1
in vec2 Coord;
out vec4 Color;
uniform samplercube Texture;

void main() {
    // Convert to (lat, lon) angle
    vec2 a = Coord * vec2(3.14159265, 1.57079633);
    // Convert to cartesian coordinates
    vec2 c = cos(a), s = sin(a);
    Color = sampler(Texture, vec3(vec2(s.x, c.x) * c.y, s.y));
}
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!