Преглед изворни кода

add @dc-modules/material

tags/2.0.0
Caven Chen пре 4 година
родитељ
комит
55e55ee496
75 измењених фајлова са 3375 додато и 0 уклоњено
  1. 41
    0
      modules/material/MaterialProperty.js
  2. 62
    0
      modules/material/index.js
  3. 41
    0
      modules/material/property/circle/CircleBlurMaterialProperty.js
  4. 41
    0
      modules/material/property/circle/CircleDiffuseMaterialProperty.js
  5. 43
    0
      modules/material/property/circle/CircleFadeMaterialProperty.js
  6. 43
    0
      modules/material/property/circle/CirclePulseMaterialProperty.js
  7. 43
    0
      modules/material/property/circle/CircleScanMaterialProperty.js
  8. 43
    0
      modules/material/property/circle/CircleSpiralMaterialProperty.js
  9. 41
    0
      modules/material/property/circle/CircleVaryMaterialProperty.js
  10. 55
    0
      modules/material/property/circle/CircleWaveMaterialProperty.js
  11. 41
    0
      modules/material/property/ellipsoid/EllipsoidElectricMaterialProperty.js
  12. 41
    0
      modules/material/property/ellipsoid/EllipsoidTrailMaterialProperty.js
  13. 40
    0
      modules/material/property/polyline/PolylineEmissionMaterialProperty.js
  14. 43
    0
      modules/material/property/polyline/PolylineFlickerMaterialProperty.js
  15. 55
    0
      modules/material/property/polyline/PolylineFlowMaterialProperty.js
  16. 58
    0
      modules/material/property/polyline/PolylineImageTrailMaterialProperty.js
  17. 48
    0
      modules/material/property/polyline/PolylineLightingMaterialProperty.js
  18. 50
    0
      modules/material/property/polyline/PolylineLightingTrailMaterialProperty.js
  19. 43
    0
      modules/material/property/polyline/PolylineTrailMaterialProperty.js
  20. 41
    0
      modules/material/property/radar/RadarLineMaterialProperty.js
  21. 41
    0
      modules/material/property/radar/RadarSweepMaterialProperty.js
  22. 41
    0
      modules/material/property/radar/RadarWaveMaterialProperty.js
  23. 56
    0
      modules/material/property/wall/WallImageTrailMaterialProperty.js
  24. 59
    0
      modules/material/property/wall/WallLineTrailMaterialProperty.js
  25. 50
    0
      modules/material/property/wall/WallTrailMaterialProperty.js
  26. 87
    0
      modules/material/property/water/WaterMaterialProperty.js
  27. 17
    0
      modules/material/shader/circle/CircleBlurMaterial.glsl
  28. 24
    0
      modules/material/shader/circle/CircleDiffuseMaterial.glsl
  29. 16
    0
      modules/material/shader/circle/CircleFadeMaterial.glsl
  30. 16
    0
      modules/material/shader/circle/CirclePulseMaterial.glsl
  31. 26
    0
      modules/material/shader/circle/CircleScanMaterial.glsl
  32. 46
    0
      modules/material/shader/circle/CircleScanShader.glsl
  33. 24
    0
      modules/material/shader/circle/CircleSpiralMaterial.glsl
  34. 18
    0
      modules/material/shader/circle/CircleVaryMaterial.glsl
  35. 48
    0
      modules/material/shader/circle/CircleWaveMaterial.glsl
  36. 78
    0
      modules/material/shader/ellipsoid/EllipsoidElectricMaterial.glsl
  37. 12
    0
      modules/material/shader/ellipsoid/EllipsoidTrailMaterial.glsl
  38. 11
    0
      modules/material/shader/polyline/PolylineEmissionMaterial.glsl
  39. 11
    0
      modules/material/shader/polyline/PolylineFlickerMaterial.glsl
  40. 16
    0
      modules/material/shader/polyline/PolylineFlowMaterial.glsl
  41. 19
    0
      modules/material/shader/polyline/PolylineImageTrailMaterial.glsl
  42. 11
    0
      modules/material/shader/polyline/PolylineLightingMaterial.glsl
  43. 21
    0
      modules/material/shader/polyline/PolylineLightingTrailMaterial.glsl
  44. 11
    0
      modules/material/shader/polyline/PolylineTrailMaterial.glsl
  45. 24
    0
      modules/material/shader/radar/RadarLineMaterial.glsl
  46. 70
    0
      modules/material/shader/radar/RadarScanShader.glsl
  47. 32
    0
      modules/material/shader/radar/RadarSweepMaterial.glsl
  48. 27
    0
      modules/material/shader/radar/RadarWaveMaterial.glsl
  49. 24
    0
      modules/material/shader/thirdpart/AsphaltMaterial.glsl
  50. 17
    0
      modules/material/shader/thirdpart/BlobMaterial.glsl
  51. 41
    0
      modules/material/shader/thirdpart/BrickMaterial.glsl
  52. 18
    0
      modules/material/shader/thirdpart/CementMaterial.glsl
  53. 21
    0
      modules/material/shader/thirdpart/ErosionMaterial.glsl
  54. 17
    0
      modules/material/shader/thirdpart/FacetMaterial.glsl
  55. 11
    0
      modules/material/shader/thirdpart/FresnelMaterial.glsl
  56. 27
    0
      modules/material/shader/thirdpart/GrassMaterial.glsl
  57. 12
    0
      modules/material/shader/thirdpart/ReflectionMaterial.glsl
  58. 13
    0
      modules/material/shader/thirdpart/RefractionMaterial.glsl
  59. 16
    0
      modules/material/shader/thirdpart/TieDyeMaterial.glsl
  60. 35
    0
      modules/material/shader/thirdpart/WoodMaterial.glsl
  61. 77
    0
      modules/material/shader/thirdpart/cellular.glsl
  62. 282
    0
      modules/material/shader/thirdpart/snoise.glsl
  63. 13
    0
      modules/material/shader/wall/WallImageTrailMaterial.glsl
  64. 16
    0
      modules/material/shader/wall/WallLineTrailMaterial.glsl
  65. 25
    0
      modules/material/shader/wall/WallRippleMaterial.glsl
  66. 18
    0
      modules/material/shader/wall/WallTrailMaterial.glsl
  67. 36
    0
      modules/material/shader/weather/FogShader.glsl
  68. 22
    0
      modules/material/shader/weather/RainShader.glsl
  69. 33
    0
      modules/material/shader/weather/SnowShader.glsl
  70. 169
    0
      modules/material/type/circle.js
  71. 50
    0
      modules/material/type/ellipsoid.js
  72. 146
    0
      modules/material/type/polyline.js
  73. 67
    0
      modules/material/type/radar.js
  74. 272
    0
      modules/material/type/thirdpart.js
  75. 72
    0
      modules/material/type/wall.js

+ 41
- 0
modules/material/MaterialProperty.js Прегледај датотеку

@@ -0,0 +1,41 @@
/**
* @Author: Caven
* @Date: 2021-02-27 22:33:50
*/

const { Cesium } = DC.Namespace

class MaterialProperty {
constructor(options = {}) {
this._definitionChanged = new Cesium.Event()
this._color = undefined
this._colorSubscription = undefined
this._speed = undefined
this._speedSubscription = undefined
this.color = options.color || Cesium.Color.fromBytes(0, 255, 255, 255)
this.speed = options.speed || 1
}

get isConstant() {
return false
}

get definitionChanged() {
return this._definitionChanged
}

getType(time) {
return null
}

getValue(time, result) {
result = Cesium.defaultValue(result, {})
return result
}

equals(other) {
return this === other
}
}

export default MaterialProperty

+ 62
- 0
modules/material/index.js Прегледај датотеку

@@ -0,0 +1,62 @@
/**
* @Author: Caven
* @Date: 2020-02-24 13:28:37
*/

// material

export * from './type/thirdpart'
export * from './type/circle'
export * from './type/ellipsoid'
export * from './type/polyline'
export * from './type/radar'
export * from './type/wall'

/**
* circle material property
*/

export { default as CircleBlurMaterialProperty } from './property/circle/CircleBlurMaterialProperty'
export { default as CircleDiffuseMaterialProperty } from './property/circle/CircleDiffuseMaterialProperty'
export { default as CircleFadeMaterialProperty } from './property/circle/CircleFadeMaterialProperty'
export { default as CirclePulseMaterialProperty } from './property/circle/CirclePulseMaterialProperty'
export { default as CircleScanMaterialProperty } from './property/circle/CircleScanMaterialProperty'
export { default as CircleSpiralMaterialProperty } from './property/circle/CircleSpiralMaterialProperty'
export { default as CircleVaryMaterialProperty } from './property/circle/CircleVaryMaterialProperty'
export { default as CircleWaveMaterialProperty } from './property/circle/CircleWaveMaterialProperty'

/**
* ellipsoid material property
*/
export { default as EllipsoidElectricMaterialProperty } from './property/ellipsoid/EllipsoidElectricMaterialProperty'
export { default as EllipsoidTrailMaterialProperty } from './property/ellipsoid/EllipsoidTrailMaterialProperty'

/**
* polyline material property
*/

export { default as PolylineFlickerMaterialProperty } from './property/polyline/PolylineFlickerMaterialProperty'
export { default as PolylineFlowMaterialProperty } from './property/polyline/PolylineFlowMaterialProperty'
export { default as PolylineImageTrailMaterialProperty } from './property/polyline/PolylineImageTrailMaterialProperty'
export { default as PolylineLightingMaterialProperty } from './property/polyline/PolylineLightingMaterialProperty'
export { default as PolylineLightingTrailMaterialProperty } from './property/polyline/PolylineLightingTrailMaterialProperty'
export { default as PolylineTrailMaterialProperty } from './property/polyline/PolylineTrailMaterialProperty'

/**
* radar material property
*/
export { default as RadarLineMaterialProperty } from './property/radar/RadarLineMaterialProperty'
export { default as RadarSweepMaterialProperty } from './property/radar/RadarSweepMaterialProperty'
export { default as RadarWaveMaterialProperty } from './property/radar/RadarWaveMaterialProperty'

/**
* wall material property
*/
export { default as WallImageTrailMaterialProperty } from './property/wall/WallImageTrailMaterialProperty'
export { default as WallLineTrailMaterialProperty } from './property/wall/WallLineTrailMaterialProperty'
export { default as WallTrailMaterialProperty } from './property/wall/WallTrailMaterialProperty'

/**
* water material property
*/
export { default as WaterMaterialProperty } from './property/water/WaterMaterialProperty'

+ 41
- 0
modules/material/property/circle/CircleBlurMaterialProperty.js Прегледај датотеку

@@ -0,0 +1,41 @@
/**
* @Author: Caven
* @Date: 2021-02-27 22:10:18
*/

import MaterialProperty from '../../MaterialProperty'

const { Cesium } = DC.Namespace

class CircleBlurMaterialProperty extends MaterialProperty {
constructor(options = {}) {
super(options)
}

getType(time) {
return Cesium.Material.CircleBlurType
}

getValue(time, result) {
result = Cesium.defaultValue(result, {})
result.color = Cesium.Property.getValueOrUndefined(this._color, time)
result.speed = this._speed
return result
}

equals(other) {
return (
this === other ||
(other instanceof CircleBlurMaterialProperty &&
Cesium.Property.equals(this._color, other._color) &&
Cesium.Property.equals(this._speed, other._speed))
)
}
}

Object.defineProperties(CircleBlurMaterialProperty.prototype, {
color: Cesium.createPropertyDescriptor('color'),
speed: Cesium.createPropertyDescriptor('speed')
})

export default CircleBlurMaterialProperty

+ 41
- 0
modules/material/property/circle/CircleDiffuseMaterialProperty.js Прегледај датотеку

@@ -0,0 +1,41 @@
/**
* @Author: Caven
* @Date: 2021-02-27 22:10:18
*/

import MaterialProperty from '../../MaterialProperty'

const { Cesium } = DC.Namespace

class CircleDiffuseMaterialProperty extends MaterialProperty {
constructor(options = {}) {
super(options)
}

getType(time) {
return Cesium.Material.CircleDiffuseType
}

getValue(time, result) {
result = Cesium.defaultValue(result, {})
result.color = Cesium.Property.getValueOrUndefined(this._color, time)
result.speed = this._speed
return result
}

equals(other) {
return (
this === other ||
(other instanceof CircleDiffuseMaterialProperty &&
Cesium.Property.equals(this._color, other._color) &&
Cesium.Property.equals(this._speed, other._speed))
)
}
}

Object.defineProperties(CircleDiffuseMaterialProperty.prototype, {
color: Cesium.createPropertyDescriptor('color'),
speed: Cesium.createPropertyDescriptor('speed')
})

export default CircleDiffuseMaterialProperty

+ 43
- 0
modules/material/property/circle/CircleFadeMaterialProperty.js Прегледај датотеку

@@ -0,0 +1,43 @@
/**
* @Author: Caven
* @Date: 2020-03-06 17:56:39
*/

import MaterialProperty from '../../MaterialProperty'

const { Cesium } = DC.Namespace

class CircleFadeMaterialProperty extends MaterialProperty {
constructor(options = {}) {
super(options)
}

getType(time) {
return Cesium.Material.CircleFadeType
}

getValue(time, result) {
if (!result) {
result = {}
}
result.color = Cesium.Property.getValueOrUndefined(this._color, time)
result.speed = this._speed
return result
}

equals(other) {
return (
this === other ||
(other instanceof CircleFadeMaterialProperty &&
Cesium.Property.equals(this._color, other._color) &&
Cesium.Property.equals(this._speed, other._speed))
)
}
}

Object.defineProperties(CircleFadeMaterialProperty.prototype, {
color: Cesium.createPropertyDescriptor('color'),
speed: Cesium.createPropertyDescriptor('speed')
})

export default CircleFadeMaterialProperty

+ 43
- 0
modules/material/property/circle/CirclePulseMaterialProperty.js Прегледај датотеку

@@ -0,0 +1,43 @@
/**
* @Author: Caven
* @Date: 2021-02-27 23:03:44
*/

import MaterialProperty from '../../MaterialProperty'

const { Cesium } = DC.Namespace

class CirclePulseMaterialProperty extends MaterialProperty {
constructor(options = {}) {
super(options)
}

getType(time) {
return Cesium.Material.CirclePulseType
}

getValue(time, result) {
if (!result) {
result = {}
}
result.color = Cesium.Property.getValueOrUndefined(this._color, time)
result.speed = this._speed
return result
}

equals(other) {
return (
this === other ||
(other instanceof CirclePulseMaterialProperty &&
Cesium.Property.equals(this._color, other._color) &&
Cesium.Property.equals(this._speed, other._speed))
)
}
}

Object.defineProperties(CirclePulseMaterialProperty.prototype, {
color: Cesium.createPropertyDescriptor('color'),
speed: Cesium.createPropertyDescriptor('speed')
})

export default CirclePulseMaterialProperty

+ 43
- 0
modules/material/property/circle/CircleScanMaterialProperty.js Прегледај датотеку

@@ -0,0 +1,43 @@
/**
* @Author: Caven
* @Date: 2021-01-09 20:23:53
*/

import MaterialProperty from '../../MaterialProperty'

const { Cesium } = DC.Namespace

class CircleScanMaterialProperty extends MaterialProperty {
constructor(options = {}) {
super(options)
}

getType(time) {
return Cesium.Material.CircleScanType
}

getValue(time, result) {
if (!result) {
result = {}
}
result.color = Cesium.Property.getValueOrUndefined(this._color, time)
result.speed = this._speed
return result
}

equals(other) {
return (
this === other ||
(other instanceof CircleScanMaterialProperty &&
Cesium.Property.equals(this._color, other._color) &&
Cesium.Property.equals(this._speed, other._speed))
)
}
}

