babylon.refractionPostProcess.ts 1.2 KB

1234567891011121314151617181920212223242526272829
  1. module BABYLON {
  2. export class RefractionPostProcess extends PostProcess {
  3. private _refRexture: Texture;
  4. constructor(name: string, refractionTextureUrl: string, public color: Color3, public depth: number, public colorLevel: number, ratio: number, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean) {
  5. super(name, "refraction", ["baseColor", "depth", "colorLevel"], ["refractionSampler"], ratio, camera, samplingMode, engine, reusable);
  6. this.onActivate = (cam: Camera) => {
  7. this._refRexture = this._refRexture || new BABYLON.Texture(refractionTextureUrl, cam.getScene());
  8. };
  9. this.onApply = (effect: Effect) => {
  10. effect.setColor3("baseColor", this.color);
  11. effect.setFloat("depth", this.depth);
  12. effect.setFloat("colorLevel", this.colorLevel);
  13. effect.setTexture("refractionSampler", this._refRexture);
  14. };
  15. }
  16. // Methods
  17. public dispose(camera: Camera): void {
  18. if (this._refRexture) {
  19. this._refRexture.dispose();
  20. }
  21. super.dispose(camera);
  22. }
  23. }
  24. }