|
21 | 21 |
|
22 | 22 | #include <filament/FilamentAPI.h>
|
23 | 23 | #include <filament/ToneMapper.h>
|
| 24 | +#include <filament/ColorSpace.h> |
24 | 25 |
|
25 | 26 | #include <utils/compiler.h>
|
26 | 27 |
|
27 | 28 | #include <math/mathfwd.h>
|
| 29 | +#include <math/vec3.h> |
| 30 | +#include <math/vec4.h> |
28 | 31 |
|
29 | 32 | #include <stdint.h>
|
30 | 33 | #include <stddef.h>
|
| 34 | +#include <memory> |
31 | 35 |
|
32 | 36 | namespace filament {
|
33 | 37 |
|
@@ -201,15 +205,14 @@ class UTILS_PUBLIC ColorGrading : public FilamentAPI {
|
201 | 205 | *
|
202 | 206 | * The default tone mapping operator is ACESLegacyToneMapper.
|
203 | 207 | *
|
204 |
| - * The specified tone mapper must have a lifecycle that exceeds the lifetime of |
205 |
| - * this builder. Since the build(Engine&) method is synchronous, it is safe to |
206 |
| - * delete the tone mapper object after that finishes executing. |
| 208 | + * The ownership of the specified tone mapper is shared with the builder and built |
| 209 | + * ColorGrading object. |
207 | 210 | *
|
208 | 211 | * @param toneMapper The tone mapping operator to apply to the HDR color buffer
|
209 | 212 | *
|
210 | 213 | * @return This Builder, for chaining calls
|
211 | 214 | */
|
212 |
| - Builder& toneMapper(ToneMapper const* UTILS_NULLABLE toneMapper) noexcept; |
| 215 | + Builder& toneMapper(std::shared_ptr<ToneMapper> toneMapper) noexcept; |
213 | 216 |
|
214 | 217 | /**
|
215 | 218 | * Selects the tone mapping operator to apply to the HDR color buffer as the last
|
@@ -487,7 +490,118 @@ class UTILS_PUBLIC ColorGrading : public FilamentAPI {
|
487 | 490 | friend class FColorGrading;
|
488 | 491 | };
|
489 | 492 |
|
490 |
| -protected: |
| 493 | + /** Returns the quality level used to create this ColorGrading object. */ |
| 494 | + QualityLevel getQuality() const noexcept; |
| 495 | + |
| 496 | + /** Returns the LUT format used to create this ColorGrading object. */ |
| 497 | + LutFormat getLutFormat() const noexcept; |
| 498 | + |
| 499 | + /** Returns the LUT dimensions used to create this ColorGrading object. */ |
| 500 | + uint8_t getLutDimensions() const noexcept; |
| 501 | + |
| 502 | + /** Returns the tone mapper used to create this ColorGrading object. */ |
| 503 | + const ToneMapper& getToneMapper() const noexcept; |
| 504 | + |
| 505 | + /** Returns whether luminance scaling was enabled during creation. */ |
| 506 | + bool isLuminanceScalingEnabled() const noexcept; |
| 507 | + |
| 508 | + /** Returns whether gamut mapping was enabled during creation. */ |
| 509 | + bool isGamutMappingEnabled() const noexcept; |
| 510 | + |
| 511 | + /** Returns the exposure value used to create this ColorGrading object. */ |
| 512 | + float getExposure() const noexcept; |
| 513 | + |
| 514 | + /** Returns the night adaptation value used to create this ColorGrading object. */ |
| 515 | + float getNightAdaptation() const noexcept; |
| 516 | + |
| 517 | + /** Returns the white balance temperature used to create this ColorGrading object. */ |
| 518 | + float getWhiteBalanceTemperature() const noexcept; |
| 519 | + |
| 520 | + /** Returns the white balance tint used to create this ColorGrading object. */ |
| 521 | + float getWhiteBalanceTint() const noexcept; |
| 522 | + |
| 523 | + /** Returns the channel mixer output for the red channel. */ |
| 524 | + math::float3 getChannelMixerOutRed() const noexcept; |
| 525 | + |
| 526 | + /** Returns the channel mixer output for the green channel. */ |
| 527 | + math::float3 getChannelMixerOutGreen() const noexcept; |
| 528 | + |
| 529 | + /** Returns the channel mixer output for the blue channel. */ |
| 530 | + math::float3 getChannelMixerOutBlue() const noexcept; |
| 531 | + |
| 532 | + /** Returns the shadows adjustment used to create this ColorGrading object. */ |
| 533 | + math::float3 getShadows() const noexcept; |
| 534 | + |
| 535 | + /** Returns the midtones adjustment used to create this ColorGrading object. */ |
| 536 | + math::float3 getMidtones() const noexcept; |
| 537 | + |
| 538 | + /** Returns the highlights adjustment used to create this ColorGrading object. */ |
| 539 | + math::float3 getHighlights() const noexcept; |
| 540 | + |
| 541 | + /** Returns the shadow/midtones/highlights ranges used to create this ColorGrading object. */ |
| 542 | + math::float4 getShadowMidtonesHighlightsRanges() const noexcept; |
| 543 | + |
| 544 | + /** Returns the slope adjustment used to create this ColorGrading object. */ |
| 545 | + math::float3 getSlope() const noexcept; |
| 546 | + |
| 547 | + /** Returns the offset adjustment used to create this ColorGrading object. */ |
| 548 | + math::float3 getOffset() const noexcept; |
| 549 | + |
| 550 | + /** Returns the power adjustment used to create this ColorGrading object. */ |
| 551 | + math::float3 getPower() const noexcept; |
| 552 | + |
| 553 | + /** Returns the contrast value used to create this ColorGrading object. */ |
| 554 | + float getContrast() const noexcept; |
| 555 | + |
| 556 | + /** Returns the vibrance value used to create this ColorGrading object. */ |
| 557 | + float getVibrance() const noexcept; |
| 558 | + |
| 559 | + /** Returns the saturation value used to create this ColorGrading object. */ |
| 560 | + float getSaturation() const noexcept; |
| 561 | + |
| 562 | + /** Returns the shadow gamma curve adjustment used to create this ColorGrading object. */ |
| 563 | + math::float3 getCurvesShadowGamma() const noexcept; |
| 564 | + |
| 565 | + /** Returns the mid-point curve adjustment used to create this ColorGrading object. */ |
| 566 | + math::float3 getCurvesMidPoint() const noexcept; |
| 567 | + |
| 568 | + /** Returns the highlight scale curve adjustment used to create this ColorGrading object. */ |
| 569 | + math::float3 getCurvesHighlightScale() const noexcept; |
| 570 | + |
| 571 | + /** Returns the output color space used to create this ColorGrading object. */ |
| 572 | + const color::ColorSpace& getOutputColorSpace() const noexcept; |
| 573 | + |
| 574 | +protected : |
| 575 | + struct Settings { |
| 576 | + LutFormat lutFormat = LutFormat::INTEGER; |
| 577 | + uint8_t lutDimensions = 32; |
| 578 | + std::shared_ptr<ToneMapper> toneMapper = std::make_shared<ACESLegacyToneMapper>(); |
| 579 | + bool luminanceScaling = false; |
| 580 | + bool gummapMapping = false; |
| 581 | + float exposure = 0.0f; |
| 582 | + float nightAdaptation = 0.0f; |
| 583 | + float whiteBalanceTemperature = 0.0f; |
| 584 | + float whiteBalanceTint = 0.0f; |
| 585 | + math::float3 channelMixerOutRed{1.0f, 0.0f, 0.0f}; |
| 586 | + math::float3 channelMixerOutGreen{0.0f, 1.0f, 0.0f}; |
| 587 | + math::float3 channelMixerOutBlue{0.0f, 0.0f, 1.0f}; |
| 588 | + math::float3 shadows{1.0f, 1.0f, 1.0f}; |
| 589 | + math::float3 midtones{1.0f, 1.0f, 1.0f}; |
| 590 | + math::float3 highlights{1.0f, 1.0f, 1.0f}; |
| 591 | + math::float4 ShadowMidtonesHighlightsRanges{0.0f, 0.333f, 0.55f, 1.0f}; |
| 592 | + math::float3 slope{1.0f}; |
| 593 | + math::float3 offset{0.0f}; |
| 594 | + math::float3 power{1.0f}; |
| 595 | + float contrast = 1.0f; |
| 596 | + float vibrance = 1.0f; |
| 597 | + float saturation = 1.0f; |
| 598 | + math::float3 curvesShadowGamma{1.0f, 1.0f, 1.0f}; |
| 599 | + math::float3 curvesMidPoint{1.0f, 1.0f, 1.0f}; |
| 600 | + math::float3 curvesHighlightScale{1.0f, 1.0f, 1.0f}; |
| 601 | + color::ColorSpace colorSpace = color::Rec709 - color::sRGB - color::D65; |
| 602 | + }; |
| 603 | + Settings mSettings; |
| 604 | + |
491 | 605 | // prevent heap allocation
|
492 | 606 | ~ColorGrading() = default;
|
493 | 607 | };
|
|
0 commit comments