zoukankan      html  css  js  c++  java
  • leaflet 雷达扫描的shader

    0.效果:

    1.vertexShader

            attribute vec2 aCRSCoords;        
            attribute vec2 aExtrudeCoords;
            uniform mat4 uTransformMatrix;     /
            uniform vec2 uPixelSize;
            uniform float uNow;
            
            attribute float adm0cap;
    
            varying vec2 vExtrudeCoords;
            
            varying float vTimeNow ;
    
            varying vec2 vCRSCoords;
    
            void main(void) {
                vExtrudeCoords = aExtrudeCoords;
                vTimeNow = uNow;
    
                gl_Position = uTransformMatrix * vec4(aCRSCoords, 1.0, 1.0);
        
                // If not, just place a smaller kitten.
                gl_Position += vec4(aExtrudeCoords * uPixelSize * 100.0, 0.0, 0.0);
                
            }

    2.fragmentShader

            uniform sampler2D uTexture0; 
    
    
            precision highp float;
            
            varying float vTimeNow ;
    
            varying vec2 vExtrudeCoords;
    
            const float PI = 3.1415926535898;
    
    
            const float PI_2 = PI/2.0;
    
    
    
            float arctan2(float y,float x){
                if( x > 0.0 )
                    return atan(y/x);
                else if( x < 0.0 && y >= 0.0 )
                    return atan(y/x) + PI;
                else if( x < 0.0 && y < 0.0 )
                    return atan(y/x) - PI;
                else if( x == 0.0 && y > 0.0 )
                    return PI_2;
                else if( x == 0.0 && y < 0.0 )
                    return -PI_2;
                else return 0.0;
            }
    
            void main(void) {
                // Our extrude coordinates go from [-1,-1] to [1,1],
                // but the texture lookup needs coords in the [0,0]-[1,1]
                // range.
    
                vec2 texelCoords;
                texelCoords.x = (vExtrudeCoords.x + 1.0) / 2.0;
                texelCoords.y = (1.0 - vExtrudeCoords.y) / 2.0;
                
                // Perform a texture lookup
                vec4 texelColour = texture2D(uTexture0, texelCoords);
    
                float angle = arctan2( vExtrudeCoords.y, vExtrudeCoords.x );    
    
                angle = mod( -vTimeNow/500.0 + angle,  PI * 2.0 );
                float alpha = 0.0;
                if( angle < PI )
                    angle = 0.0; 
                else
                    alpha = ( angle - PI ) / PI * 1.0;
    
                if( mod(gl_FragCoord.s,3.0) < 1.0 || mod(gl_FragCoord.t,3.0) < 1.0 )
                    alpha = 0.0;
                    
    
                // Use the colour from the texture as the colour for this pixel
                texelColour.a = texelColour.a*alpha;
                gl_FragColor = texelColour;
            }
  • 相关阅读:
    洛谷P3886 [JLOI2009]神秘的生物(插头dp)
    Leetcode 842 将数组拆分成斐波那契序列
    Leetcode 08.07 无重复字符串的排列组合
    Leetcode131 分割回文串
    Leetcode 516 最长回文子序列
    Leetcode08.12 N皇后
    Leetcode 813 最大平均值和分组
    Leetcode 79 单词搜索 二维平面上的回溯
    题解 洛谷 P4694 【[PA2013]Raper】
    跳表的基本认识
  • 原文地址:https://www.cnblogs.com/airduce/p/12619400.html
Copyright © 2011-2022 走看看