Vertex Offset Flickering on Cylinder Material

Hi,

I would like to report an issue I’m experiencing with a material in Unreal Engine. I am creating a material that simulates painting a cylinder based on screen coordinates.

My setup is as follows: I take the difference between the WorldPosition and the CameraPosition, calculate the distance, multiply it by a small offset value, and then multiply the result by the VertexNormal. Finally, I connect this to the WorldPositionOffset input.

The problem occurs when I apply this material to a cylinder: if the cylinder is not selected in the viewport, it flickers while the vertices are being displaced.

I would appreciate any guidance or insight into why this might be happening and i 've attached the project.zip with the material and cylinder so you can take a look.

Thank you,

Alex.

[Attachment Removed]

Steps to Reproduce

  • Create a new material and enable Used with Vertex Offset.
  • Subtract CameraPosition from WorldPosition, calculate the distance, multiply by a small scalar, multiply by VertexNormal, and connect to WorldPositionOffset.
  • Apply the material to a cylinder in the scene.
  • Observe flickering in the viewport when the cylinder is not selected.
  • The displacement works correctly when the cylinder is selected or in-game, but flickers in the viewport when not selected.
  • It happens from UE >= 5.3

[Attachment Removed]

Repo Project:

https://drop.brainstorm3d.com/wl/?id\=WI1DnNfDHKBkj3KYl9fEx0KzfCzmRA9S

[Attachment Removed]

Hi Alex,

What’s happening there is an instability on the result of the Hardware Occlusion Queries performed by the engine. This can happen when World Position Offset (WPO) moves vertices of an object outside of its own bounds. In your case, the visible pixels are completely occluding the original bounding box of the object, causing the queries to fail every other frame and producing the flickering as you observed.

The following console commands can help you visualize the problem:

  • ShowFlag.VisualizeOutOfBoundsPixels 1 (also available through the Eye icon on the viewport -- Visualize -- Out of Bounds Pixels) - This will show the offending pixels in a yellow-cyan diagonally striped pattern
  • ShowFlag.Bounds 1 (also available through the Eye Icon -- Advanced -- Bounds) - This will show the culling bounds of the selected actor as a reddish box)
  • r.VisualizeOccludedPrimitives 1 - This will draw in green the bounds of any geometry that was occluded on a frame
  • r.AllowOcclusionQueries 0 - This will completely disable Occlusion Queries (the flickering should stop)
  • ShowFlag.DisableOcclusionQueries 1 - Same as the previous

There are two direct ways to fix the problem:

A) On the material that makes use of WPO, look in the Details Tab for “World Position Offset -- Max World Position Offset Displacement”. If you set this to anything higher than zero, the culling bounds of any mesh that uses the material will be automatically extended by that amount, and any offset produced by the material will also be clamped to that.

B) On the Level Editor, select the Static Mesh Components of the Actors that you want to change. Look in the Details Tab for “Rendering -- Advanced -- Bounds Scale”, and increase it above 1 as much as needed to eliminate the possibility of any out-of-bounds pixels.

Let me know if this helps!

Best regards,

Vitor

[Attachment Removed]

Hi Vitor,

Thank you very much for the detailed explanation and the troubleshooting steps.

Both of the solutions you suggested worked correctly on my end. I decided to go with option A (setting the Max World Position Offset Displacement on the material), since I plan to apply this material to multiple objects and this approach lets me fix the issue without having to modify each Static Mesh individually.

Just out of curiosity: do you know if the Max World Position Offset Displacement value corresponds to a specific unit of measurement in world space, or is it simply treated as a generic scale/clamp value internally?

Thanks again for the help!

Best regards,

Alex

[Attachment Removed]

I believe it is a simple clamp internally, which would mean the same unit of measurement as World Position Offset itself (i.e. world space, centimeters by default). But using that setting should guarantee that no pixels are generated out-of-bounds because of WPO.

Best,

Vitor

[Attachment Removed]