1 
2 //
3 // This source file is part of appleseed.
4 // Visit https://appleseedhq.net/ for additional information and resources.
5 //
6 // This software is released under the MIT license.
7 //
8 // Copyright (c) 2016-2018 Esteban Tovagliari, The appleseedhq Organization
9 //
10 // Permission is hereby granted, free of charge, to any person obtaining a copy
11 // of this software and associated documentation files (the "Software"), to deal
12 // in the Software without restriction, including without limitation the rights
13 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 // copies of the Software, and to permit persons to whom the Software is
15 // furnished to do so, subject to the following conditions:
16 //
17 // The above copyright notice and this permission notice shall be included in
18 // all copies or substantial portions of the Software.
19 //
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
26 // THE SOFTWARE.
27 //
28 
29 #pragma once
30 
31 // appleseed.renderer headers.
32 #include "renderer/global/globaltypes.h"
33 #include "renderer/modeling/bsdf/ibsdffactory.h"
34 #include "renderer/modeling/input/inputarray.h"
35 
36 // appleseed.foundation headers.
37 #include "foundation/platform/compiler.h"
38 #include "foundation/utility/autoreleaseptr.h"
39 
40 // appleseed.main headers.
41 #include "main/dllsymbol.h"
42 
43 // Forward declarations.
44 namespace foundation    { class Dictionary; }
45 namespace foundation    { class DictionaryArray; }
46 namespace renderer      { class BSDF; }
47 namespace renderer      { class ParamArray; }
48 
49 namespace renderer
50 {
51 
52 //
53 // Metal BRDF input values.
54 //
55 
APPLESEED_DECLARE_INPUT_VALUES(MetalBRDFInputValues)56 APPLESEED_DECLARE_INPUT_VALUES(MetalBRDFInputValues)
57 {
58     Spectrum    m_normal_reflectance;
59     Spectrum    m_edge_tint;
60     float       m_reflectance_multiplier;
61     float       m_roughness;
62     float       m_anisotropy;
63     float       m_energy_compensation;
64 
65     struct Precomputed
66     {
67         Spectrum m_n;
68         Spectrum m_k;
69         Spectrum m_fresnel_average;
70         float    m_outside_ior;
71     };
72 
73     Precomputed m_precomputed;
74 };
75 
76 
77 //
78 // Metal BRDF factory.
79 //
80 
81 class APPLESEED_DLLSYMBOL MetalBRDFFactory
82   : public IBSDFFactory
83 {
84   public:
85     // Delete this instance.
86     void release() override;
87 
88     // Return a string identifying this BSDF model.
89     const char* get_model() const override;
90 
91     // Return metadata for this BSDF model.
92     foundation::Dictionary get_model_metadata() const override;
93 
94     // Return metadata for the inputs of this BSDF model.
95     foundation::DictionaryArray get_input_metadata() const override;
96 
97     // Create a new BSDF instance.
98     foundation::auto_release_ptr<BSDF> create(
99         const char*         name,
100         const ParamArray&   params) const override;
101 };
102 
103 }   // namespace renderer
104