Object.defineProperties(CircleScanMaterialProperty.prototype, {
color: Cesium.createPropertyDescriptor('color'),
speed: Cesium.createPropertyDescriptor('speed')
})

export default CircleScanMaterialProperty

+ 43
- 0
modules/material/property/circle/CircleSpiralMaterialProperty.js Прегледај датотеку

@@ -0,0 +1,43 @@
/**
* @Author: Caven
* @Date: 2021-01-09 20:23:53
*/

import MaterialProperty from '../../MaterialProperty'

const { Cesium } = DC.Namespace

class CircleSpiralMaterialProperty extends MaterialProperty {
constructor(options = {}) {
super(options)
}

getType(time) {
return Cesium.Material.CircleSpiralType
}

getValue(time, result) {
if (!result) {
result = {}
}
result.color = Cesium.Property.getValueOrUndefined(this._color, time)
result.speed = this._speed
return result
}

equals(other) {
return (
this === other ||
(other instanceof CircleSpiralMaterialProperty &&
Cesium.Property.equals(this._color, other._color) &&
Cesium.Property.equals(this._speed, other._speed))
)
}
}

Object.defineProperties(CircleSpiralMaterialProperty.prototype, {
color: Cesium.createPropertyDescriptor('color'),
speed: Cesium.createPropertyDescriptor('speed')
})

export default CircleSpiralMaterialProperty

+ 41
- 0
modules/material/property/circle/CircleVaryMaterialProperty.js Прегледај датотеку

@@ -0,0 +1,41 @@
/**
* @Author: Caven
* @Date: 2021-02-27 22:10:18
*/

import MaterialProperty from '../../MaterialProperty'

const { Cesium } = DC.Namespace

class CircleVaryMaterialProperty extends MaterialProperty {
constructor(options = {}) {
super(options)
}

getType(time) {
return Cesium.Material.CircleVaryType
}

getValue(time, result) {
result = Cesium.defaultValue(result, {})
result.color = Cesium.Property.getValueOrUndefined(this._color, time)
result.speed = this._speed
return result
}

equals(other) {
return (
this === other ||
(other instanceof CircleVaryMaterialProperty &&
Cesium.Property.equals(this._color, other._color) &&
Cesium.Property.equals(this._speed, other._speed))
)
}
}

Object.defineProperties(CircleVaryMaterialProperty.prototype, {
color: Cesium.createPropertyDescriptor('color'),
speed: Cesium.createPropertyDescriptor('speed')
})

export default CircleVaryMaterialProperty

+ 55
- 0
modules/material/property/circle/CircleWaveMaterialProperty.js Прегледај датотеку

@@ -0,0 +1,55 @@
/**
* @Author: Caven
* @Date: 2020-03-06 17:56:39
*/

import MaterialProperty from '../../MaterialProperty'

const { Cesium } = DC.Namespace

class CircleWaveMaterialProperty extends MaterialProperty {
constructor(options = {}) {
super(options)
this.count = Math.max(options.count || 3, 1)
this.gradient = Cesium.Math.clamp(options.gradient || 0.1, 0, 1)
}

get isConstant() {
return false
}

get definitionChanged() {
return this._definitionChanged
}

getType(time) {
return Cesium.Material.CircleWaveType
}

getValue(time, result) {
if (!result) {
result = {}
}
result.color = Cesium.Property.getValueOrUndefined(this._color, time)
result.speed = this._speed
result.count = this.count
result.gradient = this.gradient
return result
}

equals(other) {
return (
this === other ||
(other instanceof CircleWaveMaterialProperty &&
Cesium.Property.equals(this._color, other._color) &&
Cesium.Property.equals(this._speed, other._speed))
)
}
}

Object.defineProperties(CircleWaveMaterialProperty.prototype, {
color: Cesium.createPropertyDescriptor('color'),
speed: Cesium.createPropertyDescriptor('speed')
})

export default CircleWaveMaterialProperty

+ 41
- 0
modules/material/property/ellipsoid/EllipsoidElectricMaterialProperty.js Прегледај датотеку

@@ -0,0 +1,41 @@
/**
* @Author: Caven
* @Date: 2021-03-04 22:10:18
*/

import MaterialProperty from '../../MaterialProperty'

const { Cesium } = DC.Namespace

class EllipsoidElectricMaterialProperty extends MaterialProperty {
constructor(options = {}) {
super(options)
}

getType(time) {
return Cesium.Material.EllipsoidElectricType
}

getValue(time, result) {
result = Cesium.defaultValue(result, {})
result.color = Cesium.Property.getValueOrUndefined(this._color, time)
result.speed = this._speed
return result
}

equals(other) {
return (
this === other ||
(other instanceof EllipsoidElectricMaterialProperty &&
Cesium.Property.equals(this._color, other._color) &&
Cesium.Property.equals(this._speed, other._speed))
)
}
}

Object.defineProperties(EllipsoidElectricMaterialProperty.prototype, {
color: Cesium.createPropertyDescriptor('color'),
speed: Cesium.createPropertyDescriptor('speed')
})

export default EllipsoidElectricMaterialProperty

+ 41
- 0
modules/material/property/ellipsoid/EllipsoidTrailMaterialProperty.js Прегледај датотеку

@@ -0,0 +1,41 @@
/**
* @Author: Caven
* @Date: 2021-03-04 22:10:18
*/

import MaterialProperty from '../../MaterialProperty'

const { Cesium } = DC.Namespace

class EllipsoidTrailMaterialProperty extends MaterialProperty {
constructor(options = {}) {
super(options)
}

getType(time) {
return Cesium.Material.EllipsoidTrailType
}

getValue(time, result) {
result = Cesium.defaultValue(result, {})
result.color = Cesium.Property.getValueOrUndefined(this._color, time)
result.speed = this._speed
return result
}

equals(other) {
return (
this === other ||
(other instanceof EllipsoidTrailMaterialProperty &&
Cesium.Property.equals(this._color, other._color) &&
Cesium.Property.equals(this._speed, other._speed))
)
}
}

Object.defineProperties(EllipsoidTrailMaterialProperty.prototype, {
color: Cesium.createPropertyDescriptor('color'),
speed: Cesium.createPropertyDescriptor('speed')
})

export default EllipsoidTrailMaterialProperty

+ 40
- 0
modules/material/property/polyline/PolylineEmissionMaterialProperty.js Прегледај датотеку

@@ -0,0 +1,40 @@
/**
* @Author: Caven
* @Date: 2020-02-26 10:15:55
*/

import MaterialProperty from '../../MaterialProperty'

const { Cesium } = DC.Namespace

class PolylineEmissionMaterialProperty extends MaterialProperty {
constructor(options = {}) {
super(options)
}

getType(time) {
return Cesium.Material.PolylineEmissionType
}

getValue(time, result) {
if (!result) {
result = {}
}
result.color = Cesium.Property.getValueOrUndefined(this._color, time)
return result
}

equals(other) {
return (
this === other ||
(other instanceof PolylineEmissionMaterialProperty &&
Cesium.Property.equals(this._color, other._color))
)
}
}

Object.defineProperties(PolylineEmissionMaterialProperty.prototype, {
color: Cesium.createPropertyDescriptor('color')
})

export default PolylineEmissionMaterialProperty

+ 43
- 0
modules/material/property/polyline/PolylineFlickerMaterialProperty.js Прегледај датотеку

@@ -0,0 +1,43 @@
/**
* @Author: Caven
* @Date: 2021-01-11 21:08:02
*/

import MaterialProperty from '../../MaterialProperty'

const { Cesium } = DC.Namespace

class PolylineFlickerMaterialProperty extends MaterialProperty {
constructor(options = {}) {
super(options)
}

getType(time) {
return Cesium.Material.PolylineFlickerType
}

getValue(time, result) {
if (!result) {
result = {}
}
result.color = Cesium.Property.getValueOrUndefined(this._color, time)
result.speed = this._speed
return result
}

equals(other) {
return (
this === other ||
(other instanceof PolylineFlickerMaterialProperty &&
Cesium.Property.equals(this._color, other._color) &&
Cesium.Property.equals(this._speed, other._speed))
)
}
}

Object.defineProperties(PolylineFlickerMaterialProperty.prototype, {
color: Cesium.createPropertyDescriptor('color'),
speed: Cesium.createPropertyDescriptor('speed')
})

export default PolylineFlickerMaterialProperty

+ 55
- 0
modules/material/property/polyline/PolylineFlowMaterialProperty.js Прегледај датотеку

@@ -0,0 +1,55 @@
/**
* @Author: Caven
* @Date: 2020-02-24 13:53:52
*/

import MaterialProperty from '../../MaterialProperty'

const { Cesium } = DC.Namespace

class PolylineFlowMaterialProperty extends MaterialProperty {
constructor(options = {}) {
super(options)
this._percent = undefined
this._percentSubscription = undefined
this._gradient = undefined
this._gradientSubscription = undefined
this.percent = options.percent || 0.03
this.gradient = options.gradient || 0.1
}

getType(time) {
return Cesium.Material.PolylineFlowType
}

getValue(time, result) {
if (!result) {
result = {}
}
result.color = Cesium.Property.getValueOrUndefined(this._color, time)
result.speed = this._speed
result.percent = this._percent
result.gradient = this._gradient
return result
}

equals(other) {
return (
this === other ||
(other instanceof PolylineFlowMaterialProperty &&
Cesium.Property.equals(this._color, other._color) &&
Cesium.Property.equals(this._speed, other._speed) &&
Cesium.Property.equals(this._percent, other._percent) &&
Cesium.Property.equals(this._gradient, other._gradient))
)
}
}

Object.defineProperties(PolylineFlowMaterialProperty.prototype, {
color: Cesium.createPropertyDescriptor('color'),
speed: Cesium.createPropertyDescriptor('speed'),
percent: Cesium.createPropertyDescriptor('percent'),
gradient: Cesium.createPropertyDescriptor('gradient')
})

export default PolylineFlowMaterialProperty

+ 58
- 0
modules/material/property/polyline/PolylineImageTrailMaterialProperty.js Прегледај датотеку

@@ -0,0 +1,58 @@
/**
* @Author: Caven
* @Date: 2020-07-17 22:15:56
*/

import MaterialProperty from '../../MaterialProperty'

const { Cesium } = DC.Namespace

class PolylineImageTrailMaterialProperty extends MaterialProperty {
constructor(options = {}) {
super(options)
this._image = undefined
this._imageSubscription = undefined
this._repeat = undefined
this._repeatSubscription = undefined
this.image = options.image
this.repeat = new Cesium.Cartesian2(
options.repeat?.x || 1,
options.repeat?.y || 1
)
}

getType(time) {
return Cesium.Material.PolylineImageTrailType
}

getValue(time, result) {
if (!result) {
result = {}
}
result.color = Cesium.Property.getValueOrUndefined(this._color, time)
result.image = Cesium.Property.getValueOrUndefined(this._image, time)
result.repeat = Cesium.Property.getValueOrUndefined(this._repeat, time)
result.speed = this._speed
return result
}

equals(other) {
return (
this === other ||
(other instanceof PolylineImageTrailMaterialProperty &&
Cesium.Property.equals(this._color, other._color) &&
Cesium.Property.equals(this._image, other._image) &&
Cesium.Property.equals(this._repeat, other._repeat) &&
Cesium.Property.equals(this._speed, other._speed))
)
}
}

Object.defineProperties(PolylineImageTrailMaterialProperty.prototype, {
color: Cesium.createPropertyDescriptor('color'),
speed: Cesium.createPropertyDescriptor('speed'),
image: Cesium.createPropertyDescriptor('image'),
repeat: Cesium.createPropertyDescriptor('repeat')
})

export default PolylineImageTrailMaterialProperty

+ 48
- 0
modules/material/property/polyline/PolylineLightingMaterialProperty.js Прегледај датотеку

@@ -0,0 +1,48 @@
/**
* @Author: Caven
* @Date: 2021-01-13 20:52:47
*/

import MaterialProperty from '../../MaterialProperty'

const IMG = require('@dc-modules/images/lighting.png')

const { Cesium } = DC.Namespace

class PolylineLightingMaterialProperty extends MaterialProperty {
constructor(options = {}) {
super(options)
this._image = undefined
this._imageSubscription = undefined
this.image = IMG
}

getType(time) {
return Cesium.Material.PolylineLightingType
}

getValue(time, result) {
if (!result) {
result = {}
}
result.color = Cesium.Property.getValueOrUndefined(this._color, time)
result.image = Cesium.Property.getValueOrUndefined(this._image, time)
return result
}

equals(other) {
return (
this === other ||
(other instanceof PolylineLightingMaterialProperty &&
Cesium.Property.equals(this._color, other._color) &&
Cesium.Property.equals(this._image, other._image))
)
}
}

Object.defineProperties(PolylineLightingMaterialProperty.prototype, {
color: Cesium.createPropertyDescriptor('color'),
image: Cesium.createPropertyDescriptor('image')
})

export default PolylineLightingMaterialProperty

+ 50
- 0
modules/material/property/polyline/PolylineLightingTrailMaterialProperty.js Прегледај датотеку

@@ -0,0 +1,50 @@
/**
* @Author: Caven
* @Date: 2021-01-13 20:52:47
*/

import MaterialProperty from '../../MaterialProperty'

const IMG = require('@dc-modules/images/lighting.png')

const { Cesium } = DC.Namespace

class PolylineLightingTrailMaterialProperty extends MaterialProperty {
constructor(options = {}) {
super(options)
this._image = undefined
this._imageSubscription = undefined
this.image = IMG
}

getType(time) {
return Cesium.Material.PolylineLightingTrailType
}

getValue(time, result) {
if (!result) {
result = {}
}
result.color = Cesium.Property.getValueOrUndefined(this._color, time)
result.image = Cesium.Property.getValueOrUndefined(this._image, time)
result.speed = this._speed
return result
}

equals(other) {
return (
this === other ||
(other instanceof PolylineLightingTrailMaterialProperty &&
Cesium.Property.equals(this._color, other._color) &&
Cesium.Property.equals(this._speed, other._speed))
)
}
}

Object.defineProperties(PolylineLightingTrailMaterialProperty.prototype, {
color: Cesium.createPropertyDescriptor('color'),
speed: Cesium.createPropertyDescriptor('speed'),
image: Cesium.createPropertyDescriptor('image')
})

export default PolylineLightingTrailMaterialProperty

+ 43
- 0
modules/material/property/polyline/PolylineTrailMaterialProperty.js Прегледај датотеку

@@ -0,0 +1,43 @@
/**
* @Author: Caven
* @Date: 2020-02-24 13:09:09
*/

import MaterialProperty from '../../MaterialProperty'

const { Cesium } = DC.Namespace

class PolylineTrailMaterialProperty extends MaterialProperty {
constructor(options = {}) {
super(options)
}

getType(time) {
return Cesium.Material.PolylineTrailType
}

getValue(time, result) {
if (!result) {
result = {}
}
result.color = Cesium.Property.getValueOrUndefined(this._color, time)
result.speed = this._speed
return result
}

equals(other) {
return (
this === other ||
(other instanceof PolylineTrailMaterialProperty &&
Cesium.Property.equals(this._color, other._color) &&
Cesium.Property.equals(this._speed, other._speed))
)
}
}

