Virtual Texture sampling in Niagara works in editor but not in packaged builds or standalone

Setting particle color by sampling Virtual Texture assets in Niagara works as expected in the editor, but fails in packaged builds.

Expected result:

Niagara particles should be able to sample from Virtual Texture assets the same way they do from regular textures, with consistent results between Play In Editor and packaged builds.

Actual result:

In packaged builds, Niagara particles that sample Virtual Texture assets appear colorless.

Steps to Reproduce

  1. Right click a regular texture asset and convert it to a Virtual Texture. (Virtual Texture Support is enabled in settings.)
  2. Create a Niagara System with an emitter that uses the Sample Texture module to set Particle Color during Particle Spawn.
  3. Choose the Virtual Texture asset to sample from in the Sample Texture module.
  4. Use a Random Range Vector 2D for the UV input.
  5. Create a sprite material that uses Particle Color node for Emissive Color.
  6. Play in Editor and observe that it works fine to sample Virtual Textures in Niagara, the particles are sampling the color from the texture.
  7. Create a packaged build of this same setup.
  8. Run the packaged build, and observe that it doesn’t work to sample Virtual Textures in packaged build, the particles appear colorless.

Hey!

The sample texture module currently doesn’t support virtual textures (VT). I’ll open a bug ticket so that it at least displays a warning if you try to sample from an unsupported texture type (there are more texture types like volume textures that are also accepted as inputs and don’t work).

Instead of the sample texture module, you can try to use a scratch pad with a “virtual texture sample” data interface added as input and sample your VT like this:

[Image Removed]

Make sure the VT itself works in the level by using it in a material for example.

Regards,

Michael

Hi Michael. I’m a colleague of OP, who is currently away.

Thanks for your reply. We will try the scratch pad method and see if that works.

Do you have any information as to why the Sample Texture module would work with Virtual Textures in the editor but not in builds? A warning on the module when inputting an invalid texture would be useful, but if it works in editor, yet not in builds, the warning should explicitly mention that, since otherwise it could seem confusing.

Hey Claud!

I don’t know why exactly it can still sample the VT in the editor, but it’s also not really surprising. There is a lot of data around in editor mode that it removed during the cook, things are kept in memory in the editor for faster iteration (like texture mips) that are not in memory at runtime, etc. That’s why it’s always a good idea to have a nightly cook in place for your project to be able easily test and verify that things work in a packaged game on a regular basis.

Yeah, I’ll make sure the warning on the module is as explicit as possible.

Regards,

Michael