Skip to main content
deleted 37 characters in body
Source Link

This question and its answer, actually answer my question. I had to read its answer carefully and find my mistake.

Now my fragment shader look like this:

const GLchar* fragmentSource = R"glsl(
    #version 330 core

    in vec2 TexCoord;

    uniform sampler2D ourTexture;

    #define PI       3.141592653589793238462f
    #define TWO_PI   6.283185307179586476924f
    #define PI4      0.7853981633974483096155f

    void main(){
        if(TexCoord.y > 0){
            float lat = (TexCoord.y - 0.5f) * PI;
            if(lat >= -1.48442222974871 && lat <= 1.48442222974871){
                float y = log(tan(PI4 + (lat / 2.0)));
                y = (y + PI) / TWO_PI;
                gl_FragColor = texture(ourTexture, vec2(TexCoord.x, y));
                return;
            }
        }
        gl_FragColor = vec4(1, 1, 1, 0);
    }
)glsl";

And it's works perfectly.

This question and its answer, actually answer my question. I had to read its answer carefully and find my mistake.

Now my fragment shader look like this:

const GLchar* fragmentSource = R"glsl(
    #version 330 core

    in vec2 TexCoord;

    uniform sampler2D ourTexture;

    #define PI       3.141592653589793238462f
    #define TWO_PI   6.283185307179586476924f
    #define PI4      0.7853981633974483096155f

    void main(){
        if(TexCoord.y > 0){
            float lat = (TexCoord.y - 0.5f) * PI;
            if(lat >= -1.48442222974871 && lat <= 1.48442222974871){
                float y = log(tan(PI4 + (lat / 2.0)));
                y = (y + PI) / TWO_PI;
                gl_FragColor = texture(ourTexture, vec2(TexCoord.x, y));
                return;
            }
        }
        gl_FragColor = vec4(1, 1, 1, 0);
    }
)glsl";

And it's works perfectly.

This question and its answer, actually answer my question. I had to read its answer carefully and find my mistake.

Now my fragment shader look like this:

const GLchar* fragmentSource = R"glsl(
    #version 330 core

    in vec2 TexCoord;

    uniform sampler2D ourTexture;

    #define PI       3.141592653589793238462f
    #define TWO_PI   6.283185307179586476924f
    #define PI4      0.7853981633974483096155f

    void main(){
        float lat = (TexCoord.y - 0.5f) * PI;
        if(lat >= -1.48442222974871 && lat <= 1.48442222974871){
            float y = log(tan(PI4 + (lat / 2.0)));
            y = (y + PI) / TWO_PI;
            gl_FragColor = texture(ourTexture, vec2(TexCoord.x, y));
            return;
        }
        gl_FragColor = vec4(1, 1, 1, 0);
    }
)glsl";

And it's works perfectly.

Source Link

This question and its answer, actually answer my question. I had to read its answer carefully and find my mistake.

Now my fragment shader look like this:

const GLchar* fragmentSource = R"glsl(
    #version 330 core

    in vec2 TexCoord;

    uniform sampler2D ourTexture;

    #define PI       3.141592653589793238462f
    #define TWO_PI   6.283185307179586476924f
    #define PI4      0.7853981633974483096155f

    void main(){
        if(TexCoord.y > 0){
            float lat = (TexCoord.y - 0.5f) * PI;
            if(lat >= -1.48442222974871 && lat <= 1.48442222974871){
                float y = log(tan(PI4 + (lat / 2.0)));
                y = (y + PI) / TWO_PI;
                gl_FragColor = texture(ourTexture, vec2(TexCoord.x, y));
                return;
            }
        }
        gl_FragColor = vec4(1, 1, 1, 0);
    }
)glsl";

And it's works perfectly.