Object.defineProperties(PolylineTrailMaterialProperty.prototype, {
color: Cesium.createPropertyDescriptor('color'),
speed: Cesium.createPropertyDescriptor('speed')
})

export default PolylineTrailMaterialProperty

+ 41
- 0
modules/material/property/radar/RadarLineMaterialProperty.js Прегледај датотеку

@@ -0,0 +1,41 @@
/**
* @Author: Caven
* @Date: 2021-02-27 23:53:08
*/

import MaterialProperty from '../../MaterialProperty'

const { Cesium } = DC.Namespace

class RadarLineMaterialProperty extends MaterialProperty {
constructor(options = {}) {
super(options)
}

getType(time) {
return Cesium.Material.RadarLineType
}

getValue(time, result) {
result = Cesium.defaultValue(result, {})
result.color = Cesium.Property.getValueOrUndefined(this._color, time)
result.speed = this._speed
return result
}

equals(other) {
return (
this === other ||
(other instanceof RadarLineMaterialProperty &&
Cesium.Property.equals(this._color, other._color) &&
Cesium.Property.equals(this._speed, other._speed))
)
}
}

Object.defineProperties(RadarLineMaterialProperty.prototype, {
color: Cesium.createPropertyDescriptor('color'),
speed: Cesium.createPropertyDescriptor('speed')
})

export default RadarLineMaterialProperty

+ 41
- 0
modules/material/property/radar/RadarSweepMaterialProperty.js Прегледај датотеку

@@ -0,0 +1,41 @@
/**
* @Author: Caven
* @Date: 2021-02-27 23:53:08
*/

import MaterialProperty from '../../MaterialProperty'

const { Cesium } = DC.Namespace

class RadarSweepMaterialProperty extends MaterialProperty {
constructor(options = {}) {
super(options)
}

getType(time) {
return Cesium.Material.RadarSweepType
}

getValue(time, result) {
result = Cesium.defaultValue(result, {})
result.color = Cesium.Property.getValueOrUndefined(this._color, time)
result.speed = this._speed
return result
}

equals(other) {
return (
this === other ||
(other instanceof RadarSweepMaterialProperty &&
Cesium.Property.equals(this._color, other._color) &&
Cesium.Property.equals(this._speed, other._speed))
)
}
}

Object.defineProperties(RadarSweepMaterialProperty.prototype, {
color: Cesium.createPropertyDescriptor('color'),
speed: Cesium.createPropertyDescriptor('speed')
})

export default RadarSweepMaterialProperty

+ 41
- 0
modules/material/property/radar/RadarWaveMaterialProperty.js Прегледај датотеку

@@ -0,0 +1,41 @@
/**
* @Author: Caven
* @Date: 2021-02-27 23:53:08
*/

import MaterialProperty from '../../MaterialProperty'

const { Cesium } = DC.Namespace

class RadarWaveMaterialProperty extends MaterialProperty {
constructor(options = {}) {
super(options)
}

getType(time) {
return Cesium.Material.RadarWaveType
}

getValue(time, result) {
result = Cesium.defaultValue(result, {})
result.color = Cesium.Property.getValueOrUndefined(this._color, time)
result.speed = this._speed
return result
}

equals(other) {
return (
this === other ||
(other instanceof RadarWaveMaterialProperty &&
Cesium.Property.equals(this._color, other._color) &&
Cesium.Property.equals(this._speed, other._speed))
)
}
}

Object.defineProperties(RadarWaveMaterialProperty.prototype, {
color: Cesium.createPropertyDescriptor('color'),
speed: Cesium.createPropertyDescriptor('speed')
})

export default RadarWaveMaterialProperty

+ 56
- 0
modules/material/property/wall/WallImageTrailMaterialProperty.js Прегледај датотеку

@@ -0,0 +1,56 @@
/**
* @Author: Caven
* @Date: 2021-02-27 23:53:08
*/

import MaterialProperty from '../../MaterialProperty'

const { Cesium } = DC.Namespace

class WallImageTrailMaterialProperty extends MaterialProperty {
constructor(options = {}) {
super(options)
this._image = undefined
this._imageSubscription = undefined
this._repeat = undefined
this._repeatSubscription = undefined
this.image = options.image
this.repeat = new Cesium.Cartesian2(
options.repeat?.x || 1,
options.repeat?.y || 1
)
}

getType(time) {
return Cesium.Material.WallImageTrailType
}

getValue(time, result) {
result = Cesium.defaultValue(result, {})
result.color = Cesium.Property.getValueOrUndefined(this._color, time)
result.image = Cesium.Property.getValueOrUndefined(this._image, time)
result.repeat = Cesium.Property.getValueOrUndefined(this._repeat, time)
result.speed = this._speed
return result
}

equals(other) {
return (
this === other ||
(other instanceof WallImageTrailMaterialProperty &&
Cesium.Property.equals(this._color, other._color) &&
Cesium.Property.equals(this._image, other._image) &&
Cesium.Property.equals(this._repeat, other._repeat) &&
Cesium.Property.equals(this._speed, other._speed))
)
}
}

Object.defineProperties(WallImageTrailMaterialProperty.prototype, {
image: Cesium.createPropertyDescriptor('image'),
color: Cesium.createPropertyDescriptor('color'),
speed: Cesium.createPropertyDescriptor('speed'),
repeat: Cesium.createPropertyDescriptor('repeat')
})

export default WallImageTrailMaterialProperty

+ 59
- 0
modules/material/property/wall/WallLineTrailMaterialProperty.js Прегледај датотеку

@@ -0,0 +1,59 @@
/**
* @Author: Caven
* @Date: 2021-02-24 13:54:09
*/

import MaterialProperty from '../../MaterialProperty'

const IMG = require('@dc-modules/images/space_line.png')

const { Cesium } = DC.Namespace

class WallLineTrailMaterialProperty extends MaterialProperty {
constructor(options = {}) {
super(options)
this._image = undefined
this._imageSubscription = undefined
this._repeat = undefined
this._repeatSubscription = undefined
this.image = IMG
this.repeat = new Cesium.Cartesian2(
options.repeat?.x || 1,
options.repeat?.y || 1
)
}

getType(time) {
return Cesium.Material.WallLineTrailType
}

getValue(time, result) {
if (!result) {
result = {}
}
result.color = Cesium.Property.getValueOrUndefined(this._color, time)
result.image = Cesium.Property.getValueOrUndefined(this._image, time)
result.repeat = Cesium.Property.getValueOrUndefined(this._repeat, time)
result.speed = this._speed
return result
}

equals(other) {
return (
this === other ||
(other instanceof WallLineTrailMaterialProperty &&
Cesium.Property.equals(this._color, other._color) &&
Cesium.Property.equals(this._speed, other._speed) &&
Cesium.Property.equals(this._repeat, other._repeat))
)
}
}

Object.defineProperties(WallLineTrailMaterialProperty.prototype, {
color: Cesium.createPropertyDescriptor('color'),
image: Cesium.createPropertyDescriptor('image'),
repeat: Cesium.createPropertyDescriptor('repeat'),
speed: Cesium.createPropertyDescriptor('speed')
})

export default WallLineTrailMaterialProperty

+ 50
- 0
modules/material/property/wall/WallTrailMaterialProperty.js Прегледај датотеку

@@ -0,0 +1,50 @@
/**
* @Author: Caven
* @Date: 2020-06-22 16:46:14
*/

import MaterialProperty from '../../MaterialProperty'

const IMG = require('@dc-modules/images/fence.png')

const { Cesium } = DC.Namespace

class WallTrailMaterialProperty extends MaterialProperty {
constructor(options = {}) {
super(options)
this._image = undefined
this._imageSubscription = undefined
this.image = IMG
}

getType(time) {
return Cesium.Material.WallTrailType
}

getValue(time, result) {
if (!result) {
result = {}
}
result.color = Cesium.Property.getValueOrUndefined(this._color, time)
result.image = Cesium.Property.getValueOrUndefined(this._image, time)
result.speed = this._speed
return result
}

equals(other) {
return (
this === other ||
(other instanceof WallTrailMaterialProperty &&
Cesium.Property.equals(this._color, other._color) &&
Cesium.Property.equals(this._speed, other._speed))
)
}
}

Object.defineProperties(WallTrailMaterialProperty.prototype, {
color: Cesium.createPropertyDescriptor('color'),
speed: Cesium.createPropertyDescriptor('speed'),
image: Cesium.createPropertyDescriptor('image')
})

export default WallTrailMaterialProperty

+ 87
- 0
modules/material/property/water/WaterMaterialProperty.js Прегледај датотеку

@@ -0,0 +1,87 @@
/**
* @Author: Caven
* @Date: 2020-02-25 21:16:00
*/

const { Cesium } = DC.Namespace

class WaterMaterialProperty {
constructor(options) {
options = options || {}
this._definitionChanged = new Cesium.Event()
this._baseWaterColor = undefined
this._baseWaterColorSubscription = undefined
this.baseWaterColor =
options.baseWaterColor || new Cesium.Color(0.2, 0.3, 0.6, 1.0)
this._blendColor = undefined
this._blendColorSubscription = undefined
this.blendColor =
options.blendColor || new Cesium.Color(0.0, 1.0, 0.699, 1.0)
this._specularMap = undefined
this._specularMapSubscription = undefined
this.specularMap = options.specularMap || Cesium.Material.DefaultImageId
this._normalMap = undefined
this._normalMapSubscription = undefined
this.normalMap = options.normalMap || Cesium.Material.DefaultImageId
this.frequency = Cesium.defaultValue(options.frequency, 1000)
this.animationSpeed = Cesium.defaultValue(options.animationSpeed, 0.01)
this.amplitude = Cesium.defaultValue(options.amplitude, 10.0)
this.specularIntensity = Cesium.defaultValue(options.specularIntensity, 0.5)
}

get isConstant() {
return false
}

get definitionChanged() {
return this._definitionChanged
}

getType(time) {
return Cesium.Material.WaterType
}

getValue(time, result) {
if (!result) {
result = {}
}
result.baseWaterColor = Cesium.Property.getValueOrUndefined(
this._baseWaterColor,
time
)
result.blendColor = Cesium.Property.getValueOrUndefined(
this._blendColor,
time
)
result.specularMap = Cesium.Property.getValueOrUndefined(
this._specularMap,
time
)
result.normalMap = Cesium.Property.getValueOrUndefined(
this._normalMap,
time
)
result.frequency = this.frequency
result.animationSpeed = this.animationSpeed
result.amplitude = this.amplitude
result.specularIntensity = this.specularIntensity
return result
}

equals(other) {
return (
this === other ||
(other instanceof WaterMaterialProperty &&
Cesium.Property.equals(this._baseWaterColor, other._baseWaterColor))
)
}
}

Object.defineProperties(WaterMaterialProperty.prototype, {
baseWaterColor: Cesium.createPropertyDescriptor('baseWaterColor'),
blendColor: Cesium.createPropertyDescriptor('blendColor'),
specularMap: Cesium.createPropertyDescriptor('specularMap'),
normalMap: Cesium.createPropertyDescriptor('normalMap')
})

export default WaterMaterialProperty

+ 17
- 0
modules/material/shader/circle/CircleBlurMaterial.glsl Прегледај датотеку

@@ -0,0 +1,17 @@
uniform vec4 color;
uniform float speed;
czm_material czm_getMaterial(czm_materialInput materialInput){
czm_material material = czm_getDefaultMaterial(materialInput);
vec2 st = materialInput.st ;
vec2 center = vec2(0.5);
float time = fract(czm_frameNumber * speed / 1000.0);
float r = 0.5 + sin(time) / 3.0;
float dis = distance(st, center);
float a = 0.0;
if(dis < r) {
a = 1.0 - smoothstep(0.0, r, dis);
}
material.alpha = pow(a,10.0) ;
material.diffuse = color.rgb * a * 3.0;
return material;
}

+ 24
- 0
modules/material/shader/circle/CircleDiffuseMaterial.glsl Прегледај датотеку

@@ -0,0 +1,24 @@
uniform vec4 color;
uniform float speed;

vec3 circlePing(float r, float innerTail, float frontierBorder, float timeResetSeconds, float radarPingSpeed, float fadeDistance){
float t = fract(czm_frameNumber * speed / 1000.0);
float time = mod(t, timeResetSeconds) * radarPingSpeed;
float circle;
circle += smoothstep(time - innerTail, time, r) * smoothstep(time + frontierBorder,time, r);
circle *= smoothstep(fadeDistance, 0.0, r);
return vec3(circle);
}

czm_material czm_getMaterial(czm_materialInput materialInput){
czm_material material = czm_getDefaultMaterial(materialInput);
vec2 st = materialInput.st * 2.0 - 1.0 ;
vec2 center = vec2(0.);
float time = fract(czm_frameNumber * speed / 1000.0);
vec3 flagColor;
float r = length(st - center) / 4.;
flagColor += circlePing(r, 0.25, 0.025, 4.0, 0.3, 1.0) * color.rgb;
material.alpha = length(flagColor);
material.diffuse = flagColor.rgb;
return material;
}

+ 16
- 0
modules/material/shader/circle/CircleFadeMaterial.glsl Прегледај датотеку

@@ -0,0 +1,16 @@
uniform vec4 color;
uniform float speed;

czm_material czm_getMaterial(czm_materialInput materialInput){
czm_material material = czm_getDefaultMaterial(materialInput);
material.diffuse = 1.5 * color.rgb;
vec2 st = materialInput.st;
float dis = distance(st, vec2(0.5, 0.5));
float per = fract(czm_frameNumber * speed / 1000.0);
if(dis > per * 0.5){
material.alpha = color.a;
}else {
discard;
}
return material;
}

+ 16
- 0
modules/material/shader/circle/CirclePulseMaterial.glsl Прегледај датотеку

@@ -0,0 +1,16 @@
uniform vec4 color;
uniform float speed;
czm_material czm_getMaterial(czm_materialInput materialInput){
czm_material material = czm_getDefaultMaterial(materialInput);
vec2 st = materialInput.st * 2.0 - 1.0;
float time = fract(czm_frameNumber * speed / 1000.0);
float r = length(st) * 1.2;
float a = pow(r, 2.0);
float b = sin(r * 0.8 - 1.6);
float c = sin(r - 0.010);
float s = sin(a - time * 2.0 + b) * c;
float d = abs(1.0 / (s * 10.8)) - 0.01;
material.alpha = pow(d,10.0) ;
material.diffuse = color.rgb * d;
return material;
}

+ 26
- 0
modules/material/shader/circle/CircleScanMaterial.glsl Прегледај датотеку

@@ -0,0 +1,26 @@
uniform vec4 color;
uniform float speed;

float circle(vec2 uv, float r, float blur) {
float d = length(uv) * 2.0;
float c = smoothstep(r+blur, r, d);
return c;
}

czm_material czm_getMaterial(czm_materialInput materialInput)
{
czm_material material = czm_getDefaultMaterial(materialInput);
vec2 st = materialInput.st - .5;
material.diffuse = color.rgb;
material.emission = vec3(0);
float t =fract(czm_frameNumber * speed / 1000.0);
float s = 0.3;
float radius1 = smoothstep(.0, s, t) * 0.5;
float alpha1 = circle(st, radius1, 0.01) * circle(st, radius1, -0.01);
float alpha2 = circle(st, radius1, 0.01 - radius1) * circle(st, radius1, 0.01);
float radius2 = 0.5 + smoothstep(s, 1.0, t) * 0.5;
float alpha3 = circle(st, radius1, radius2 + 0.01 - radius1) * circle(st, radius1, -0.01);
material.alpha = smoothstep(1.0, s, t) * (alpha1 + alpha2*0.1 + alpha3*0.1);
material.alpha *= color.a;
return material;
}

