[UE4.25] "ShaderInPlugin" guide no longer working

Hello!

I can no longer compile the “Create a New Global Shader as a Plugin” documentation graphics programming guide as of Unreal Engine 4.25.

There is an issue with the following code, it was previously working in 4.24.


// Get shaders.
        TShaderMap<FGlobalShaderType>* GlobalShaderMap = GetGlobalShaderMap(FeatureLevel);
        TShaderMapRef< FLensDistortionUVGenerationVS > VertexShader(GlobalShaderMap);
        TShaderMapRef< FLensDistortionUVGenerationPS > PixelShader(GlobalShaderMap);
...
GraphicsPSOInit.BoundShaderState.VertexShaderRHI = GETSAFERHISHADER_VERTEX(*VertexShader);
GraphicsPSOInit.BoundShaderState.PixelShaderRHI = GETSAFERHISHADER_PIXEL(*PixelShader);


Error    C2440    'initializing': cannot convert from 'FGlobalShaderMap *' to 'TShaderMap<FGlobalShaderType,FShaderMapPointerTable> *'
Error    C2664    'TShaderMapRef<FLensDistortionUVGenerationVS>::TShaderMapRef(TShaderMapRef<FLensDistortionUVGenerationVS> &&)': cannot convert argument 1 from 'TShaderMap<FGlobalShaderType,FShaderMapPointerTable> *' to 'const FLensDistortionUVGenerationVS::ShaderMapType *'
Error    C2664    'TShaderMapRef<FLensDistortionUVGenerationPS>::TShaderMapRef(TShaderMapRef<FLensDistortionUVGenerationPS> &&)': cannot convert argument 1 from 'TShaderMap<FGlobalShaderType,FShaderMapPointerTable> *' to 'const FLensDistortionUVGenerationPS::ShaderMapType *'
Error    C3861    'GETSAFERHISHADER_VERTEX': identifier not found
Error    C3861    'GETSAFERHISHADER_PIXEL': identifier not found

I cannot find a changelog documentation about it.

Fixed it myself, similar to the incompatibility issue with NewTek NDI SDK for Unreal Engine.
Read about it in here: https://forums.newtek.com/showthread.php/162129-NDI-with-Unreal-Engine?p=1593609&viewfull=1#post1593609

1 Like

Hi, the linked post is not working anymore, can you share the solution?

Thanks in advanced

I found a possible solution in engine source code.[Engine\Source\Runtime\Renderer\Private\LightRendering.cpp]

	TShaderMapRef< FDeferredLightPS > PixelShader( View.ShaderMap, PermutationVector );
	GraphicsPSOInit.BoundShaderState.VertexDeclarationRHI = GetVertexDeclarationFVector4();
	GraphicsPSOInit.BoundShaderState.VertexShaderRHI = VertexShader.GetVertexShader();
	GraphicsPSOInit.BoundShaderState.PixelShaderRHI = PixelShader.GetPixelShader();
1 Like

Thanks