Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
7685d29
updated dxc
keptsecret May 22, 2026
5c248b4
reference backend basic structure + some impl for albedo, generate
keptsecret May 22, 2026
5fd4557
main compile function of backend does templated function declarations…
keptsecret May 22, 2026
2aab0eb
change compile to return ptr, minor fixes in combining node child res…
keptsecret May 25, 2026
28d9707
complete albedo hlsl impl
keptsecret May 25, 2026
efec002
backend normal hlsl impl
keptsecret May 25, 2026
a22700f
combine material functions into a struct to avoid repeating hash temp…
keptsecret May 26, 2026
abcb092
fixes to albedo and generate for new material struct
keptsecret May 26, 2026
2687586
transparency function impl added
keptsecret May 26, 2026
a3dbad5
add aovThroughput function + some fixes to transparency
keptsecret May 27, 2026
c36f9f6
more changes to use raw string literals
keptsecret May 27, 2026
bc4776b
emission functions
keptsecret May 27, 2026
d49f1d3
code to set up cook torrance bxdf, probably need to split out to anot…
keptsecret May 28, 2026
c2d1288
complete generate function impls
keptsecret May 28, 2026
6359f94
quotientAndWeight functions impl
keptsecret Jun 1, 2026
7bb2204
evalAndWeight functions impls
keptsecret Jun 1, 2026
3c6c684
fix some eval bugs not doing eval
keptsecret Jun 1, 2026
534b959
add cache struct declares, defines and usage
keptsecret Jun 2, 2026
89845ac
canGenerate function and use in quotient and eval funcs
keptsecret Jun 3, 2026
a1ce6d0
choiceTarget function impls
keptsecret Jun 3, 2026
c21d469
some bug fixes + removed resolved todos
keptsecret Jun 4, 2026
7aa4e1c
common function for getting cook torrance bxdf, also handle anisotrop…
keptsecret Jun 4, 2026
16d53c2
added missing factorcombiner cases for quotient, eval, generate and c…
keptsecret Jun 5, 2026
eba148f
changed to map nodes and use traversal node struct
keptsecret Jun 5, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion 3rdparty/dxc/dxc
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// Copyright (C) 2018-2026 - DevSH Graphics Programming Sp. z O.O.
// This file is part of the "Nabla Engine".
// For conditions of distribution and use, see copyright notice in nabla.h
#ifndef _NBL_ASSET_MATERIAL_COMPILER_V3_C_REFERENCE_UNIDIRECTIONAL_PATH_TRACING_H_INCLUDED_
#define _NBL_ASSET_MATERIAL_COMPILER_V3_C_REFERENCE_UNIDIRECTIONAL_PATH_TRACING_H_INCLUDED_

#include "nbl/asset/material_compiler3/IBackend.h"

namespace nbl::asset::material_compiler3
{

class CReferenceUnidirectionalPathTracing final : public IBackend
{
public:
class CResult final : public IBackend::IResult
{
public:
std::string fragmentShaderSource_common;
std::string fragmentShaderSource_raytracingPipeline; // only maps entry point to templated funcs
};

core::smart_refctd_ptr<CResult> compile(const CTrueIR* ir, const std::span<const CTrueIR::SMaterialHandle> materials);

private:
struct TraversalNodeInfo
{
const CTrueIR::INode* node;
bool isTransmission;
};

void traverseIRNode(const CTrueIR::INode* node, const CTrueIR* ir, core::vector<CTrueIR::typed_pointer_type<const CTrueIR::INode>>& nodeStack, core::unordered_map<CTrueIR::typed_pointer_type<const CTrueIR::INode>, TraversalNodeInfo>& nodeInfos);

std::string getHashAs4UintsString(const CTrueIR::INode* node, const CTrueIR* ir, const std::string& separator = ",") const;

bool isNodeTypeContributor(CTrueIR::INode::EFinalType type) const;
void getMaterialDeclarationCode(std::ostringstream& sstr, const CTrueIR::INode* node, const CTrueIR* ir);
void getCacheDefineCode(std::ostringstream& sstr, const TraversalNodeInfo& nodeInfo, const CTrueIR* ir);

void getAlbedoHLSLCode(std::ostringstream& sstr, const TraversalNodeInfo& nodeInfo, const CTrueIR* ir);
void getNormalHLSLCode(std::ostringstream& sstr, const TraversalNodeInfo& nodeInfo, const CTrueIR* ir);
void getAOVThroughputHLSLCode(std::ostringstream& sstr, const TraversalNodeInfo& nodeInfo, const CTrueIR* ir);
void getTransparencyHLSLCode(std::ostringstream& sstr, const TraversalNodeInfo& nodeInfo, const CTrueIR* ir);
void getGenerateHLSLCode(std::ostringstream& sstr, const TraversalNodeInfo& nodeInfo, const CTrueIR* ir);
void getQuotientWeightHLSLCode(std::ostringstream& sstr, const TraversalNodeInfo& nodeInfo, const CTrueIR* ir);
void getEvalWeightHLSLCode(std::ostringstream& sstr, const TraversalNodeInfo& nodeInfo, const CTrueIR* ir);
void getEmissionHLSLCode(std::ostringstream& sstr, const TraversalNodeInfo& nodeInfo, const CTrueIR* ir);

void getCanGenerateHLSLCode(std::ostringstream& sstr, const TraversalNodeInfo& nodeInfo, const CTrueIR* ir);
void getChoiceTargetHLSLCode(std::ostringstream& sstr, const TraversalNodeInfo& nodeInfo, const CTrueIR* ir);

void getCookTorranceBxDFHLSLCode(const CTrueIR::CCookTorrance* cook_torrance, const CTrueIR* ir, std::string& bxdf_type, std::string& fresnel_create);
};

}

#endif
25 changes: 25 additions & 0 deletions include/nbl/asset/material_compiler3/IBackend.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright (C) 2018-2026 - DevSH Graphics Programming Sp. z O.O.
// This file is part of the "Nabla Engine".
// For conditions of distribution and use, see copyright notice in nabla.h
#ifndef _NBL_ASSET_MATERIAL_COMPILER_V3_I_BACKEND_H_INCLUDED_
#define _NBL_ASSET_MATERIAL_COMPILER_V3_I_BACKEND_H_INCLUDED_

#include "nbl/asset/material_compiler3/CTrueIR.h"

namespace nbl::asset::material_compiler3
{

class IBackend : public core::IReferenceCounted
{
public:
class IResult : public core::IReferenceCounted
{

};

core::smart_refctd_ptr<IResult> compile(const CTrueIR*, const std::span<const CTrueIR::SMaterialHandle>);
};

}

#endif
1 change: 1 addition & 0 deletions src/nbl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ set(NBL_ASSET_SOURCES
# Materials
asset/material_compiler3/CFrontendIR.cpp
asset/material_compiler3/CTrueIR.cpp
asset/material_compiler3/CReferenceUnidirectionalPathTracing.cpp

# Shaders
asset/utils/ISPIRVOptimizer.cpp
Expand Down
Loading
Loading