+ 46
- 0
modules/material/shader/circle/CircleScanShader.glsl Прегледај датотеку

@@ -0,0 +1,46 @@
uniform sampler2D colorTexture;
uniform sampler2D depthTexture;
varying vec2 v_textureCoordinates;
uniform vec3 centerWC;
uniform vec3 normalWC;
uniform float radius;
uniform vec4 color;
uniform float speed;

float getDepth(){
float z_window = czm_unpackDepth(texture2D(depthTexture, v_textureCoordinates));
z_window = czm_reverseLogDepth(z_window);
float n_range = czm_depthRange.near;
float f_range = czm_depthRange.far;
return (2.0 * z_window - n_range - f_range) / (f_range - n_range);
}

vec4 toEye(in vec2 uv, in float depth){
vec2 xy = vec2((uv.x * 2.0 - 1.0),(uv.y * 2.0 - 1.0));
vec4 posInCamera =czm_inverseProjection * vec4(xy, depth, 1.0);
posInCamera = posInCamera / posInCamera.w;
return posInCamera;
}

vec3 pointProjectOnPlane(in vec3 planeNormal, in vec3 planeOrigin, in vec3 point){
vec3 v01 = point - planeOrigin;
float d = dot(planeNormal, v01) ;
return (point - planeNormal * d);
}

void main() {
gl_FragColor = texture2D(colorTexture, v_textureCoordinates);
float depth = getDepth();
vec4 viewPos = toEye(v_textureCoordinates, depth);
vec4 center = czm_view * vec4(centerWC,1);
vec4 planeNormal = czm_view * vec4(normalWC,0);
vec3 prjOnPlane = pointProjectOnPlane(planeNormal.xyz, center.xyz, viewPos.xyz);
float dis = length(prjOnPlane.xyz - center.xyz);
float time = fract(czm_frameNumber * speed / 1000.0);
float temp = radius * time;
if(dis < temp) {
float f = 1.0 - abs(temp - dis) / temp;
f = pow(f, 4.0);
gl_FragColor = mix(gl_FragColor, color, f);
}
}

+ 24
- 0
modules/material/shader/circle/CircleSpiralMaterial.glsl Прегледај датотеку

@@ -0,0 +1,24 @@
uniform vec4 color;
uniform float speed;

#define PI 3.14159265359

vec2 rotate2D (vec2 _st, float _angle) {
_st = mat2(cos(_angle),-sin(_angle), sin(_angle),cos(_angle)) * _st;
return _st;
}

czm_material czm_getMaterial(czm_materialInput materialInput){
czm_material material = czm_getDefaultMaterial(materialInput);
vec2 st = materialInput.st * 2.0 - 1.0;
st *= 1.6;
float time = czm_frameNumber * speed / 1000.0;
float r = length(st);
float w = .3;
st = rotate2D(st,(r*PI*6.-time*2.));
float a = smoothstep(-w,.2,st.x) * smoothstep(w,.2,st.x);
float b = abs(1./(sin(pow(r,2.)*2.-time*1.3)*6.))*.4;
material.alpha = a * b ;
material.diffuse = color.rgb * a * b * 3.0;
return material;
}

+ 18
- 0
modules/material/shader/circle/CircleVaryMaterial.glsl Прегледај датотеку

@@ -0,0 +1,18 @@
uniform vec4 color;
uniform float speed;

czm_material czm_getMaterial(czm_materialInput materialInput){
czm_material material = czm_getDefaultMaterial(materialInput);
vec2 st = materialInput.st * 2.0 - 1.0;
float time =czm_frameNumber * speed / 1000.0;
float radius = length(st);
float angle = atan(st.y/st.x);
float radius1 = sin(time * 2.0) + sin(40.0*angle+time)*0.01;
float radius2 = cos(time * 3.0);
vec3 fragColor = 0.2 + 0.5 * cos( time + color.rgb + vec3(0,2,4));
float inten1 = 1.0 - sqrt(abs(radius1 - radius));
float inten2 = 1.0 - sqrt(abs(radius2 - radius));
material.alpha = pow(inten1 + inten2 , 5.0) ;
material.diffuse = fragColor * (inten1 + inten2);
return material;
}

+ 48
- 0
modules/material/shader/circle/CircleWaveMaterial.glsl Прегледај датотеку

@@ -0,0 +1,48 @@
uniform vec4 color;
uniform float speed;
uniform float count;
uniform float gradient;

czm_material czm_getMaterial(czm_materialInput materialInput)
{
czm_material material = czm_getDefaultMaterial(materialInput);
material.diffuse = 1.5 * color.rgb;
vec2 st = materialInput.st;
float dis = distance(st, vec2(0.5, 0.5));
float per = fract(czm_frameNumber * speed / 1000.0);
if(count == 1.0){
if(dis > per * 0.5){
discard;
}else {
material.alpha = color.a * dis / per / 2.0;
}
} else {
vec3 str = materialInput.str;
if(abs(str.z) > 0.001){
discard;
}
if(dis > 0.5){
discard;
} else {
float perDis = 0.5 / count;
float disNum;
float bl = 0.0;
for(int i = 0; i <= 999; i++){
if(float(i) <= count){
disNum = perDis * float(i) - dis + per / count;
if(disNum > 0.0){
if(disNum < perDis){
bl = 1.0 - disNum / perDis;
}
else if(disNum - perDis < perDis){
bl = 1.0 - abs(1.0 - disNum / perDis);
}
material.alpha = pow(bl,(1.0 + 10.0 * (1.0 - gradient)));
}
}
}
}
}
return material;
}


+ 78
- 0
modules/material/shader/ellipsoid/EllipsoidElectricMaterial.glsl Прегледај датотеку

@@ -0,0 +1,78 @@
uniform vec4 color;
uniform float speed;

#define pi 3.1415926535
#define PI2RAD 0.01745329252
#define TWO_PI (2. * PI)

float rands(float p){
return fract(sin(p) * 10000.0);
}

float noise(vec2 p){
float time = fract( czm_frameNumber * speed / 1000.0);
float t = time / 20000.0;
if(t > 1.0) t -= floor(t);
return rands(p.x * 14. + p.y * sin(t) * 0.5);
}

vec2 sw(vec2 p){
return vec2(floor(p.x), floor(p.y));
}

vec2 se(vec2 p){
return vec2(ceil(p.x), floor(p.y));
}

vec2 nw(vec2 p){
return vec2(floor(p.x), ceil(p.y));
}

vec2 ne(vec2 p){
return vec2(ceil(p.x), ceil(p.y));
}

float smoothNoise(vec2 p){
vec2 inter = smoothstep(0.0, 1.0, fract(p));
float s = mix(noise(sw(p)), noise(se(p)), inter.x);
float n = mix(noise(nw(p)), noise(ne(p)), inter.x);
return mix(s, n, inter.y);
}

float fbm(vec2 p){
float z = 2.0;
float rz = 0.0;
vec2 bp = p;
for(float i = 1.0; i < 6.0; i++){
rz += abs((smoothNoise(p) - 0.5)* 2.0) / z;
z *= 2.0;
p *= 2.0;
}
return rz;
}

czm_material czm_getMaterial(czm_materialInput materialInput)
{
czm_material material = czm_getDefaultMaterial(materialInput);
vec2 st = materialInput.st;
vec2 st2 = materialInput.st;
float time = fract( czm_frameNumber * speed / 1000.0);
if (st.t < 0.5) {
discard;
}
st *= 4.;
float rz = fbm(st);
st /= exp(mod( time * 2.0, pi));
rz *= pow(15., 0.9);
vec4 temp = vec4(0);
temp = mix( color / rz, vec4(color.rgb, 0.1), 0.2);
if (st2.s < 0.05) {
temp = mix(vec4(color.rgb, 0.1), temp, st2.s / 0.05);
}
if (st2.s > 0.95){
temp = mix(temp, vec4(color.rgb, 0.1), (st2.s - 0.95) / 0.05);
}
material.diffuse = temp.rgb;
material.alpha = temp.a * 2.0;
return material;
}

+ 12
- 0
modules/material/shader/ellipsoid/EllipsoidTrailMaterial.glsl Прегледај датотеку

@@ -0,0 +1,12 @@
uniform vec4 color;
uniform float speed;
czm_material czm_getMaterial(czm_materialInput materialInput){
czm_material material = czm_getDefaultMaterial(materialInput);
vec2 st = materialInput.st;
float time = fract(czm_frameNumber * speed / 1000.0);
float alpha = abs(smoothstep(0.5,1.,fract( -st.t - time)));
alpha += .1;
material.alpha = alpha;
material.diffuse = color.rgb;
return material;
}

+ 11
- 0
modules/material/shader/polyline/PolylineEmissionMaterial.glsl Прегледај датотеку

@@ -0,0 +1,11 @@
uniform vec4 color;

czm_material czm_getMaterial(czm_materialInput materialInput){
czm_material material = czm_getDefaultMaterial(materialInput);
vec4 fragColor = color;
fragColor = czm_gammaCorrect(fragColor);
material.emission = fragColor.rgb;
material.diffuse = fragColor.rgb;
material.alpha = color.a;
return material;
}

+ 11
- 0
modules/material/shader/polyline/PolylineFlickerMaterial.glsl Прегледај датотеку

@@ -0,0 +1,11 @@
uniform vec4 color;
uniform float speed;
czm_material czm_getMaterial(czm_materialInput materialInput){
czm_material material = czm_getDefaultMaterial(materialInput);
float time = fract( czm_frameNumber * speed / 1000.0);
vec2 st = materialInput.st;
float scalar = smoothstep(0.0,1.0,time);
material.diffuse = color.rgb * scalar;
material.alpha = color.a * scalar ;
return material;
}

+ 16
- 0
modules/material/shader/polyline/PolylineFlowMaterial.glsl Прегледај датотеку

@@ -0,0 +1,16 @@
uniform vec4 color;
uniform float speed;
uniform float percent;
uniform float gradient;

czm_material czm_getMaterial(czm_materialInput materialInput){
czm_material material = czm_getDefaultMaterial(materialInput);
vec2 st = materialInput.st;
float t =fract(czm_frameNumber * speed / 1000.0);
t *= (1.0 + percent);
float alpha = smoothstep(t- percent, t, st.s) * step(-t, -st.s);
alpha += gradient;
material.diffuse = color.rgb;
material.alpha = alpha;
return material;
}

+ 19
- 0
modules/material/shader/polyline/PolylineImageTrailMaterial.glsl Прегледај датотеку

@@ -0,0 +1,19 @@
uniform sampler2D image;
uniform float speed;
uniform vec4 color;
uniform vec2 repeat;

czm_material czm_getMaterial(czm_materialInput materialInput){
czm_material material = czm_getDefaultMaterial(materialInput);
vec2 st = repeat * materialInput.st;
float time = fract(czm_frameNumber * speed / 1000.0);
vec4 colorImage = texture2D(image, vec2(fract(st.s - time), st.t));
if(color.a == 0.0){
material.alpha = colorImage.a;
material.diffuse = colorImage.rgb;
}else{
material.alpha = colorImage.a * color.a;
material.diffuse = max(color.rgb * material.alpha * 3.0, color.rgb);
}
return material;
}

+ 11
- 0
modules/material/shader/polyline/PolylineLightingMaterial.glsl Прегледај датотеку

@@ -0,0 +1,11 @@
uniform sampler2D image;
uniform vec4 color;
czm_material czm_getMaterial(czm_materialInput materialInput){
czm_material material = czm_getDefaultMaterial(materialInput);
vec2 st = materialInput.st;
vec4 colorImage = texture2D(image,st);
vec3 fragColor = color.rgb;
material.alpha = colorImage.a * color.a * 3.;
material.diffuse = max(fragColor.rgb + colorImage.rgb , fragColor.rgb);
return material;
}

+ 21
- 0
modules/material/shader/polyline/PolylineLightingTrailMaterial.glsl Прегледај датотеку

@@ -0,0 +1,21 @@
uniform sampler2D image;
uniform vec4 color;
uniform float speed;
czm_material czm_getMaterial(czm_materialInput materialInput){
czm_material material = czm_getDefaultMaterial(materialInput);
vec2 st = materialInput.st;
float time = fract(czm_frameNumber * speed / 1000.0);
vec4 colorImage = texture2D(image,st);
vec3 fragColor = color.rgb;
if(st.t > 0.45 && st.t < 0.55 ) {
fragColor = vec3(1.0);
}
if(color.a == 0.0){
material.alpha = colorImage.a * 1.5 * fract(st.s - time);
material.diffuse = colorImage.rgb;
}else{
material.alpha = colorImage.a * color.a * 1.5 * smoothstep(.0,1., fract(st.s - time));
material.diffuse = max(fragColor.rgb * material.alpha , fragColor.rgb);
}
return material;
}

+ 11
- 0
modules/material/shader/polyline/PolylineTrailMaterial.glsl Прегледај датотеку

@@ -0,0 +1,11 @@
uniform vec4 color;
uniform float speed;

czm_material czm_getMaterial(czm_materialInput materialInput){
czm_material material = czm_getDefaultMaterial(materialInput);
vec2 st = materialInput.st;
float time = fract(czm_frameNumber * speed / 1000.0);
material.diffuse = color.rgb;
material.alpha = color.a * fract(st.s-time);
return material;
}

+ 24
- 0
modules/material/shader/radar/RadarLineMaterial.glsl Прегледај датотеку

@@ -0,0 +1,24 @@
uniform vec4 color;
uniform float speed;

czm_material czm_getMaterial(czm_materialInput materialInput){
czm_material material = czm_getDefaultMaterial(materialInput);
vec2 st = materialInput.st * 2.0 - 1.0;
float t = czm_frameNumber * 10.0 / 1000.0 ;
vec3 col = vec3(0.0);
vec2 p = vec2(sin(t), cos(t));
float d = length(st - dot(p, st) * p);
if (dot(st, p) < 0.) {
d = length(st);
}

col = .006 / d * color.rgb;

if(distance(st,vec2(0)) > 0.99 ){
col =color.rgb;
}

material.alpha = pow(length(col),2.0);
material.diffuse = col * 3.0 ;
return material;
}

+ 70
- 0
modules/material/shader/radar/RadarScanShader.glsl Прегледај датотеку

@@ -0,0 +1,70 @@
uniform sampler2D colorTexture;
uniform sampler2D depthTexture;
varying vec2 v_textureCoordinates;
uniform vec3 centerWC;
uniform vec3 planeNormalWC;
uniform vec3 lineNormalWC;
uniform float radius;
uniform vec4 color;

float getDepth(){
float z_window = czm_unpackDepth(texture2D(depthTexture, v_textureCoordinates));
z_window = czm_reverseLogDepth(z_window);
float n_range = czm_depthRange.near;
float f_range = czm_depthRange.far;
return (2.0 * z_window - n_range - f_range) / (f_range - n_range);
}

vec4 toEye(in vec2 uv, in float depth){
vec2 xy = vec2((uv.x * 2.0 - 1.0),(uv.y * 2.0 - 1.0));
vec4 posInCamera =czm_inverseProjection * vec4(xy, depth, 1.0);
posInCamera = posInCamera / posInCamera.w;
return posInCamera;
}

bool isPointOnLineRight(in vec3 ptOnLine, in vec3 lineNormal, in vec3 testPt)
{
vec3 v01 = testPt - ptOnLine;
normalize(v01);
vec3 temp = cross(v01, lineNormal);
vec4 planeNormalEC = czm_view * vec4(planeNormalWC,0);
float d = dot(temp, planeNormalEC.xyz);
return d > 0.5;
}

