0

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

Nicol Bolas
  • 449,505
  • 63
  • 781
  • 982
CrushedPixel
  • 1,152
  • 2
  • 13
  • 26
  • What exactly is the question? – derhass Jan 27 '16 at 22:31
  • I need to get some hints on how to take multiple textures and "move" their pixels onto the final texture by an algorithm – CrushedPixel Jan 27 '16 at 22:47
  • What is a "quadratic texture"? And what is a "cubic projection image"? – Nicol Bolas Jan 27 '16 at 23:10
  • @NicolBolas This is [Cubic Projection](http://wiki.panotools.org/Cubic_Projection), and by "quadratic textures" I just meant textures with the same width and height. – CrushedPixel Jan 27 '16 at 23:11
  • not the same but similar question (different transformation) [Equirectangular to azimuthal equidistant projection in GLSL](http://stackoverflow.com/a/33015271/2521214) might help a bit. – Spektre Jan 28 '16 at 08:28

1 Answers1

5

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));
}
Dietrich Epp
  • 205,541
  • 37
  • 345
  • 415