babylon.refractionPostProcess.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. "use strict";
  2. var BABYLON = BABYLON || {};
  3. (function () {
  4. BABYLON.RefractionPostProcess = function (name, refractionTextureUrl, color, depth, colorLevel, ratio, camera, samplingMode, engine, reusable) {
  5. BABYLON.PostProcess.call(this, name, "refraction", ["baseColor", "depth", "colorLevel"], ["refractionSampler"], ratio, camera, samplingMode, engine, reusable);
  6. this.color = color;
  7. this.depth = depth;
  8. this.colorLevel = colorLevel;
  9. this._refRexture = null;
  10. var that = this;
  11. this.onActivate = function (camera) {
  12. that._refRexture = this._refRexture || new BABYLON.Texture(refractionTextureUrl, camera.getScene());
  13. };
  14. this.onApply = function (effect) {
  15. effect.setColor3("baseColor", that.color);
  16. effect.setFloat("depth", that.depth);
  17. effect.setFloat("colorLevel", that.colorLevel);
  18. effect.setTexture("refractionSampler", that._refRexture);
  19. };
  20. };
  21. BABYLON.RefractionPostProcess.prototype = Object.create(BABYLON.PostProcess.prototype);
  22. // Methods
  23. BABYLON.RefractionPostProcess.prototype._onDispose = function () {
  24. this._refRexture.dispose();
  25. };
  26. })();