babylon.starfieldProceduralTexture.ts 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /// <reference path="../../../dist/preview release/babylon.d.ts"/>
  2. module BABYLON {
  3. export class StarfieldProceduralTexture extends ProceduralTexture {
  4. private _time = 1;
  5. private _alpha = 0.5;
  6. private _beta = 0.8;
  7. private _zoom = 0.8;
  8. private _formuparam = 0.53;
  9. private _stepsize = 0.1;
  10. private _tile = 0.850;
  11. private _brightness = 0.0015;
  12. private _darkmatter = 0.400;
  13. private _distfading = 0.730;
  14. private _saturation = 0.850;
  15. constructor(name: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean) {
  16. super(name, size, "starfieldProceduralTexture", scene, fallbackTexture, generateMipMaps);
  17. this.updateShaderUniforms();
  18. }
  19. public updateShaderUniforms() {
  20. this.setFloat("time", this._time);
  21. this.setFloat("alpha", this._alpha);
  22. this.setFloat("beta", this._beta);
  23. this.setFloat("zoom", this._zoom);
  24. this.setFloat("formuparam", this._formuparam);
  25. this.setFloat("stepsize", this._stepsize);
  26. this.setFloat("tile", this._tile);
  27. this.setFloat("brightness", this._brightness);
  28. this.setFloat("darkmatter", this._darkmatter);
  29. this.setFloat("distfading", this._distfading);
  30. this.setFloat("saturation", this._saturation);
  31. }
  32. public get time(): number {
  33. return this._time;
  34. }
  35. public set time(value: number) {
  36. this._time = value;
  37. this.updateShaderUniforms();
  38. }
  39. public get alpha(): number {
  40. return this._alpha;
  41. }
  42. public set alpha(value: number) {
  43. this._alpha = value;
  44. this.updateShaderUniforms();
  45. }
  46. public get beta(): number {
  47. return this._beta;
  48. }
  49. public set beta(value: number) {
  50. this._beta = value;
  51. this.updateShaderUniforms();
  52. }
  53. public get formuparam(): number {
  54. return this._formuparam;
  55. }
  56. public set formuparam(value: number) {
  57. this._formuparam = value;
  58. this.updateShaderUniforms();
  59. }
  60. public get stepsize(): number {
  61. return this._stepsize;
  62. }
  63. public set stepsize(value: number) {
  64. this._stepsize = value;
  65. this.updateShaderUniforms();
  66. }
  67. public get zoom(): number {
  68. return this._zoom;
  69. }
  70. public set zoom(value: number) {
  71. this._zoom = value;
  72. this.updateShaderUniforms();
  73. }
  74. public get tile(): number {
  75. return this._tile;
  76. }
  77. public set tile(value: number) {
  78. this._tile = value;
  79. this.updateShaderUniforms();
  80. }
  81. public get brightness(): number {
  82. return this._brightness;
  83. }
  84. public set brightness(value: number) {
  85. this._brightness = value;
  86. this.updateShaderUniforms();
  87. }
  88. public get darkmatter(): number {
  89. return this._darkmatter;
  90. }
  91. public set darkmatter(value: number) {
  92. this._darkmatter = value;
  93. this.updateShaderUniforms();
  94. }
  95. public get distfading(): number {
  96. return this._distfading;
  97. }
  98. public set distfading(value: number) {
  99. this._distfading = value;
  100. this.updateShaderUniforms();
  101. }
  102. public get saturation(): number {
  103. return this._saturation;
  104. }
  105. public set saturation(value: number) {
  106. this._saturation = value;
  107. this.updateShaderUniforms();
  108. }
  109. }
  110. }