Skip to content

Commit a52d012

Browse files
Emission Profiles now load properly!
1 parent 708f753 commit a52d012

5 files changed

Lines changed: 139 additions & 228 deletions

File tree

include/nbl/ext/MitsubaLoader/CMitsubaLoader.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@ class CMitsubaLoader final : public asset::ISceneLoader
4848
virtual ~CMitsubaLoader() = default;
4949

5050
#if 0
51-
void cacheTexture(SContext& ctx, uint32_t hierarchyLevel, const CElementTexture* texture, const CMitsubaMaterialCompilerFrontend::E_IMAGE_VIEW_SEMANTIC semantic);
52-
void cacheEmissionProfile(SContext& ctx, const CElementEmissionProfile* profile);
51+
void cacheTexture(SContext& ctx, uint32_t hierarchyLevel, const CElementTexture* texture, const CMitsubaMaterialCompilerFrontend::E_IMAGE_VIEW_SEMANTIC semantic);
5352

5453
template <typename Iter>
5554
core::smart_refctd_ptr<asset::ICPUDescriptorSet> createDS0(const SContext& _ctx, asset::ICPUPipelineLayout* _layout, const asset::material_compiler::CMaterialCompilerGLSLBackendCommon::result_t& _compResult, Iter meshBegin, Iter meshEnd);

include/nbl/ext/MitsubaLoader/CMitsubaMaterialCompilerFrontend.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,10 @@
1616
namespace nbl::ext::MitsubaLoader
1717
{
1818

19-
struct SContext;
20-
2119
class CMitsubaMaterialCompilerFrontend
2220
{
2321
public:
2422
#ifdef 0
25-
using IRNode = asset::material_compiler::IR::INode;
26-
using EmitterNode = asset::material_compiler::IR::CEmitterNode;
2723
enum E_IMAGE_VIEW_SEMANTIC : uint8_t
2824
{
2925
EIVS_IDENTITIY,
@@ -33,24 +29,16 @@ class CMitsubaMaterialCompilerFrontend
3329
EIVS_COUNT
3430
};
3531

36-
explicit CMitsubaMaterialCompilerFrontend(const SContext* _ctx) : m_loaderContext(_ctx) {}
37-
3832
front_and_back_t compileToIRTree(asset::material_compiler::IR* ir, const CElementBSDF* _bsdf);
39-
EmitterNode* createEmitterNode(asset::material_compiler::IR* ir, const CElementEmitter* _emitter, core::matrix4SIMD transform);
4033

4134
private:
4235
using tex_ass_type = std::tuple<core::smart_refctd_ptr<asset::ICPUImageView>,core::smart_refctd_ptr<asset::ICPUSampler>,float>;
43-
using emission_profile_type = std::tuple<core::smart_refctd_ptr<asset::ICPUSampler>, const asset::CIESProfileMetadata*>;
4436

4537
const SContext* m_loaderContext;
4638

4739
std::pair<const CElementTexture*,float> unwindTextureScale(const CElementTexture* _element) const;
4840

4941
tex_ass_type getTexture(const CElementTexture* _element, const E_IMAGE_VIEW_SEMANTIC semantic=EIVS_IDENTITIY) const;
50-
51-
emission_profile_type getEmissionProfile(const CElementEmissionProfile* _element);
52-
53-
tex_ass_type getErrorTexture(const E_IMAGE_VIEW_SEMANTIC semantic) const;
5442
#endif
5543
};
5644

include/nbl/ext/MitsubaLoader/SContext.h

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ struct SContext final
3434

3535
// Mitsuba XML Materials do not support emission from a BSDF node (i.e. emitter behind a coating or glass screen), its purely additive and cannot be backface emitting
3636
using material_t = asset::material_compiler3::CFrontendIR::typed_pointer_type<const asset::material_compiler3::CFrontendIR::CLayer>; // TODO: change to true IR
37-
material_t getMaterial(const CElementBSDF* bsdf, const CElementEmitter* frontFaceEmitter, const hlsl::float32_t3x3& iesProfileOrientation, const core::string& debugName, system::ISystem* debugFileWriter=nullptr);
37+
material_t getMaterial(const CElementBSDF* bsdf, const CElementEmitter* frontFaceEmitter, const core::string& debugName, system::ISystem* debugFileWriter=nullptr);
3838

3939
inline void writeFrontendForestDot3(system::ISystem* system, const system::path& filepath)
4040
{
@@ -60,8 +60,8 @@ struct SContext final
6060
// not `frontend_ir_t::CEmitter` because the color factor gets multiplied in
6161
using frontend_emitter_t = frontend_ir_t::typed_pointer_type<const frontend_ir_t::CMul>;
6262
frontend_material_t genMaterial(const CElementBSDF* bsdf, system::ISystem* debugFileWriter);
63-
frontend_emitter_t getEmitter(const CElementEmitter* emitter, const hlsl::float32_t3x3& iesProfileOrientation, system::ISystem* debugFileWriter);
6463
frontend_emitter_t genEmitter(const CElementEmitter* emitter, system::ISystem* debugFileWriter);
64+
frontend_ir_t::SParameter getProfile(const CElementEmissionProfile* profile);
6565
//
6666
void writeDot3File(system::ISystem* system, const system::path& filepath, frontend_ir_t::SDotPrinter& printer);
6767

@@ -70,28 +70,16 @@ struct SContext final
7070
//
7171
core::unordered_map<const CElementShape::ShapeGroup*,CMitsubaMetadata::SGeometryCollectionMetaPair> groupCache;
7272
//
73-
core::unordered_map<const CElementBSDF*,frontend_material_t> bsdfCache;
7473
core::unordered_map<const CElementEmitter*,frontend_emitter_t> emitterCache;
74+
core::unordered_map<const CElementBSDF*,frontend_material_t> bsdfCache;
75+
core::unordered_map<const CElementEmissionProfile*,frontend_ir_t::SParameter> profileCache;
7576

7677
#if 0 // stuff that belongs in the Material Compiler backend
7778
//image, sampler
7879
using tex_ass_type = std::tuple<core::smart_refctd_ptr<asset::ICPUImageView>,core::smart_refctd_ptr<asset::ICPUSampler>>;
7980
//image, scale
8081
core::map<core::smart_refctd_ptr<asset::ICPUImage>,float> derivMapCache;
8182

82-
static asset::ISampler::SParams emissionProfileSamplerParams(const CElementEmissionProfile* profile, const asset::CIESProfileMetadata& meta)
83-
{
84-
return {
85-
asset::ISampler::ETC_REPEAT,
86-
asset::ISampler::ETC_REPEAT,
87-
asset::ISampler::ETC_REPEAT,
88-
asset::ISampler::ETBC_INT_OPAQUE_BLACK,
89-
asset::ISampler::ETF_LINEAR,
90-
asset::ISampler::ETF_LINEAR,
91-
asset::ISampler::ETF_LINEAR,
92-
0u, false, asset::ECO_ALWAYS
93-
};
94-
}
9583

9684
static auto computeSamplerParameters(const CElementTexture::Bitmap& bitmap)
9785
{

0 commit comments

Comments
 (0)