Where can I read the HLSL code of the currently present Material editor functions?
I want to write a few custom nodes but, I don’t have time to learn HLSL as for now. So I just want to check how some pre-exsisting material function codes are written and learn from there.
I tried to find the material function codes but I couldn’t.
If you want to see the guts of where the HLSL actually gets generated for the nodes. Then you will need to look at Source\Runtime\Engine\Private\Materials\HLSLMaterialTranslator.h start looking around Line 1510. You will see different functions for the different nodes, which are called from the MaterialExpressions.cpp classes. So if you wanted to add your own. You would:
create a new class based on UMaterialExpression overriding the Compile function at a minimum
From the compile function you will want to call Compiler->YourNewFunction( Input.Compile( Compiler ) );
Add a new function to FMaterialCompiler in MaterialCompiler.h matching the name you used above
Implement the function in FProxyMaterialCompiler in the same file
Implement the function in FHLSLMaterialTranslator in HLSLMaterialTranslator.h
And that should be it. I have done this in the past, but am going off of memory here, so if I missed a step, sorry.
Thanks, I did find some info on a few functions although I didn’t understand much. I want to add a few custom noise generating functions so I wanted to see its already existing noise function.
But all I found on the existing noise function other than this
That particular node, is adding a function call in the shader to MaterialExpressionNoise which can be found in Common.usf. So if you wanted to add your own noise functions. You could model off that same Noise function and just add your additional custom noise functions to Common.usf
If you look at MaterialExpressionNoise.h and MaterialExpressions.cpp. You will see that the compile function for that class calls Compiler->Noise. Which is the function your looking at above. So I would base my class off of the UMaterialExpressionNoise class.