123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- export const vertexShader = `
- attribute float randam;
- attribute float sprite;
- attribute float centerHeight; //add
-
- //uniform float fireHeight; //add
- uniform float time;
- uniform float size;
- uniform float heightOfNearPlane;
-
-
-
-
- //varying float heightRatio;
- varying float vSprite;
- varying float vOpacity;
- float PI = 3.14;
- float quadraticIn( float t )
- {
- float tt = t * t;
- return tt * tt;
- //变化曲线 越来越快
- }
-
- void main() {
- float progress = fract( time + ( 2.0 * randam - 1.0 ) );
- float progressNeg = 1.0 - progress;
- float ease = quadraticIn( progress );
- float influence = sin( PI * ease );
- //vec3 newPosition = position * vec3( 1.0, 1.0 , ease);
- vec3 newPosition = position;
- newPosition.z = (newPosition.z - centerHeight) * ease + centerHeight;
-
- gl_Position = projectionMatrix * modelViewMatrix * vec4( newPosition, 1.0 );
- gl_PointSize = ( heightOfNearPlane * size ) / gl_Position.w;
- vOpacity = min( influence * 4.0, 1.0 ) * progressNeg;
- vSprite = sprite;
-
- //heightRatio = (newPosition.z - centerHeight) / fireHeight ;
-
- }
- `
- export const fragmentShader = `
- uniform vec3 color;
- uniform sampler2D u_sampler;
- varying float vSprite;
- varying float vOpacity;
- //varying float heightRatio;
- void main()
- {
-
-
- vec2 texCoord = vec2(gl_PointCoord.x * 0.25 + vSprite, gl_PointCoord.y);
-
- gl_FragColor = vec4( texture2D( u_sampler, texCoord ).xyz * color * vOpacity, 1.0 );
-
-
- }
- `
|