Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Rekod3DBuildings.Engine.prototype.createVertexShaderForSnowParticles = function( scriptId ) {
- if ( typeof scriptId === 'string' ) {
- var script = document.createElement( 'script' );
- script.id = scriptId;
- script.type = 'x-shader/x-vertex';
- script.textContent = '\
- attribute float size;\
- attribute float time;\
- attribute vec3 customColor;\
- uniform float globalTime;\
- varying vec3 vColor;\
- varying float fAlpha;\
- \
- void main() {\
- vColor = customColor;\
- vec3 pos = position;\
- float localTime = time + globalTime;\
- float modTime = mod( localTime, 1.0 );\
- float accTime = modTime * modTime;\
- pos.x += cos( modTime * 8.0 + ( position.z ) ) * 70.0;\
- pos.z += sin( modTime * 6.0 + ( position.x ) ) * 100.0;\
- fAlpha = ( pos.z ) / 1800.0;\
- vec3 animated = vec3( pos.x, pos.y * accTime, pos.z );\
- vec4 mvPosition = modelViewMatrix * vec4( animated, 1.0 );\
- gl_PointSize = min( 150.0, size * ( 150.0 / length( mvPosition.xyz ) ) );\
- gl_Position = projectionMatrix * mvPosition;\
- }';
- document.head.appendChild( script );
- return script;
- }
- else
- console.error( 'Script id for the vertex shader isn\'t a type of `string`.' );
- };
- Rekod3DBuildings.Engine.prototype.createFragmentShaderForSnowParticles = function( scriptId ) {
- if ( typeof scriptId === 'string' ) {
- var script = document.createElement( 'script' );
- script.id = scriptId;
- script.type = 'x-shader/x-fragment';
- script.textContent = '\
- uniform vec3 color;\
- uniform sampler2D texture;\
- varying vec3 vColor;\
- varying float fAlpha;\
- \
- void main() {\
- gl_FragColor = vec4( color * vColor, fAlpha );\
- gl_FragColor = gl_FragColor * texture2D( texture, gl_PointCoord );\
- }';
- document.head.appendChild( script );
- return script;
- }
- else
- console.error( 'Script id for the fragment shader isn\'t a type of `string`.' );
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement