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;
            }
  • 相关阅读:
    char/unsigned char/int/short 存储范围
    js 数字数组按大小排序
    【转】Vue生命周期
    mvn+spring+webapp模板
    【转存】Vue组件选项props
    eclipse -- git 显示修改历史 对比文件
    eclipse -- git 提示
    mysql -- 查询并插入
    git --eclipse -- 下载超时
    mysql -- 字符串长度
  • 原文地址:https://www.cnblogs.com/airduce/p/12619400.html
Copyright © 2011-2022 走看看