vec3 pointProjectOnPlane(in vec3 planeNormal, in vec3 planeOrigin, in vec3 point)
{
vec3 v01 = point -planeOrigin;
float d = dot(planeNormal, v01) ;
return (point - planeNormal * d);
}

float distancePointToLine(in vec3 ptOnLine, in vec3 lineNormal, in vec3 testPt)
{
vec3 tempPt = pointProjectOnPlane(lineNormal, ptOnLine, testPt);
return length(tempPt - ptOnLine);
}

void main() {
gl_FragColor = texture2D(colorTexture, v_textureCoordinates);
float depth = getDepth();
vec4 viewPos = toEye(v_textureCoordinates, depth);
vec4 centerEC = czm_view * vec4(centerWC,1);
vec4 planeNormalEC = czm_view * vec4(planeNormalWC,0);
vec4 lineNormalEC = czm_view * vec4(lineNormalWC,0);
vec3 prjOnPlane = pointProjectOnPlane(planeNormalEC.xyz, centerEC.xyz, viewPos.xyz);
float dis = length(prjOnPlane.xyz - centerEC.xyz);
float diameter = radius * 2.0;
if(dis < radius){
float f0 = 1.0 -abs(radius - dis) / radius;
f0 = pow(f0, 64.0);
vec3 lineEndPt = vec3(centerEC.xyz) + vec3(lineNormalEC.xyz) * radius;
float f = 0.0;
if(isPointOnLineRight(centerEC.xyz, lineNormalEC.xyz, prjOnPlane.xyz)) {
float dis1= length(prjOnPlane.xyz - lineEndPt);
f = abs(diameter - dis1) / diameter;
f = pow(f, 3.0);
}
gl_FragColor = mix(gl_FragColor, color, f + f0);
}
}

+ 32
- 0
modules/material/shader/radar/RadarSweepMaterial.glsl Прегледај датотеку

@@ -0,0 +1,32 @@
uniform vec4 color;
uniform float speed;

#define PI 3.14159265359

czm_material czm_getMaterial(czm_materialInput materialInput){
czm_material material = czm_getDefaultMaterial(materialInput);
vec2 st = materialInput.st;
vec2 scrPt = st * 2.0 - 1.0;
float time = czm_frameNumber * speed / 1000.0 ;
vec3 col = vec3(0.0);
mat2 rot;
float theta = -time * 1.0 * PI - 2.2;
float cosTheta, sinTheta;
cosTheta = cos(theta);
sinTheta = sin(theta);
rot[0][0] = cosTheta;
rot[0][1] = -sinTheta;
rot[1][0] = sinTheta;
rot[1][1] = cosTheta;
vec2 scrPtRot = rot * scrPt;
float angle = 1.0 - (atan(scrPtRot.y, scrPtRot.x) / 6.2831 + 0.5);
float falloff = 1.0 - length(scrPtRot);
float ringSpacing = 0.23;
if(mod(length(scrPtRot), ringSpacing) < 0.015 && length(scrPtRot) / ringSpacing < 5.0) {
col += vec3(0, 0.5, 0);
}
col += vec3(0, 0.8, 0) * step(mod(length(scrPtRot), ringSpacing), 0.01) * step(length(scrPtRot), 1.0);
material.alpha =pow(length(col + vec3(.5)),5.0);
material.diffuse = (0.5 + pow(angle, 2.0) * falloff ) * color.rgb ;
return material;
}

+ 27
- 0
modules/material/shader/radar/RadarWaveMaterial.glsl Прегледај датотеку

@@ -0,0 +1,27 @@
uniform vec4 color;
uniform float speed;

#define PI 3.14159265359

float rand(vec2 co){
return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);
}

czm_material czm_getMaterial(czm_materialInput materialInput){
czm_material material = czm_getDefaultMaterial(materialInput);
vec2 st = materialInput.st;
vec2 pos = st - vec2(0.5);
float time = czm_frameNumber * speed / 1000.0 ;
float r = length(pos);
float t = atan(pos.y, pos.x) - time * 2.5;
float a = (atan(sin(t), cos(t)) + PI)/(2.0*PI);
float ta = 0.5;
float v = smoothstep(ta-0.05,ta+0.05,a) * smoothstep(ta+0.05,ta-0.05,a);
vec3 flagColor = color.rgb * v;
float blink = pow(sin(time*1.5)*0.5+0.5, 0.8);
flagColor = color.rgb * pow(a, 8.0*(.2+blink))*(sin(r*500.0)*.5+.5) ;
flagColor = flagColor * pow(r, 0.4);
material.alpha = length(flagColor) * 1.3;
material.diffuse = flagColor * 3.0;
return material;
}

+ 24
- 0
modules/material/shader/thirdpart/AsphaltMaterial.glsl Прегледај датотеку

@@ -0,0 +1,24 @@
uniform vec4 asphaltColor;
uniform float bumpSize;
uniform float roughness;

czm_material czm_getMaterial(czm_materialInput materialInput){
czm_material material = czm_getDefaultMaterial(materialInput);

// From Stefan Gustavson's Procedural Textures in GLSL in OpenGL Insights
//Main cellular pattern
vec4 color = asphaltColor;
vec2 st = materialInput.st;
vec2 F = czm_cellular(st / bumpSize);
color.rgb -= (F.x / F.y) * 0.1;

//Extra bumps for roughness
float noise = czm_snoise(st / bumpSize);
noise = pow(noise, 5.0) * roughness;
color.rgb += noise;

material.diffuse = color.rgb;
material.alpha = color.a;

return material;
}

+ 17
- 0
modules/material/shader/thirdpart/BlobMaterial.glsl Прегледај датотеку

@@ -0,0 +1,17 @@
uniform vec4 lightColor;
uniform vec4 darkColor;
uniform float frequency;

czm_material czm_getMaterial(czm_materialInput materialInput){
czm_material material = czm_getDefaultMaterial(materialInput);

// From Stefan Gustavson's Procedural Textures in GLSL in OpenGL Insights
vec2 F = czm_cellular(materialInput.st * frequency);
float t = 1.0 - F.x * F.x;

vec4 color = mix(lightColor, darkColor, t);
material.diffuse = color.rgb;
material.alpha = color.a;

return material;
}

+ 41
- 0
modules/material/shader/thirdpart/BrickMaterial.glsl Прегледај датотеку

@@ -0,0 +1,41 @@
uniform vec4 brickColor;
uniform vec4 mortarColor;
uniform vec2 brickSize;
uniform vec2 brickPct;
uniform float brickRoughness;
uniform float mortarRoughness;

#define Integral(x, p) ((floor(x) * p) + max(fract(x) - (1.0 - p), 0.0))

czm_material czm_getMaterial(czm_materialInput materialInput){
czm_material material = czm_getDefaultMaterial(materialInput);

// From OpenGL Shading Language (3rd edition) pg. 194, 501
vec2 st = materialInput.st;
vec2 position = st / brickSize;
if(fract(position.y * 0.5) > 0.5) {
position.x += 0.5;
}

//calculate whether to use brick or mortar (does AA)
vec2 filterWidth = vec2(0.02);
vec2 useBrick = (Integral(position + filterWidth, brickPct) -
Integral(position, brickPct)) / filterWidth;
float useBrickFinal = useBrick.x * useBrick.y;
vec4 color = mix(mortarColor, brickColor, useBrickFinal);

//Apply noise to brick
vec2 brickScaled = vec2(st.x / 0.1, st.y / 0.006);
float brickNoise = abs(czm_snoise(brickScaled) * brickRoughness / 5.0);
color.rg += brickNoise * useBrickFinal;

//Apply noise to mortar
vec2 mortarScaled = st / 0.005;
float mortarNoise = max(czm_snoise(mortarScaled) * mortarRoughness, 0.0);
color.rgb += mortarNoise * (1.0 - useBrickFinal);

material.diffuse = color.rgb;
material.alpha = color.a;

return material;
}

+ 18
- 0
modules/material/shader/thirdpart/CementMaterial.glsl Прегледај датотеку

@@ -0,0 +1,18 @@
uniform vec4 cementColor;
uniform float grainScale;
uniform float roughness;

czm_material czm_getMaterial(czm_materialInput materialInput){
czm_material material = czm_getDefaultMaterial(materialInput);

float noise = czm_snoise(materialInput.st / grainScale);
noise = pow(noise, 5.0) * roughness;

vec4 color = cementColor;
color.rgb += noise;

material.diffuse = color.rgb;
material.alpha = color.a;

return material;
}

+ 21
- 0
modules/material/shader/thirdpart/ErosionMaterial.glsl Прегледај датотеку

@@ -0,0 +1,21 @@
uniform vec4 color;
uniform float time;

czm_material czm_getMaterial(czm_materialInput materialInput){
czm_material material = czm_getDefaultMaterial(materialInput);
float alpha = 1.0;
if (time != 1.0)
{
float t = 0.5 + (0.5 * czm_snoise(materialInput.str / (1.0 / 10.0))); // Scale [-1, 1] to [0, 1]

if (t > time)
{
alpha = 0.0;
}
}

material.diffuse = color.rgb;
material.alpha = color.a * alpha;

return material;
}

+ 17
- 0
modules/material/shader/thirdpart/FacetMaterial.glsl Прегледај датотеку

@@ -0,0 +1,17 @@
uniform vec4 lightColor;
uniform vec4 darkColor;
uniform float frequency;

czm_material czm_getMaterial(czm_materialInput materialInput){
czm_material material = czm_getDefaultMaterial(materialInput);

// From Stefan Gustavson's Procedural Textures in GLSL in OpenGL Insights
vec2 F = czm_cellular(materialInput.st * frequency);
float t = 0.1 + (F.y - F.x);

vec4 color = mix(lightColor, darkColor, t);
material.diffuse = color.rgb;
material.alpha = color.a;

return material;
}

+ 11
- 0
modules/material/shader/thirdpart/FresnelMaterial.glsl Прегледај датотеку

@@ -0,0 +1,11 @@
czm_material czm_getMaterial(czm_materialInput materialInput){
czm_material material = czm_getDefaultMaterial(materialInput);

vec3 normalWC = normalize(czm_inverseViewRotation * material.normal);
vec3 positionWC = normalize(czm_inverseViewRotation * materialInput.positionToEyeEC);
float cosAngIncidence = max(dot(normalWC, positionWC), 0.0);

material.diffuse = mix(reflection.diffuse, refraction.diffuse, cosAngIncidence);

return material;
}

+ 27
- 0
modules/material/shader/thirdpart/GrassMaterial.glsl Прегледај датотеку

@@ -0,0 +1,27 @@
uniform vec4 grassColor;
uniform vec4 dirtColor;
uniform float patchiness;

czm_material czm_getMaterial(czm_materialInput materialInput){
czm_material material = czm_getDefaultMaterial(materialInput);

vec2 st = materialInput.st;
float noise1 = (czm_snoise(st * patchiness * 1.0)) * 1.0;
float noise2 = (czm_snoise(st * patchiness * 2.0)) * 0.5;
float noise3 = (czm_snoise(st * patchiness * 4.0)) * 0.25;
float noise = sin(noise1 + noise2 + noise3) * 0.1;

vec4 color = mix(grassColor, dirtColor, noise);

//Make thatch patterns
float verticalNoise = czm_snoise(vec2(st.x * 100.0, st.y * 20.0)) * 0.02;
float horizontalNoise = czm_snoise(vec2(st.x * 20.0, st.y * 100.0)) * 0.02;
float stripeNoise = min(verticalNoise, horizontalNoise);

color.rgb += stripeNoise;

material.diffuse = color.rgb;
material.alpha = color.a;

return material;
}

+ 12
- 0
modules/material/shader/thirdpart/ReflectionMaterial.glsl Прегледај датотеку

@@ -0,0 +1,12 @@
uniform samplerCube cubeMap;

czm_material czm_getMaterial(czm_materialInput materialInput){
czm_material material = czm_getDefaultMaterial(materialInput);

vec3 normalWC = normalize(czm_inverseViewRotation * material.normal);
vec3 positionWC = normalize(czm_inverseViewRotation * materialInput.positionToEyeEC);
vec3 reflectedWC = reflect(positionWC, normalWC);
material.diffuse = textureCube(cubeMap, reflectedWC).channels;

return material;
}

+ 13
- 0
modules/material/shader/thirdpart/RefractionMaterial.glsl Прегледај датотеку

@@ -0,0 +1,13 @@
uniform samplerCube cubeMap;
uniform float indexOfRefractionRatio;

czm_material czm_getMaterial(czm_materialInput materialInput){
czm_material material = czm_getDefaultMaterial(materialInput);

vec3 normalWC = normalize(czm_inverseViewRotation * material.normal);
vec3 positionWC = normalize(czm_inverseViewRotation * materialInput.positionToEyeEC);
vec3 refractedWC = refract(positionWC, -normalWC, indexOfRefractionRatio);
material.diffuse = textureCube(cubeMap, refractedWC).channels;

return material;
}

+ 16
- 0
modules/material/shader/thirdpart/TieDyeMaterial.glsl Прегледај датотеку

@@ -0,0 +1,16 @@
uniform vec4 lightColor;
uniform vec4 darkColor;
uniform float frequency;

czm_material czm_getMaterial(czm_materialInput materialInput){
czm_material material = czm_getDefaultMaterial(materialInput);

vec3 scaled = materialInput.str * frequency;
float t = abs(czm_snoise(scaled));

vec4 color = mix(lightColor, darkColor, t);
material.diffuse = color.rgb;
material.alpha = color.a;

return material;
}

+ 35
- 0
modules/material/shader/thirdpart/WoodMaterial.glsl Прегледај датотеку

@@ -0,0 +1,35 @@
uniform vec4 lightWoodColor;
uniform vec4 darkWoodColor;
uniform float ringFrequency;
uniform vec2 noiseScale;
uniform float grainFrequency;

czm_material czm_getMaterial(czm_materialInput materialInput){
czm_material material = czm_getDefaultMaterial(materialInput);

//Based on wood shader from OpenGL Shading Language (3rd edition) pg. 455
vec2 st = materialInput.st;

vec2 noisevec;
noisevec.x = czm_snoise(st * noiseScale.x);
noisevec.y = czm_snoise(st * noiseScale.y);

vec2 location = st + noisevec;
float dist = sqrt(location.x * location.x + location.y * location.y);
dist *= ringFrequency;

float r = fract(dist + noisevec[0] + noisevec[1]) * 2.0;
if(r > 1.0)
r = 2.0 - r;

vec4 color = mix(lightWoodColor, darkWoodColor, r);

//streaks
r = abs(czm_snoise(vec2(st.x * grainFrequency, st.y * grainFrequency * 0.02))) * 0.2;
color.rgb += lightWoodColor.rgb * r;

material.diffuse = color.rgb;
material.alpha = color.a;

return material;
}

+ 77
- 0
modules/material/shader/thirdpart/cellular.glsl Прегледај датотеку

@@ -0,0 +1,77 @@
/**
* @license
* Cellular noise ("Worley noise") in 2D in GLSL.
* Copyright (c) Stefan Gustavson 2011-04-19. All rights reserved.
* This code is released under the conditions of the MIT license.
* See LICENSE file for details.
*/

//#ifdef GL_OES_standard_derivatives
// #extension GL_OES_standard_derivatives : enable
//#endif
//
//float aastep (float threshold , float value)
//{
// float afwidth = 0.7 * length ( vec2 ( dFdx ( value ), dFdy ( value )));
// return smoothstep ( threshold - afwidth , threshold + afwidth , value );
//}

