1
1
/* eslint-disable @typescript-eslint/naming-convention */
2
- import { serialize , serializeAsColor3 , expandToProperty , serializeAsTexture , serializeAsVector3 , serializeAsImageProcessingConfiguration } from "../../Misc/decorators" ;
2
+ import { serialize , serializeAsColor3 , expandToProperty , serializeAsTexture , serializeAsVector3 } from "../../Misc/decorators" ;
3
3
import { SmartArray } from "../../Misc/smartArray" ;
4
- import type { Observer } from "../../Misc/observable" ;
5
4
import { Logger } from "../../Misc/logger" ;
6
5
import type { Nullable , int , float } from "../../types" ;
7
6
import type { Scene } from "../../scene" ;
@@ -14,7 +13,6 @@ import type { Mesh } from "../../Meshes/mesh";
14
13
import type { IEffectCreationOptions } from "../../Materials/effect" ;
15
14
import { MaterialDefines } from "../../Materials/materialDefines" ;
16
15
import { PushMaterial } from "../../Materials/pushMaterial" ;
17
- import type { ColorCurves } from "../../Materials/colorCurves" ;
18
16
import { ImageProcessingDefinesMixin } from "../../Materials/imageProcessingConfiguration.defines" ;
19
17
import { ImageProcessingConfiguration } from "../../Materials/imageProcessingConfiguration" ;
20
18
import type { BaseTexture } from "../../Materials/Textures/baseTexture" ;
@@ -47,6 +45,7 @@ import {
47
45
} from "../materialHelper.functions" ;
48
46
import { SerializationHelper } from "../../Misc/decorators.serialization" ;
49
47
import { ShaderLanguage } from "../shaderLanguage" ;
48
+ import { ImageProcessingMixin } from "../imageProcessing" ;
50
49
51
50
class BackgroundMaterialDefinesBase extends MaterialDefines { }
52
51
@@ -187,11 +186,12 @@ class BackgroundMaterialDefines extends ImageProcessingDefinesMixin(BackgroundMa
187
186
}
188
187
}
189
188
189
+ class BackgroundMaterialBase extends ImageProcessingMixin ( PushMaterial ) { }
190
190
/**
191
191
* Background material used to create an efficient environment around your scene.
192
192
* #157MGZ: simple test
193
193
*/
194
- export class BackgroundMaterial extends PushMaterial {
194
+ export class BackgroundMaterial extends BackgroundMaterialBase {
195
195
/**
196
196
* Standard reflectance value at parallel view angle.
197
197
*/
@@ -439,168 +439,6 @@ export class BackgroundMaterial extends PushMaterial {
439
439
@expandToProperty ( "_markAllSubMeshesAsLightsDirty" )
440
440
public shadowOnly : boolean = false ;
441
441
442
- /**
443
- * Default configuration related to image processing available in the Background Material.
444
- */
445
- @serializeAsImageProcessingConfiguration ( )
446
- protected _imageProcessingConfiguration : ImageProcessingConfiguration ;
447
-
448
- /**
449
- * Keep track of the image processing observer to allow dispose and replace.
450
- */
451
- private _imageProcessingObserver : Nullable < Observer < ImageProcessingConfiguration > > = null ;
452
-
453
- /**
454
- * Attaches a new image processing configuration to the PBR Material.
455
- * @param configuration (if null the scene configuration will be use)
456
- */
457
- protected _attachImageProcessingConfiguration ( configuration : Nullable < ImageProcessingConfiguration > ) : void {
458
- if ( configuration === this . _imageProcessingConfiguration ) {
459
- return ;
460
- }
461
-
462
- // Detaches observer.
463
- if ( this . _imageProcessingConfiguration && this . _imageProcessingObserver ) {
464
- this . _imageProcessingConfiguration . onUpdateParameters . remove ( this . _imageProcessingObserver ) ;
465
- }
466
-
467
- // Pick the scene configuration if needed.
468
- if ( ! configuration ) {
469
- this . _imageProcessingConfiguration = this . getScene ( ) . imageProcessingConfiguration ;
470
- } else {
471
- this . _imageProcessingConfiguration = configuration ;
472
- }
473
-
474
- // Attaches observer.
475
- if ( this . _imageProcessingConfiguration ) {
476
- this . _imageProcessingObserver = this . _imageProcessingConfiguration . onUpdateParameters . add ( ( ) => {
477
- this . _computePrimaryColorFromPerceptualColor ( ) ;
478
- this . _markAllSubMeshesAsImageProcessingDirty ( ) ;
479
- } ) ;
480
- }
481
- }
482
-
483
- /**
484
- * Gets the image processing configuration used either in this material.
485
- */
486
- public get imageProcessingConfiguration ( ) : Nullable < ImageProcessingConfiguration > {
487
- return this . _imageProcessingConfiguration ;
488
- }
489
-
490
- /**
491
- * Sets the Default image processing configuration used either in the this material.
492
- *
493
- * If sets to null, the scene one is in use.
494
- */
495
- public set imageProcessingConfiguration ( value : Nullable < ImageProcessingConfiguration > ) {
496
- this . _attachImageProcessingConfiguration ( value ) ;
497
-
498
- // Ensure the effect will be rebuilt.
499
- this . _markAllSubMeshesAsTexturesDirty ( ) ;
500
- }
501
-
502
- /**
503
- * Gets whether the color curves effect is enabled.
504
- */
505
- public get cameraColorCurvesEnabled ( ) : boolean {
506
- return ( < ImageProcessingConfiguration > this . imageProcessingConfiguration ) . colorCurvesEnabled ;
507
- }
508
- /**
509
- * Sets whether the color curves effect is enabled.
510
- */
511
- public set cameraColorCurvesEnabled ( value : boolean ) {
512
- ( < ImageProcessingConfiguration > this . imageProcessingConfiguration ) . colorCurvesEnabled = value ;
513
- }
514
-
515
- /**
516
- * Gets whether the color grading effect is enabled.
517
- */
518
- public get cameraColorGradingEnabled ( ) : boolean {
519
- return ( < ImageProcessingConfiguration > this . imageProcessingConfiguration ) . colorGradingEnabled ;
520
- }
521
- /**
522
- * Gets whether the color grading effect is enabled.
523
- */
524
- public set cameraColorGradingEnabled ( value : boolean ) {
525
- ( < ImageProcessingConfiguration > this . imageProcessingConfiguration ) . colorGradingEnabled = value ;
526
- }
527
-
528
- /**
529
- * Gets whether tonemapping is enabled or not.
530
- */
531
- public get cameraToneMappingEnabled ( ) : boolean {
532
- return this . _imageProcessingConfiguration . toneMappingEnabled ;
533
- }
534
- /**
535
- * Sets whether tonemapping is enabled or not
536
- */
537
- public set cameraToneMappingEnabled ( value : boolean ) {
538
- this . _imageProcessingConfiguration . toneMappingEnabled = value ;
539
- }
540
-
541
- /**
542
- * The camera exposure used on this material.
543
- * This property is here and not in the camera to allow controlling exposure without full screen post process.
544
- * This corresponds to a photographic exposure.
545
- */
546
- public get cameraExposure ( ) : float {
547
- return this . _imageProcessingConfiguration . exposure ;
548
- }
549
- /**
550
- * The camera exposure used on this material.
551
- * This property is here and not in the camera to allow controlling exposure without full screen post process.
552
- * This corresponds to a photographic exposure.
553
- */
554
- public set cameraExposure ( value : float ) {
555
- this . _imageProcessingConfiguration . exposure = value ;
556
- }
557
-
558
- /**
559
- * Gets The camera contrast used on this material.
560
- */
561
- public get cameraContrast ( ) : float {
562
- return this . _imageProcessingConfiguration . contrast ;
563
- }
564
-
565
- /**
566
- * Sets The camera contrast used on this material.
567
- */
568
- public set cameraContrast ( value : float ) {
569
- this . _imageProcessingConfiguration . contrast = value ;
570
- }
571
-
572
- /**
573
- * Gets the Color Grading 2D Lookup Texture.
574
- */
575
- public get cameraColorGradingTexture ( ) : Nullable < BaseTexture > {
576
- return this . _imageProcessingConfiguration . colorGradingTexture ;
577
- }
578
- /**
579
- * Sets the Color Grading 2D Lookup Texture.
580
- */
581
- public set cameraColorGradingTexture ( value : Nullable < BaseTexture > ) {
582
- ( < ImageProcessingConfiguration > this . imageProcessingConfiguration ) . colorGradingTexture = value ;
583
- }
584
-
585
- /**
586
- * The color grading curves provide additional color adjustment that is applied after any color grading transform (3D LUT).
587
- * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
588
- * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
589
- * corresponding to low luminance, medium luminance, and high luminance areas respectively.
590
- */
591
- public get cameraColorCurves ( ) : Nullable < ColorCurves > {
592
- return ( < ImageProcessingConfiguration > this . imageProcessingConfiguration ) . colorCurves ;
593
- }
594
- /**
595
- * The color grading curves provide additional color adjustment that is applied after any color grading transform (3D LUT).
596
- * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
597
- * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
598
- * corresponding to low luminance, medium luminance, and high luminance areas respectively.
599
- */
600
- public set cameraColorCurves ( value : Nullable < ColorCurves > ) {
601
- ( < ImageProcessingConfiguration > this . imageProcessingConfiguration ) . colorCurves = value ;
602
- }
603
-
604
442
/**
605
443
* Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
606
444
* Setting this flag to true (not done automatically!) will convert it back to RGB.
0 commit comments