Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Globe view as plane view. #84

Open
niravupxselling opened this issue Jun 30, 2023 · 2 comments
Open

Globe view as plane view. #84

niravupxselling opened this issue Jun 30, 2023 · 2 comments

Comments

@niravupxselling
Copy link

niravupxselling commented Jun 30, 2023

I want to show the plane map as a 2d view.

e.g. https://cybermap.kaspersky.com/

when We click on
image
/
image

(switch to plane view / switch to globe view)

same globe view as a plane view.

Is it possible for our globe?

@vasturiano
Copy link
Owner

@niravupxselling sorry this module only supports an orthographical projection of a planet as a sphere in the 3D space. It does not support any 2D projections such as Mercator, etc. For that purpose there are already many available libraries that can do that, so you should easily find one that fits your needs.

@pujunliang
Copy link

const vertexShader = `
attribute vec3 position2;
attribute vec3 normal2;
uniform float blend;
uniform float offset_x;
uniform float height;
attribute vec2 texcoord;

        varying vec3 v_normal;
        varying vec2 vUv;  // 用于传递纹理坐标
        varying vec3 v_light_vec;
        varying vec3 v_view_vec;
        
        uniform vec3 light_pos;
        uniform vec3 view_pos;

        void main() {
            vec3 P = mix(position, position2, blend);
            P.x += offset_x;

            v_normal = mix(normal, normal2, blend);
            P += height * v_normal;

            gl_Position = projectionMatrix * modelViewMatrix * vec4(P, 1.0);
            vUv = uv;  // 将纹理坐标传递给片元着色器
            v_light_vec = light_pos - P;
            v_view_vec = view_pos - P;
        }
        `;

    const fragmentShader = `
        uniform sampler2D t_blur;
        uniform float tone;
        uniform float alpha;
        uniform vec3 color0;
        uniform vec3 color1;
        uniform vec2 resolution;  // Declare the resolution uniform

        varying vec3 v_normal;
        varying vec3 v_light_vec;
        varying vec3 v_view_vec;
        varying vec2 vUv;  // 用于接收纹理坐标
        void main() {
            vec3 N = normalize(-v_normal);
            vec3 V = normalize(v_view_vec);
            vec3 L = normalize(v_light_vec);
            vec3 H = normalize(L + V);
            float NdotL = max(0.0, dot(N, L));
            float NdotH = max(0.0, dot(N, H));
        
            // float blur = texture2D(t_blur, v_texcoord).r;
            // blur = 1.0*pow(blur, 2.0);
            vec4 textureColor = texture2D(t_blur, vUv);
            float diffuse = 0.5 + 0.5*NdotL;
            float specular = 0.75 * pow(NdotH, 15.0);

            gl_FragColor.rgb = textureColor.rgb * (diffuse * mix(color0, color1, tone) + vec3(specular));
            gl_FragColor.a = alpha;
        }
    `;

this shader Can fulfill your needs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants