I have made a simple shader called MyTest.usf, and write a c++ VS and PS class for it . Unfortunately, I got ‘Internal Error!’ after shader compiling. There is no more debug info to figure out why.
This is the c++ code and shader code
MyTest.usf
#include "/Engine/Public/Platform.ush"
void MainVS(
in float4 InPosition : ATTRIBUTE0,
out float4 Output : SV_POSITION
)
{
Output = InPosition;
}
// Simple solid color pixel shader
float4 MainPS() : SV_Target0
{
return float4(0,0,0,0);
}
MyTest.cpp
class FMyTestVS : public FGlobalShader
{
DECLARE_GLOBAL_SHADER(FMyTestVS);
SHADER_USE_PARAMETER_STRUCT(FMyTestVS, FGlobalShader);
BEGIN_SHADER_PARAMETER_STRUCT(FParameters, )
END_SHADER_PARAMETER_STRUCT()
static bool ShouldCache(EShaderPlatform Platform)
{
return true;
}
};
IMPLEMENT_GLOBAL_SHADER(FMyTestVS, "/Engine/Private/MyTest.usf", "MainVS", SF_Vertex);
class FMyTestPS : public FGlobalShader
{
DECLARE_GLOBAL_SHADER(FMyTestPS);
SHADER_USE_PARAMETER_STRUCT(FMyTestPS, FGlobalShader);
BEGIN_SHADER_PARAMETER_STRUCT(FParameters, )
RENDER_TARGET_BINDING_SLOTS()
END_SHADER_PARAMETER_STRUCT()
static void ModifyCompilationEnvironment(const FGlobalShaderPermutationParameters& Parameters, FShaderCompilerEnvironment& OutEnvironment)
{
FGlobalShader::ModifyCompilationEnvironment(Parameters, OutEnvironment);
// Add your own defines for the shader code
//OutEnvironment.SetDefine(TEXT("MY_DEFINE"), 1);
}
static bool ShouldCache(EShaderPlatform Platform)
{
// Could skip compiling for Platform == SP_METAL for example
return true;
}
};
IMPLEMENT_GLOBAL_SHADER(FMyTestPS, "/Engine/Private/MyTest.usf", "MainPS", SF_Pixel);
Please help me if you have any idea. I’m freshman of UE, by the way.