// Permutation polynomial: (34x^2 + x) mod 289
vec3 _czm_permute289(vec3 x)
{
return mod((34.0 * x + 1.0) * x, 289.0);
}

/**
* DOC_TBA
*
* Implemented by Stefan Gustavson, and distributed under the MIT License. {@link http://openglinsights.git.sourceforge.net/git/gitweb.cgi?p=openglinsights/openglinsights;a=tree;f=proceduraltextures}
*
* @name czm_cellular
* @glslFunction
*
* @see Stefan Gustavson's chapter, <i>Procedural Textures in GLSL</i>, in <a href="http://www.openglinsights.com/">OpenGL Insights</a>.
*/
vec2 czm_cellular(vec2 P)
// Cellular noise, returning F1 and F2 in a vec2.
// Standard 3x3 search window for good F1 and F2 values
{
#define K 0.142857142857 // 1/7
#define Ko 0.428571428571 // 3/7
#define jitter 1.0 // Less gives more regular pattern
vec2 Pi = mod(floor(P), 289.0);
vec2 Pf = fract(P);
vec3 oi = vec3(-1.0, 0.0, 1.0);
vec3 of = vec3(-0.5, 0.5, 1.5);
vec3 px = _czm_permute289(Pi.x + oi);
vec3 p = _czm_permute289(px.x + Pi.y + oi); // p11, p12, p13
vec3 ox = fract(p*K) - Ko;
vec3 oy = mod(floor(p*K),7.0)*K - Ko;
vec3 dx = Pf.x + 0.5 + jitter*ox;
vec3 dy = Pf.y - of + jitter*oy;
vec3 d1 = dx * dx + dy * dy; // d11, d12 and d13, squared
p = _czm_permute289(px.y + Pi.y + oi); // p21, p22, p23
ox = fract(p*K) - Ko;
oy = mod(floor(p*K),7.0)*K - Ko;
dx = Pf.x - 0.5 + jitter*ox;
dy = Pf.y - of + jitter*oy;
vec3 d2 = dx * dx + dy * dy; // d21, d22 and d23, squared
p = _czm_permute289(px.z + Pi.y + oi); // p31, p32, p33
ox = fract(p*K) - Ko;
oy = mod(floor(p*K),7.0)*K - Ko;
dx = Pf.x - 1.5 + jitter*ox;
dy = Pf.y - of + jitter*oy;
vec3 d3 = dx * dx + dy * dy; // d31, d32 and d33, squared
// Sort out the two smallest distances (F1, F2)
vec3 d1a = min(d1, d2);
d2 = max(d1, d2); // Swap to keep candidates for F2
d2 = min(d2, d3); // neither F1 nor F2 are now in d3
d1 = min(d1a, d2); // F1 is now in d1
d2 = max(d1a, d2); // Swap to keep candidates for F2
d1.xy = (d1.x < d1.y) ? d1.xy : d1.yx; // Swap if smaller
d1.xz = (d1.x < d1.z) ? d1.xz : d1.zx; // F1 is in d1.x
d1.yz = min(d1.yz, d2.yz); // F2 is now not in d2.yz
d1.y = min(d1.y, d1.z); // nor in d1.z
d1.y = min(d1.y, d2.x); // F2 is in d1.y, we're done.
return sqrt(d1.xy);
}

+ 282
- 0
modules/material/shader/thirdpart/snoise.glsl Прегледај датотеку

@@ -0,0 +1,282 @@
/**
* @license
* Description : Array and textureless GLSL 2D/3D/4D simplex
* noise functions.
* Author : Ian McEwan, Ashima Arts.
* Maintainer : ijm
* Lastmod : 20110822 (ijm)
* License : Copyright (C) 2011 Ashima Arts. All rights reserved.
* Distributed under the MIT License. See LICENSE file.
* https://github.com/ashima/webgl-noise
*/

vec4 _czm_mod289(vec4 x)
{
return x - floor(x * (1.0 / 289.0)) * 289.0;
}

vec3 _czm_mod289(vec3 x)
{
return x - floor(x * (1.0 / 289.0)) * 289.0;
}

vec2 _czm_mod289(vec2 x)
{
return x - floor(x * (1.0 / 289.0)) * 289.0;
}

float _czm_mod289(float x)
{
return x - floor(x * (1.0 / 289.0)) * 289.0;
}

vec4 _czm_permute(vec4 x)
{
return _czm_mod289(((x*34.0)+1.0)*x);
}

vec3 _czm_permute(vec3 x)
{
return _czm_mod289(((x*34.0)+1.0)*x);
}

float _czm_permute(float x)
{
return _czm_mod289(((x*34.0)+1.0)*x);
}

vec4 _czm_taylorInvSqrt(vec4 r)
{
return 1.79284291400159 - 0.85373472095314 * r;
}

float _czm_taylorInvSqrt(float r)
{
return 1.79284291400159 - 0.85373472095314 * r;
}

vec4 _czm_grad4(float j, vec4 ip)
{
const vec4 ones = vec4(1.0, 1.0, 1.0, -1.0);
vec4 p,s;

p.xyz = floor( fract (vec3(j) * ip.xyz) * 7.0) * ip.z - 1.0;
p.w = 1.5 - dot(abs(p.xyz), ones.xyz);
s = vec4(lessThan(p, vec4(0.0)));
p.xyz = p.xyz + (s.xyz*2.0 - 1.0) * s.www;

return p;
}

/**
* DOC_TBA
*
* Implemented by Ian McEwan, Ashima Arts, and distributed under the MIT License. {@link https://github.com/ashima/webgl-noise}
*
* @name czm_snoise
* @glslFunction
*
* @see <a href="https://github.com/ashima/webgl-noise">https://github.com/ashima/webgl-noise</a>
* @see Stefan Gustavson's paper <a href="http://www.itn.liu.se/~stegu/simplexnoise/simplexnoise.pdf">Simplex noise demystified</a>
*/
float czm_snoise(vec2 v)
{
const vec4 C = vec4(0.211324865405187, // (3.0-sqrt(3.0))/6.0
0.366025403784439, // 0.5*(sqrt(3.0)-1.0)
-0.577350269189626, // -1.0 + 2.0 * C.x
0.024390243902439); // 1.0 / 41.0
// First corner
vec2 i = floor(v + dot(v, C.yy) );
vec2 x0 = v - i + dot(i, C.xx);

// Other corners
vec2 i1;
//i1.x = step( x0.y, x0.x ); // x0.x > x0.y ? 1.0 : 0.0
//i1.y = 1.0 - i1.x;
i1 = (x0.x > x0.y) ? vec2(1.0, 0.0) : vec2(0.0, 1.0);
// x0 = x0 - 0.0 + 0.0 * C.xx ;
// x1 = x0 - i1 + 1.0 * C.xx ;
// x2 = x0 - 1.0 + 2.0 * C.xx ;
vec4 x12 = x0.xyxy + C.xxzz;
x12.xy -= i1;

// Permutations
i = _czm_mod289(i); // Avoid truncation effect in permutation
vec3 p = _czm_permute( _czm_permute( i.y + vec3(0.0, i1.y, 1.0 )) + i.x + vec3(0.0, i1.x, 1.0 ));

vec3 m = max(0.5 - vec3(dot(x0,x0), dot(x12.xy,x12.xy), dot(x12.zw,x12.zw)), 0.0);
m = m*m ;
m = m*m ;

// Gradients: 41 points uniformly over a line, mapped onto a diamond.
// The ring size 17*17 = 289 is close to a multiple of 41 (41*7 = 287)
vec3 x = 2.0 * fract(p * C.www) - 1.0;
vec3 h = abs(x) - 0.5;
vec3 ox = floor(x + 0.5);
vec3 a0 = x - ox;

// Normalise gradients implicitly by scaling m
// Approximation of: m *= inversesqrt( a0*a0 + h*h );
m *= 1.79284291400159 - 0.85373472095314 * ( a0*a0 + h*h );

// Compute final noise value at P
vec3 g;
g.x = a0.x * x0.x + h.x * x0.y;
g.yz = a0.yz * x12.xz + h.yz * x12.yw;
return 130.0 * dot(m, g);
}

float czm_snoise(vec3 v)
{
const vec2 C = vec2(1.0/6.0, 1.0/3.0) ;
const vec4 D = vec4(0.0, 0.5, 1.0, 2.0);

// First corner
vec3 i = floor(v + dot(v, C.yyy) );
vec3 x0 = v - i + dot(i, C.xxx) ;

// Other corners
vec3 g = step(x0.yzx, x0.xyz);
vec3 l = 1.0 - g;
vec3 i1 = min( g.xyz, l.zxy );
vec3 i2 = max( g.xyz, l.zxy );

// x0 = x0 - 0.0 + 0.0 * C.xxx;
// x1 = x0 - i1 + 1.0 * C.xxx;
// x2 = x0 - i2 + 2.0 * C.xxx;
// x3 = x0 - 1.0 + 3.0 * C.xxx;
vec3 x1 = x0 - i1 + C.xxx;
vec3 x2 = x0 - i2 + C.yyy; // 2.0*C.x = 1/3 = C.y
vec3 x3 = x0 - D.yyy; // -1.0+3.0*C.x = -0.5 = -D.y

// Permutations
i = _czm_mod289(i);
vec4 p = _czm_permute( _czm_permute( _czm_permute(
i.z + vec4(0.0, i1.z, i2.z, 1.0 ))
+ i.y + vec4(0.0, i1.y, i2.y, 1.0 ))
+ i.x + vec4(0.0, i1.x, i2.x, 1.0 ));

// Gradients: 7x7 points over a square, mapped onto an octahedron.
// The ring size 17*17 = 289 is close to a multiple of 49 (49*6 = 294)
float n_ = 0.142857142857; // 1.0/7.0
vec3 ns = n_ * D.wyz - D.xzx;

vec4 j = p - 49.0 * floor(p * ns.z * ns.z); // mod(p,7*7)

vec4 x_ = floor(j * ns.z);
vec4 y_ = floor(j - 7.0 * x_ ); // mod(j,N)

vec4 x = x_ *ns.x + ns.yyyy;
vec4 y = y_ *ns.x + ns.yyyy;
vec4 h = 1.0 - abs(x) - abs(y);

vec4 b0 = vec4( x.xy, y.xy );
vec4 b1 = vec4( x.zw, y.zw );

//vec4 s0 = vec4(lessThan(b0,0.0))*2.0 - 1.0;
//vec4 s1 = vec4(lessThan(b1,0.0))*2.0 - 1.0;
vec4 s0 = floor(b0)*2.0 + 1.0;
vec4 s1 = floor(b1)*2.0 + 1.0;
vec4 sh = -step(h, vec4(0.0));

vec4 a0 = b0.xzyw + s0.xzyw*sh.xxyy ;
vec4 a1 = b1.xzyw + s1.xzyw*sh.zzww ;

vec3 p0 = vec3(a0.xy,h.x);
vec3 p1 = vec3(a0.zw,h.y);
vec3 p2 = vec3(a1.xy,h.z);
vec3 p3 = vec3(a1.zw,h.w);

//Normalise gradients
vec4 norm = _czm_taylorInvSqrt(vec4(dot(p0,p0), dot(p1,p1), dot(p2, p2), dot(p3,p3)));
p0 *= norm.x;
p1 *= norm.y;
p2 *= norm.z;
p3 *= norm.w;

// Mix final noise value
vec4 m = max(0.6 - vec4(dot(x0,x0), dot(x1,x1), dot(x2,x2), dot(x3,x3)), 0.0);
m = m * m;
return 42.0 * dot( m*m, vec4( dot(p0,x0), dot(p1,x1),
dot(p2,x2), dot(p3,x3) ) );
}

float czm_snoise(vec4 v)
{
const vec4 C = vec4( 0.138196601125011, // (5 - sqrt(5))/20 G4
0.276393202250021, // 2 * G4
0.414589803375032, // 3 * G4
-0.447213595499958); // -1 + 4 * G4

// (sqrt(5) - 1)/4 = F4, used once below
#define F4 0.309016994374947451

// First corner
vec4 i = floor(v + dot(v, vec4(F4)) );
vec4 x0 = v - i + dot(i, C.xxxx);

// Other corners

// Rank sorting originally contributed by Bill Licea-Kane, AMD (formerly ATI)
vec4 i0;
vec3 isX = step( x0.yzw, x0.xxx );
vec3 isYZ = step( x0.zww, x0.yyz );
// i0.x = dot( isX, vec3( 1.0 ) );
i0.x = isX.x + isX.y + isX.z;
i0.yzw = 1.0 - isX;
// i0.y += dot( isYZ.xy, vec2( 1.0 ) );
i0.y += isYZ.x + isYZ.y;
i0.zw += 1.0 - isYZ.xy;
i0.z += isYZ.z;
i0.w += 1.0 - isYZ.z;

// i0 now contains the unique values 0,1,2,3 in each channel
vec4 i3 = clamp( i0, 0.0, 1.0 );
vec4 i2 = clamp( i0-1.0, 0.0, 1.0 );
vec4 i1 = clamp( i0-2.0, 0.0, 1.0 );

// x0 = x0 - 0.0 + 0.0 * C.xxxx
// x1 = x0 - i1 + 1.0 * C.xxxx
// x2 = x0 - i2 + 2.0 * C.xxxx
// x3 = x0 - i3 + 3.0 * C.xxxx
// x4 = x0 - 1.0 + 4.0 * C.xxxx
vec4 x1 = x0 - i1 + C.xxxx;
vec4 x2 = x0 - i2 + C.yyyy;
vec4 x3 = x0 - i3 + C.zzzz;
vec4 x4 = x0 + C.wwww;

// Permutations
i = _czm_mod289(i);
float j0 = _czm_permute( _czm_permute( _czm_permute( _czm_permute(i.w) + i.z) + i.y) + i.x);
vec4 j1 = _czm_permute( _czm_permute( _czm_permute( _czm_permute (
i.w + vec4(i1.w, i2.w, i3.w, 1.0 ))
+ i.z + vec4(i1.z, i2.z, i3.z, 1.0 ))
+ i.y + vec4(i1.y, i2.y, i3.y, 1.0 ))
+ i.x + vec4(i1.x, i2.x, i3.x, 1.0 ));

// Gradients: 7x7x6 points over a cube, mapped onto a 4-cross polytope
// 7*7*6 = 294, which is close to the ring size 17*17 = 289.
vec4 ip = vec4(1.0/294.0, 1.0/49.0, 1.0/7.0, 0.0) ;

vec4 p0 = _czm_grad4(j0, ip);
vec4 p1 = _czm_grad4(j1.x, ip);
vec4 p2 = _czm_grad4(j1.y, ip);
vec4 p3 = _czm_grad4(j1.z, ip);
vec4 p4 = _czm_grad4(j1.w, ip);

// Normalise gradients
vec4 norm = _czm_taylorInvSqrt(vec4(dot(p0,p0), dot(p1,p1), dot(p2, p2), dot(p3,p3)));
p0 *= norm.x;
p1 *= norm.y;
p2 *= norm.z;
p3 *= norm.w;
p4 *= _czm_taylorInvSqrt(dot(p4,p4));

// Mix contributions from the five corners
vec3 m0 = max(0.6 - vec3(dot(x0,x0), dot(x1,x1), dot(x2,x2)), 0.0);
vec2 m1 = max(0.6 - vec2(dot(x3,x3), dot(x4,x4) ), 0.0);
m0 = m0 * m0;
m1 = m1 * m1;
return 49.0 * ( dot(m0*m0, vec3( dot( p0, x0 ), dot( p1, x1 ), dot( p2, x2 )))
+ dot(m1*m1, vec2( dot( p3, x3 ), dot( p4, x4 ) ) ) ) ;
}

+ 13
- 0
modules/material/shader/wall/WallImageTrailMaterial.glsl Прегледај датотеку

@@ -0,0 +1,13 @@
uniform sampler2D image;
uniform vec4 color;
uniform float speed;
uniform vec2 repeat;
czm_material czm_getMaterial(czm_materialInput materialInput){
czm_material material = czm_getDefaultMaterial(materialInput);
vec2 st = materialInput.st * repeat;
float time = fract(czm_frameNumber * speed / 1000.0);
vec4 colorImage = texture2D(image, vec2(fract(st.s - time), st.t));
material.alpha = colorImage.a * color.a ;
material.diffuse = colorImage.rgb * color.rgb * 3.0 ;
return material;
}

+ 16
- 0
modules/material/shader/wall/WallLineTrailMaterial.glsl Прегледај датотеку

@@ -0,0 +1,16 @@
uniform sampler2D image;
uniform float speed;
uniform vec4 color;
uniform vec2 repeat;

czm_material czm_getMaterial(czm_materialInput materialInput){
czm_material material = czm_getDefaultMaterial(materialInput);
float perDis = 1.0 / repeat.y / 3.0 ;
vec2 st = materialInput.st * repeat;
float time = fract(czm_frameNumber * speed / 1000.0);
vec4 colorImage = texture2D(image, vec2(st.s, fract(st.t - time)));
material.alpha = colorImage.a * smoothstep(.2 ,1. ,distance(st.t * perDis ,1. + perDis ));
material.diffuse = max(color.rgb * material.alpha * 1.5, color.rgb);
material.emission = max(color.rgb * material.alpha * 1.5, color.rgb);
return material;
}

+ 25
- 0
modules/material/shader/wall/WallRippleMaterial.glsl Прегледај датотеку

@@ -0,0 +1,25 @@
uniform vec4 color;
uniform float speed;
uniform float count;
czm_material czm_getMaterial(czm_materialInput materialInput)
{
czm_material material = czm_getDefaultMaterial(materialInput);
vec2 st = materialInput.st;
float time = fract(czm_frameNumber * speed / 1000.0);
float sin = sin((st.t - time) * 10.0 * count);
float high = 0.92;
float medium = 0.4;
vec4 temp= vec4(0.);
if(sin > high ){
temp = vec4(mix(vec3(.8, 1., 1.), color.rgb, (1. - sin) / (1. - high)), 1.);
}else if(sin > medium) {
temp = vec4(color.rgb, mix(1., 0., 1.-(sin - medium) / (high - medium)));
}else{
temp = vec4(color.rgb,0);
}
vec3 fade = mix(color.rgb, vec3(0., 0., 0.), st.t);
temp = mix(temp, vec4(fade, 1.), 0.85);
material.diffuse = temp.rgb;
material.alpha = temp.a * (1.0 - st.t);
return material;
}

+ 18
- 0
modules/material/shader/wall/WallTrailMaterial.glsl Прегледај датотеку

@@ -0,0 +1,18 @@
uniform sampler2D image;
uniform float speed;
uniform vec4 color;

czm_material czm_getMaterial(czm_materialInput materialInput){
czm_material material = czm_getDefaultMaterial(materialInput);
vec2 st = materialInput.st;
float time = fract(czm_frameNumber * speed / 1000.0);
vec4 colorImage = texture2D(image, vec2(fract(st.t - time), st.t));
if(color.a == 0.0){
material.alpha = colorImage.a;
material.diffuse = colorImage.rgb;
}else{
material.alpha = colorImage.a * color.a;
material.diffuse = max(color.rgb * material.alpha * 3.0, color.rgb);
}
return material;
}

+ 36
- 0
modules/material/shader/weather/FogShader.glsl Прегледај датотеку

@@ -0,0 +1,36 @@
uniform sampler2D colorTexture;
uniform sampler2D depthTexture;
uniform vec4 fogByDistance;
uniform vec4 fogColor;
varying vec2 v_textureCoordinates;

float getDistance(sampler2D depthTexture, vec2 texCoords){
float depth = czm_unpackDepth(texture2D(depthTexture, texCoords));
if (depth == 0.0) {
return czm_infinity;
}
vec4 eyeCoordinate = czm_windowToEyeCoordinates(gl_FragCoord.xy, depth);
return -eyeCoordinate.z / eyeCoordinate.w;
}


float interpolateByDistance(vec4 nearFarScalar, float distance){
float startDistance = nearFarScalar.x;
float startValue = nearFarScalar.y;
float endDistance = nearFarScalar.z;
float endValue = nearFarScalar.w;
float t = clamp((distance - startDistance) / (endDistance - startDistance), 0.0, 1.0);
return mix(startValue, endValue, t);
}

vec4 alphaBlend(vec4 sourceColor, vec4 destinationColor){
return sourceColor * vec4(sourceColor.aaa, 1.0) + destinationColor * (1.0 - sourceColor.a);
}

void main(void){
float distance = getDistance(depthTexture, v_textureCoordinates);
vec4 sceneColor = texture2D(colorTexture, v_textureCoordinates);
float blendAmount = interpolateByDistance(fogByDistance, distance);
vec4 finalFogColor = vec4(fogColor.rgb, fogColor.a * blendAmount);
gl_FragColor = alphaBlend(finalFogColor, sceneColor);
}

+ 22
- 0
modules/material/shader/weather/RainShader.glsl Прегледај датотеку

@@ -0,0 +1,22 @@
uniform sampler2D colorTexture;
varying vec2 v_textureCoordinates;
uniform float speed;

float hash(float x){
return fract(sin(x*23.3)*13.13);
}

void main(){
float time = czm_frameNumber * speed / 1000.0;
vec2 resolution = czm_viewport.zw;
vec2 uv=(gl_FragCoord.xy*2.-resolution.xy)/min(resolution.x,resolution.y);
vec3 c=vec3(.1,.2,.3);
float a=-.3;
float si=sin(a),co=cos(a);
uv*=mat2(co,-si,si,co);
uv*=length(uv+vec2(0,4.9))*.3+1.;
float v=1.-sin(hash(floor(uv.x*100.))*2.);
float b=clamp(abs(sin(20.*time*v+uv.y*(5./(2.+v))))-.95,0.,1.)*10.;
c*=v*b;
gl_FragColor = mix(texture2D(colorTexture, v_textureCoordinates), vec4(c,1), 0.5);
}

+ 33
- 0
modules/material/shader/weather/SnowShader.glsl Прегледај датотеку

@@ -0,0 +1,33 @@
uniform sampler2D colorTexture;
varying vec2 v_textureCoordinates;
uniform float speed;

float snow(vec2 uv,float scale){
float time = czm_frameNumber * speed / 1000.0 ;
float w=smoothstep(1.,0.,-uv.y*(scale/10.));
if(w<.1)return 0.;
uv+=time/scale;
uv.y+=time*2./scale;
uv.x+=sin(uv.y+time*.5)/scale;
uv*=scale;
vec2 s=floor(uv),f=fract(uv),p;
float k=3.,d;
p=.5+.35*sin(11.*fract(sin((s+p+scale)*mat2(7,3,6,5))*5.))-f;
d=length(p);
k=min(d,k);
k=smoothstep(0.,k,sin(f.x+f.y)*0.01);
return k*w;
}

void main(){
vec2 resolution = czm_viewport.zw;
vec2 uv=(gl_FragCoord.xy*2.-resolution.xy)/min(resolution.x,resolution.y);
vec3 finalColor=vec3(0);
float c = 0.0;
c+=snow(uv,10.);
c+=snow(uv,8.);
c+=snow(uv,6.);
c+=snow(uv,5.);
finalColor=(vec3(c));
gl_FragColor = mix(texture2D(colorTexture, v_textureCoordinates), vec4(finalColor,1), 0.3);
}

+ 169
- 0
modules/material/type/circle.js Прегледај датотеку

@@ -0,0 +1,169 @@
/**
* @Author: Caven
* @Date: 2021-02-27 22:49:41
*/

const { Cesium } = DC.Namespace

const CircleBlurMaterial = require('../shader/circle/CircleBlurMaterial.glsl')
const CircleDiffuseMaterial = require('../shader/circle/CircleDiffuseMaterial.glsl')
const CircleFadeMaterial = require('../shader/circle/CircleFadeMaterial.glsl')
const CirclePulseMaterial = require('../shader/circle/CirclePulseMaterial.glsl')
const CircleScanMaterial = require('../shader/circle/CircleScanMaterial.glsl')
const CircleSpiralMaterial = require('../shader/circle/CircleSpiralMaterial.glsl')
const CircleVaryMaterial = require('../shader/circle/CircleVaryMaterial.glsl')
const CircleWaveMaterial = require('../shader/circle/CircleWaveMaterial.glsl')

/**
* CircleBlur
* @type {string}
*/
Cesium.Material.CircleBlurType = 'CircleBlur'
Cesium.Material._materialCache.addMaterial(Cesium.Material.CircleBlurType, {
fabric: {
type: Cesium.Material.CircleBlurType,
uniforms: {
color: new Cesium.Color(1.0, 0.0, 0.0, 0.7),
speed: 3.0
},
source: CircleBlurMaterial
},
translucent: function(material) {
return true
}
})

/**
* CircleDiffuse
* @type {string}
*/
Cesium.Material.CircleDiffuseType = 'CircleDiffuse'
Cesium.Material._materialCache.addMaterial(Cesium.Material.CircleDiffuseType, {
fabric: {
type: Cesium.Material.CircleDiffuseType,
uniforms: {
color: new Cesium.Color(1.0, 0.0, 0.0, 0.7),
speed: 3.0
},
source: CircleDiffuseMaterial
},
translucent: function(material) {
return true
}
})

/**
* CircleFade
* @type {string}
*/
Cesium.Material.CircleFadeType = 'CircleFade'
Cesium.Material._materialCache.addMaterial(Cesium.Material.CircleFadeType, {
fabric: {
type: Cesium.Material.CircleFadeType,
uniforms: {
color: new Cesium.Color(1.0, 0.0, 0.0, 0.7),
speed: 3.0
},
source: CircleFadeMaterial
},
translucent: function(material) {
return true
}
})

/**
* CirclePulse
* @type {string}
*/
Cesium.Material.CirclePulseType = 'CirclePulse'
Cesium.Material._materialCache.addMaterial(Cesium.Material.CirclePulseType, {
fabric: {
type: Cesium.Material.CirclePulseType,
uniforms: {
color: new Cesium.Color(1.0, 0.0, 0.0, 0.7),
speed: 12.0
},
source: CirclePulseMaterial
},
translucent: function(material) {
return true
}
})

/**
* CircleScan
* @type {string}
*/
Cesium.Material.CircleScanType = 'CircleScan'
Cesium.Material._materialCache.addMaterial(Cesium.Material.CircleScanType, {
fabric: {
type: Cesium.Material.CircleScanType,
uniforms: {
color: new Cesium.Color(1.0, 0.0, 0.0, 0.7),
speed: 1
},
source: CircleScanMaterial
},
translucent: function(material) {
return true
}
})

/**
* CircleSpiral
* @type {string}
*/
Cesium.Material.CircleSpiralType = 'CircleSpiral'
Cesium.Material._materialCache.addMaterial(Cesium.Material.CircleSpiralType, {
fabric: {
type: Cesium.Material.CircleSpiralType,
uniforms: {
color: new Cesium.Color(1.0, 0.0, 0.0, 0.7),
speed: 3.0
},
source: CircleSpiralMaterial
},
translucent: function(material) {
return true
}
})

/**
* CircleVary
* @type {string}
*/
Cesium.Material.CircleVaryType = 'CircleVary'
Cesium.Material._materialCache.addMaterial(Cesium.Material.CircleVaryType, {
fabric: {
type: Cesium.Material.CircleVaryType,
uniforms: {
color: new Cesium.Color(1.0, 0.0, 0.0, 0.7),
speed: 3.0
},
source: CircleVaryMaterial
},
translucent: function(material) {
return true
}
})

/**
* CircleWave
* @type {string}
*/
Cesium.Material.CircleWaveType = 'CircleWave'
Cesium.Material._materialCache.addMaterial(Cesium.Material.CircleWaveType, {
fabric: {
type: Cesium.Material.CircleWaveType,
uniforms: {
color: new Cesium.Color(1.0, 0.0, 0.0, 0.7),
speed: 3.0,
count: 1,
gradient: 0.1
},
source: CircleWaveMaterial
},
translucent: function(material) {
return true
}
})

+ 50
- 0
modules/material/type/ellipsoid.js Прегледај датотеку

@@ -0,0 +1,50 @@
/**
* @Author: Caven
* @Date: 2021-02-27 23:20:11
*/

const { Cesium } = DC.Namespace

const EllipsoidElectricMaterial = require('../shader/ellipsoid/EllipsoidElectricMaterial.glsl')
const EllipsoidTrailMaterial = require('../shader/ellipsoid/EllipsoidTrailMaterial.glsl')

/**
* EllipsoidElectric
* @type {string}
*/
Cesium.Material.EllipsoidElectricType = 'EllipsoidElectric'
Cesium.Material._materialCache.addMaterial(
Cesium.Material.EllipsoidElectricType,
{
fabric: {
type: Cesium.Material.EllipsoidElectricType,
uniforms: {
color: new Cesium.Color(1.0, 0.0, 0.0, 0.7),
speed: 1
},
source: EllipsoidElectricMaterial
},
translucent: function(material) {
return true
}
}
)

/**
* EllipsoidTrail
* @type {string}
*/
Cesium.Material.EllipsoidTrailType = 'EllipsoidTrail'
Cesium.Material._materialCache.addMaterial(Cesium.Material.EllipsoidTrailType, {
fabric: {
type: Cesium.Material.EllipsoidTrailType,
uniforms: {
color: new Cesium.Color(1.0, 0.0, 0.0, 0.7),
speed: 3.0
},
source: EllipsoidTrailMaterial
},
translucent: function(material) {
return true
}
})

+ 146
- 0
modules/material/type/polyline.js Прегледај датотеку

@@ -0,0 +1,146 @@
/**
* @Author: Caven
* @Date: 2021-02-27 23:23:12
*/

const { Cesium } = DC.Namespace

const LineFlickerMaterial = require('../shader/polyline/PolylineFlickerMaterial.glsl')
const LineFlowMaterial = require('../shader/polyline/PolylineFlowMaterial.glsl')
const LineImageTrailMaterial = require('../shader/polyline/PolylineImageTrailMaterial.glsl')
const LineLightingMaterial = require('../shader/polyline/PolylineLightingMaterial.glsl')
const LineLightingTrailMaterial = require('../shader/polyline/PolylineLightingTrailMaterial.glsl')
const LineTrailMaterial = require('../shader/polyline/PolylineTrailMaterial.glsl')

/**
* PolylineFlicker
* @type {string}
*/
Cesium.Material.PolylineFlickerType = 'PolylineFlicker'
Cesium.Material._materialCache.addMaterial(
Cesium.Material.PolylineFlickerType,
{
fabric: {
type: Cesium.Material.PolylineFlickerType,
uniforms: {
color: new Cesium.Color(1.0, 0.0, 0.0, 0.7),
speed: 1
},
source: LineFlickerMaterial
},
translucent: function(material) {
return true
}
}
)

