Where can I find single material node’s source code?
UnrealEngine\Engine\Source\Runtime\Engine\Private\Materials\MaterialExpressions.cpp
Check the compile functions.
For example the depthfade node:
int32 UMaterialExpressionDepthFade::Compile(class FMaterialCompiler* Compiler, int32 OutputIndex)
{
// Scales Opacity by a Linear fade based on SceneDepth, from 0 at PixelDepth to 1 at FadeDistance
// Result = Opacity * saturate((SceneDepth - PixelDepth) / max(FadeDistance, DELTA))
const int32 OpacityIndex = InOpacity.GetTracedInput().Expression ? InOpacity.Compile(Compiler) : Compiler->Constant(OpacityDefault);
const int32 FadeDistanceIndex = Compiler->Max(FadeDistance.GetTracedInput().Expression ? FadeDistance.Compile(Compiler) : Compiler->Constant(FadeDistanceDefault), Compiler->Constant(DELTA));
const int32 FadeIndex = CompileHelperSaturate(Compiler, Compiler->Div(Compiler->Sub(Compiler->SceneDepth(INDEX_NONE, INDEX_NONE, false), Compiler->PixelDepth()), FadeDistanceIndex));
return Compiler->Mul(OpacityIndex, FadeIndex);
}
Wanna make your own material nodes? Check out this:
UnrealEngine\Engine\Documentation\Source\Programming\Rendering\MaterialExpressions\CreatingMaterialExpressions.INT
1 Like
Thanks! May be it’s time to learn some UE source code.