在4.25.1上搞成了。ue4真坑
I make it work in 4.25.1. Hope can help somebody
//kernel size
int sizeX = 5;
int sizeY = 5;
MaterialFloat2 UV=GetDefaultSceneTextureUV(Parameters, 8);
//offset added to all uvs to get from the center to the corner
MaterialFloat2 baseOffset = MaterialFloat2(-sizeX/2.0f, -sizeY/2.0f) * offset.rg;
//sample the world normal from the GBuffer
float4 baseNormal = SceneTextureLookup(UV, 8,false);
float minDot = 10.0f;
for (int i = 0; i < sizeX; ++i)
{
for (int j = 0; j < sizeY; ++j)
{
//calucalte clamped uvs
float2 uvs = min(max(UV + baseOffset * scale + i * offset.r * scale.r * float2(1.0, 0.0f) + j * offset.g * scale.g * float2(0.0, 1.0f), float2(0.0f, 0.0f)), float2(1.0f, 1.0f));
//sample world normal from the GBuffer at the new position
float newDot = dot(baseNormal, SceneTextureLookup(uvs, 8,false));
//if smaller than our current value
if (newDot < minDot)
{
//use the new value
minDot = newDot;
}
}
}
return minDot;