/**
* PolylineFlow
* @type {string}
*/
Cesium.Material.PolylineFlowType = 'PolylineFlow'
Cesium.Material._materialCache.addMaterial(Cesium.Material.PolylineFlowType, {
fabric: {
type: Cesium.Material.PolylineFlowType,
uniforms: {
color: new Cesium.Color(1.0, 0.0, 0.0, 0.7),
speed: 1,
percent: 0.03,
gradient: 0.1
},
source: LineFlowMaterial
},
translucent: function(material) {
return true
}
})

/**
* PolylineImageTrail
* @type {string}
*/
Cesium.Material.PolylineImageTrailType = 'PolylineImageTrail'
Cesium.Material._materialCache.addMaterial(
Cesium.Material.PolylineImageTrailType,
{
fabric: {
type: Cesium.Material.PolylineImageTrailType,
uniforms: {
color: new Cesium.Color(1.0, 0.0, 0.0, 0.7),
image: Cesium.Material.DefaultImageId,
speed: 1,
repeat: new Cesium.Cartesian2(1, 1)
},
source: LineImageTrailMaterial
},
translucent: function(material) {
return true
}
}
)

/**
* PolylineLighting
* @type {string}
*/
Cesium.Material.PolylineLightingType = 'PolylineLighting'
Cesium.Material._materialCache.addMaterial(
Cesium.Material.PolylineLightingType,
{
fabric: {
type: Cesium.Material.PolylineLightingType,
uniforms: {
color: new Cesium.Color(1.0, 0.0, 0.0, 0.7),
image: Cesium.Material.DefaultImageId
},
source: LineLightingMaterial
},
translucent: function(material) {
return true
}
}
)

/**
* PolylineLightingTrail
* @type {string}
*/
Cesium.Material.PolylineLightingTrailType = 'PolylineLightingTrail'
Cesium.Material._materialCache.addMaterial(
Cesium.Material.PolylineLightingTrailType,
{
fabric: {
type: Cesium.Material.PolylineLightingTrailType,
uniforms: {
color: new Cesium.Color(1.0, 0.0, 0.0, 0.7),
image: Cesium.Material.DefaultImageId,
speed: 3.0
},
source: LineLightingTrailMaterial
},
translucent: function(material) {
return true
}
}
)

/**
* PolylineTrail
* @type {string}
*/
Cesium.Material.PolylineTrailType = 'PolylineTrail'
Cesium.Material._materialCache.addMaterial(Cesium.Material.PolylineTrailType, {
fabric: {
type: Cesium.Material.PolylineTrailType,
uniforms: {
color: new Cesium.Color(1.0, 0.0, 0.0, 0.7),
image: Cesium.Material.DefaultImageId,
speed: 1,
repeat: new Cesium.Cartesian2(1, 1)
},
source: LineTrailMaterial
},
translucent: function(material) {
return true
}
})

+ 67
- 0
modules/material/type/radar.js Прегледај датотеку

@@ -0,0 +1,67 @@
/**
* @Author: Caven
* @Date: 2021-02-27 23:22:38
*/

const { Cesium } = DC.Namespace

const RadarLineMaterial = require('../shader/radar/RadarLineMaterial.glsl')
const RadarSweepMaterial = require('../shader/radar/RadarSweepMaterial.glsl')
const RadarWaveMaterial = require('../shader/radar/RadarWaveMaterial.glsl')

/**
* RadarLine
* @type {string}
*/
Cesium.Material.RadarLineType = 'RadarLine'
Cesium.Material._materialCache.addMaterial(Cesium.Material.RadarLineType, {
fabric: {
type: Cesium.Material.RadarLineType,
uniforms: {
color: new Cesium.Color(1.0, 0.0, 0.0, 0.7),
speed: 3.0
},
source: RadarLineMaterial
},
translucent: function(material) {
return true
}
})

/**
* RadarSweep
* @type {string}
*/
Cesium.Material.RadarSweepType = 'RadarSweep'
Cesium.Material._materialCache.addMaterial(Cesium.Material.RadarSweepType, {
fabric: {
type: Cesium.Material.RadarSweepType,
uniforms: {
color: new Cesium.Color(1.0, 0.0, 0.0, 0.7),
speed: 3.0
},
source: RadarSweepMaterial
},
translucent: function(material) {
return true
}
})

/**
* RadarWave
* @type {string}
*/
Cesium.Material.RadarWaveType = 'RadarWave'
Cesium.Material._materialCache.addMaterial(Cesium.Material.RadarWaveType, {
fabric: {
type: Cesium.Material.RadarWaveType,
uniforms: {
color: new Cesium.Color(1.0, 0.0, 0.0, 0.7),
speed: 3.0
},
source: RadarWaveMaterial
},
translucent: function(material) {
return true
}
})

+ 272
- 0
modules/material/type/thirdpart.js Прегледај датотеку

@@ -0,0 +1,272 @@
/**
* @Author: Caven
* @Date: 2021-02-27 22:52:23
*/

const { Cesium } = DC.Namespace

const czm_cellular = require('../shader/thirdpart/cellular.glsl')
const czm_snoise = require('../shader/thirdpart/snoise.glsl')
const AsphaltMaterial = require('../shader/thirdpart/AsphaltMaterial.glsl')
const BlobMaterial = require('../shader/thirdpart/BlobMaterial.glsl')
const BrickMaterial = require('../shader/thirdpart/BlobMaterial.glsl')
const CementMaterial = require('../shader/thirdpart/CementMaterial.glsl')
const ErosionMaterial = require('../shader/thirdpart/ErosionMaterial.glsl')
const FacetMaterial = require('../shader/thirdpart/FacetMaterial.glsl')
const FresnelMaterial = require('../shader/thirdpart/FresnelMaterial.glsl')
const GrassMaterial = require('../shader/thirdpart/GrassMaterial.glsl')
const ReflectionMaterial = require('../shader/thirdpart/ReflectionMaterial.glsl')
const RefractionMaterial = require('../shader/thirdpart/RefractionMaterial.glsl')
const TieDyeMaterial = require('../shader/thirdpart/TieDyeMaterial.glsl')
const WoodMaterial = require('../shader/thirdpart/WoodMaterial.glsl')

Cesium.ShaderSource._czmBuiltinsAndUniforms.czm_cellular = czm_cellular
Cesium.ShaderSource._czmBuiltinsAndUniforms.czm_snoise = czm_snoise

/**
* Asphalt
* @type {string}
*/
Cesium.Material.AsphaltType = 'Asphalt'
Cesium.Material._materialCache.addMaterial(Cesium.Material.AsphaltType, {
fabric: {
type: Cesium.Material.AsphaltType,
uniforms: {
asphaltColor: new Cesium.Color(0.15, 0.15, 0.15, 1.0),
bumpSize: 0.02,
roughness: 0.2
},
source: AsphaltMaterial
},
translucent: function(material) {
return material.uniforms.asphaltColor.alpha < 1.0
}
})

/**
* Blob
* @type {string}
*/
Cesium.Material.BlobType = 'Blob'
Cesium.Material._materialCache.addMaterial(Cesium.Material.BlobType, {
fabric: {
type: Cesium.Material.BlobType,
uniforms: {
lightColor: new Cesium.Color(1.0, 1.0, 1.0, 0.5),
darkColor: new Cesium.Color(0.0, 0.0, 1.0, 0.5),
frequency: 10.0
},
source: BlobMaterial
},
translucent: function(material) {
var uniforms = material.uniforms
return uniforms.lightColor.alpha < 1.0 || uniforms.darkColor.alpha < 0.0
}
})

/**
* Brick
* @type {string}
*/
Cesium.Material.BrickType = 'Brick'
Cesium.Material._materialCache.addMaterial(Cesium.Material.BrickType, {
fabric: {
type: Cesium.Material.BrickType,
uniforms: {
brickColor: new Cesium.Color(0.6, 0.3, 0.1, 1.0),
mortarColor: new Cesium.Color(0.8, 0.8, 0.7, 1.0),
brickSize: new Cesium.Cartesian2(0.3, 0.15),
brickPct: new Cesium.Cartesian2(0.9, 0.85),
brickRoughness: 0.2,
mortarRoughness: 0.1
},
source: BrickMaterial
},
translucent: function(material) {
var uniforms = material.uniforms
return uniforms.brickColor.alpha < 1.0 || uniforms.mortarColor.alpha < 1.0
}
})

/**
* Cement
* @type {string}
*/
Cesium.Material.CementType = 'Cement'
Cesium.Material._materialCache.addMaterial(Cesium.Material.CementType, {
fabric: {
type: Cesium.Material.CementType,
uniforms: {
cementColor: new Cesium.Color(0.95, 0.95, 0.85, 1.0),
grainScale: 0.01,
roughness: 0.3
},
source: CementMaterial
},
translucent: function(material) {
return material.uniforms.cementColor.alpha < 1.0
}
})

/**
* Erosion
* @type {string}
*/
Cesium.Material.ErosionType = 'Erosion'
Cesium.Material._materialCache.addMaterial(Cesium.Material.ErosionType, {
fabric: {
type: Cesium.Material.ErosionType,
uniforms: {
color: new Cesium.Color(1.0, 0.0, 0.0, 0.5),
time: 1.0
},
source: ErosionMaterial
},
translucent: function(material) {
return material.uniforms.color.alpha < 1.0
}
})

/**
* Facet
* @type {string}
*/
Cesium.Material.FacetType = 'Facet'
Cesium.Material._materialCache.addMaterial(Cesium.Material.FacetType, {
fabric: {
type: Cesium.Material.FacetType,
uniforms: {
lightColor: new Cesium.Color(0.25, 0.25, 0.25, 0.75),
darkColor: new Cesium.Color(0.75, 0.75, 0.75, 0.75),
frequency: 10.0
},
source: FacetMaterial
},
translucent: function(material) {
var uniforms = material.uniforms
return uniforms.lightColor.alpha < 1.0 || uniforms.darkColor.alpha < 0.0
}
})

/**
* Fresnel
* @type {string}
*/
Cesium.Material.FresnelType = 'Fresnel'
Cesium.Material._materialCache.addMaterial(Cesium.Material.FresnelType, {
fabric: {
type: Cesium.Material.FresnelType,
materials: {
reflection: {
type: Cesium.Material.ReflectionType
},
refraction: {
type: Cesium.Material.RefractionType
}
},
source: FresnelMaterial
},
translucent: false
})

/**
* Grass
* @type {string}
*/
Cesium.Material.GrassType = 'Grass'
Cesium.Material._materialCache.addMaterial(Cesium.Material.GrassType, {
fabric: {
type: Cesium.Material.GrassType,
uniforms: {
grassColor: new Cesium.Color(0.25, 0.4, 0.1, 1.0),
dirtColor: new Cesium.Color(0.1, 0.1, 0.1, 1.0),
patchiness: 1.5
},
source: GrassMaterial
},
translucent: function(material) {
var uniforms = material.uniforms
return uniforms.grassColor.alpha < 1.0 || uniforms.dirtColor.alpha < 1.0
}
})

/**
* Reflection
* @type {string}
*/
Cesium.Material.ReflectionType = 'Reflection'
Cesium.Material._materialCache.addMaterial(Cesium.Material.ReflectionType, {
fabric: {
type: Cesium.Material.ReflectionType,
uniforms: {
cubeMap: Cesium.Material.DefaultCubeMapId,
channels: 'rgb'
},
source: ReflectionMaterial
},
translucent: false
})

/**
* Refraction
* @type {string}
*/
Cesium.Material.RefractionType = 'Refraction'
Cesium.Material._materialCache.addMaterial(Cesium.Material.RefractionType, {
fabric: {
type: Cesium.Material.RefractionType,
uniforms: {
cubeMap: Cesium.Material.DefaultCubeMapId,
channels: 'rgb',
indexOfRefractionRatio: 0.9
},
source: RefractionMaterial
},
translucent: false
})

/**
* TieDye
* @type {string}
*/
Cesium.Material.TyeDyeType = 'TieDye'
Cesium.Material._materialCache.addMaterial(Cesium.Material.TyeDyeType, {
fabric: {
type: Cesium.Material.TyeDyeType,
uniforms: {
lightColor: new Cesium.Color(1.0, 1.0, 0.0, 0.75),
darkColor: new Cesium.Color(1.0, 0.0, 0.0, 0.75),
frequency: 5.0
},
source: TieDyeMaterial
},
translucent: function(material) {
var uniforms = material.uniforms
return uniforms.lightColor.alpha < 1.0 || uniforms.darkColor.alpha < 0.0
}
})

/**
* Wood
* @type {string}
*/
Cesium.Material.WoodType = 'Wood'
Cesium.Material._materialCache.addMaterial(Cesium.Material.WoodType, {
fabric: {
type: Cesium.Material.WoodType,
uniforms: {
lightWoodColor: new Cesium.Color(0.6, 0.3, 0.1, 1.0),
darkWoodColor: new Cesium.Color(0.4, 0.2, 0.07, 1.0),
ringFrequency: 3.0,
noiseScale: new Cesium.Cartesian2(0.7, 0.5),
grainFrequency: 27.0
},
source: WoodMaterial
},
translucent: function(material) {
let uniforms = material.uniforms
return (
uniforms.lightWoodColor.alpha < 1.0 || uniforms.darkWoodColor.alpha < 1.0
)
}
})

+ 72
- 0
modules/material/type/wall.js Прегледај датотеку

@@ -0,0 +1,72 @@
/**
* @Author: Caven
* @Date: 2021-02-27 23:30:43
*/

const { Cesium } = DC.Namespace

const WallImageTrailMaterial = require('../shader/wall/WallImageTrailMaterial.glsl')
const WallLineTrailMaterial = require('../shader/wall/WallLineTrailMaterial.glsl')
const WallTrailMaterial = require('../shader/wall/WallTrailMaterial.glsl')

/**
* WallImageTrail
* @type {string}
*/
Cesium.Material.WallImageTrailType = 'WallImageTrail'
Cesium.Material._materialCache.addMaterial(Cesium.Material.WallImageTrailType, {
fabric: {
type: Cesium.Material.WallImageTrailType,
uniforms: {
image: Cesium.Material.DefaultImageId,
color: new Cesium.Color(1.0, 0.0, 0.0, 0.7),
speed: 3.0,
repeat: new Cesium.Cartesian2(1, 1)
},
source: WallImageTrailMaterial
},
translucent: function(material) {
return true
}
})

/**
* WallLineTrail
* @type {string}
*/
Cesium.Material.WallLineTrailType = 'WallLineTrail'
Cesium.Material._materialCache.addMaterial(Cesium.Material.WallLineTrailType, {
fabric: {
type: Cesium.Material.WallLineTrailType,
uniforms: {
color: new Cesium.Color(1.0, 0.0, 0.0, 0.7),
image: Cesium.Material.DefaultImageId,
repeat: new Cesium.Cartesian2(1, 1),
speed: 3.0
},
source: WallLineTrailMaterial
},
translucent: function(material) {
return true
}
})

/**
* WallTrail
* @type {string}
*/
Cesium.Material.WallTrailType = 'WallTrail'
Cesium.Material._materialCache.addMaterial(Cesium.Material.WallTrailType, {
fabric: {
type: Cesium.Material.WallTrailType,
uniforms: {
color: new Cesium.Color(1.0, 0.0, 0.0, 0.7),
image: Cesium.Material.DefaultImageId,
speed: 1
},
source: WallTrailMaterial
},
translucent: function(material) {
return true
}
})

Loading…
Откажи
Сачувај