UE5.1 PostProcess Custom Shader 100x slowdown (Kuwahara Filter)

I am running a PostProcess material that invokes HLSL code which involves a nested for-loop doing scene texture lookups.

 for (int i = 0; i < 4; i++)
        {
            for (int j = 0; j <= Radius.x; j++)
            {
                for (int k = 0; k <= Radius.y; k++)
                {
                    [stuff]

                    col = SceneTextureLookup(uvPos, 14, false);
                    [stuff]

                }
            }
        }

In Unreal 5.0.3 this material cost me about 0.5ms. In 5.1 it is costing me over 80ms, with no apparent changes to the material. I verified SM6 DX12 and Vulkan. Clearly there is a change in the rendering pipeline that is affecting this, but I could not find an obvious culprit in the changelog.

Does anybody know what might have changed?

Only other thing of note is that I am using ViewportUVToSceneTextureUV(UV,14) in a separate custom node…other than that, the material itself is straightforward.

1 Like

They recently did some changes to the shader code for Unreal Engine Version 5.1. I am not sure if I know the full reason for why you are experiencing these issues, all I know is that the default shading model is set to 6.

Here are the release notes: Unreal Engine 5.1 Release Notes | Unreal Engine 5.1 Documentation. I would sugget that you perhaps go through all relevant changes, to see what may have changed, and then alter your shader in accordance.

Hi, thanks for your reply. Yes, I confirmed the behavior in SM6 and in Vulkan, so it seems that just the switch to SM6 would not explain it. I did go through the changelog but it was not granular enough to show me actual API differences in the RHI, so now I’m looking through Github and taking a look at differences in frames between 5.0.3 and 5.1 in RenderDoc.

1 Like

Oh god, I’m sorry you have to do that… please let me know if you figure it out.

Hopefully someone else are able to point out the reason why it is happening.

Hey!
I experience the same issue with a directional Kuwahara shader!
To be honest, I was quite happy to find this topic and to see that this seems to be in issue with SM6 - i though my shader implementation sucks big time! :slight_smile:

Anything came up about this issue yet?
I switched back to SM5 but get warnings that Nanite and Virtal Shadow Maps won’t work unless I switch to SM6.
With SM6, my PPM performance drops and is unusable.

5.1.1 still got the same problem!
Hope they fix this soon - it’s unusable