Accessing View struct from custom .usf shader causes undeclared identifier error

Hi everyone,

I’m writing a custom shader in a .usf file and I’m trying to access the View uniform buffer (e.g. View.ViewProjectionMatrix, etc.). However, the shader compiler errors out with:

error: use of undeclared identifier 'View'; did you mean 'new'?

On the C++ side, my shader derives from FGlobalShader, and I’ve added the following parameter:

SHADER_PARAMETER_STRUCT_REF(FViewUniformShaderParameters, View)

The shader compiles fine on the C++ side, but inside the .usf file the View symbol is still not defined.

I’ve also tried including common headers like:

#include "/Engine/Private/Common.ush"
#include "/Engine/Private/SceneTexturesCommon.ush"

but the issue persists.

What is the correct way to expose and access the View uniform buffer inside a custom .usf shader?
Am I missing a required include, binding step, or macro on the shader side?

Any guidance or minimal working example would be greatly appreciated.

Thanks!

1 Like

I have encountered same issuse. There is a temproal fix. For example, use View_ViewRectMin.xy rather than View.ViewRectMin.xy

1 Like

Thank you! I’ll have to try that out.

Also good to know I’m not the only one experiencing this.

Also, this issue might caused by using parameters which name has changed. Such as View.PreViewTranslation now become two seperated parameters, View.PreViewTranslationHigh and View.PreViewTranslationLow

1 Like