Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. AFRAME.registerShader('skyGradient', {
  2. schema: {
  3. colorTop: { type: 'color', default: 'black', is: 'uniform' },
  4. colorBottom: { type: 'color', default: 'red', is: 'uniform' }
  5. },
  6.  
  7. vertexShader: [
  8. 'varying vec3 vWorldPosition;',
  9.  
  10. 'void main() {',
  11.  
  12. 'vec4 worldPosition = modelMatrix * vec4( position, 1.0 );',
  13. 'vWorldPosition = worldPosition.xyz;',
  14.  
  15. 'gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );',
  16.  
  17. '}'
  18.  
  19. ].join('\n'),
  20.  
  21. fragmentShader: [
  22. 'uniform vec3 colorTop;',
  23. 'uniform vec3 colorBottom;',
  24.  
  25. 'varying vec3 vWorldPosition;',
  26.  
  27. 'void main()',
  28.  
  29. '{',
  30. 'vec3 pointOnSphere = normalize(vWorldPosition.xyz);',
  31. 'float f = 1.0;',
  32. 'if(pointOnSphere.y > - 0.2){',
  33.  
  34. 'f = sin(pointOnSphere.y * 2.0);',
  35.  
  36. '}',
  37. 'gl_FragColor = vec4(mix(colorBottom,colorTop, f ), 1.0);',
  38.  
  39. '}'
  40. ].join('\n')
  41. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement