fxaaPostProcess.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import { Texture } from "../Materials/Textures/texture.js";
  2. import { PostProcess } from "./postProcess.js";
  3. import "../Shaders/fxaa.fragment.js";
  4. import "../Shaders/fxaa.vertex.js";
  5. import { RegisterClass } from "../Misc/typeStore.js";
  6. import { SerializationHelper } from "../Misc/decorators.serialization.js";
  7. /**
  8. * Fxaa post process
  9. * @see https://doc.babylonjs.com/features/featuresDeepDive/postProcesses/usePostProcesses#fxaa
  10. */
  11. export class FxaaPostProcess extends PostProcess {
  12. /**
  13. * Gets a string identifying the name of the class
  14. * @returns "FxaaPostProcess" string
  15. */
  16. getClassName() {
  17. return "FxaaPostProcess";
  18. }
  19. constructor(name, options, camera = null, samplingMode, engine, reusable, textureType = 0) {
  20. super(name, "fxaa", ["texelSize"], null, options, camera, samplingMode || Texture.BILINEAR_SAMPLINGMODE, engine, reusable, null, textureType, "fxaa", undefined, true);
  21. const defines = this._getDefines();
  22. this.updateEffect(defines);
  23. this.onApplyObservable.add((effect) => {
  24. const texelSize = this.texelSize;
  25. effect.setFloat2("texelSize", texelSize.x, texelSize.y);
  26. });
  27. }
  28. _getDefines() {
  29. const engine = this.getEngine();
  30. if (!engine) {
  31. return null;
  32. }
  33. const driverInfo = engine.extractDriverInfo();
  34. if (driverInfo.toLowerCase().indexOf("mali") > -1) {
  35. return "#define MALI 1\n";
  36. }
  37. return null;
  38. }
  39. /**
  40. * @internal
  41. */
  42. static _Parse(parsedPostProcess, targetCamera, scene, rootUrl) {
  43. return SerializationHelper.Parse(() => {
  44. return new FxaaPostProcess(parsedPostProcess.name, parsedPostProcess.options, targetCamera, parsedPostProcess.renderTargetSamplingMode, scene.getEngine(), parsedPostProcess.reusable);
  45. }, parsedPostProcess, scene, rootUrl);
  46. }
  47. }
  48. RegisterClass("BABYLON.FxaaPostProcess", FxaaPostProcess);
  49. //# sourceMappingURL=fxaaPostProcess.js.map