babylon.tonemapPostProcess.ts 1.4 KB

12345678910111213141516171819202122232425262728293031323334
  1. module BABYLON {
  2. export enum TonemappingOperator {
  3. Hable = 0,
  4. Reinhard = 1,
  5. HejiDawson = 2,
  6. Photographic = 3,
  7. };
  8. export class TonemapPostProcess extends PostProcess {
  9. constructor(name: string, private _operator: TonemappingOperator, public exposureAdjustment: number, camera: Camera, samplingMode: number = Texture.BILINEAR_SAMPLINGMODE, engine?: Engine, textureFormat = Engine.TEXTURETYPE_UNSIGNED_INT) {
  10. super(name, "tonemap", ["_ExposureAdjustment"], null, 1.0, camera, samplingMode, engine, true, defines, textureFormat);
  11. var defines = "#define ";
  12. if (this._operator === TonemappingOperator.Hable)
  13. defines += "HABLE_TONEMAPPING";
  14. else if (this._operator === TonemappingOperator.Reinhard)
  15. defines += "REINHARD_TONEMAPPING";
  16. else if (this._operator === TonemappingOperator.HejiDawson)
  17. defines += "OPTIMIZED_HEJIDAWSON_TONEMAPPING";
  18. else if (this._operator === TonemappingOperator.Photographic)
  19. defines += "PHOTOGRAPHIC_TONEMAPPING";
  20. //sadly a second call to create the effect.
  21. this.updateEffect(defines);
  22. this.onApply = (effect: Effect) => {
  23. effect.setFloat("_ExposureAdjustment", this.exposureAdjustment);
  24. };
  25. }
  26. }
  27. }