GLSL Shader to convert six textures to Equirectangular projection

有些话、适合烂在心里 提交于 2019-12-10 00:31:00

问题


I want to create an equirectangular projection from six quadratic textures, similar to converting a cubic projection image to an equirectangular image, but with the separate faces as textures instead of one texture in cubic projection.

I'd like to do this on the graphics card for performance reasons, and therefore want to use a GLSL Shader.

I've found a Shader that converts a cubic texture to an equirectangular one: link


回答1:


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));
}


来源:https://stackoverflow.com/questions/35048665/glsl-shader-to-convert-six-textures-to-equirectangular-projection

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!