From PopcornFX
Jump to navigation Jump to search
! IMPORTANT ! This is a PopcornFX v1 page. PopcornFX v2 UE4 plugin documentation can be found here

(last edit version: IN THE FUTURE)

Virtual Texture Override is a way to GLOBALY replace any texture's pixel data by your own data via blueprint functions.

Sampler Texture SampleRawValues

First create a CParticleSamplerTexture and set:

  • TextureResource to a placeholder texture
The texture pixels data will be replaced later.
  • ScriptOutputType to the right future pixel data: Float (Luminance), Float3 (RGB), Float4 (RGBA).
It must match to future data, or PopcornFX will duplicate and convert the Texture.
  • enable SampleRawData
PopcornFX will try to NOT duplicate data nor convert. But if it must, it will log warnings.

Texture/_VirtualTexture_Test.png, float4 (RGBA Float32)

Register Virtual Texture Override

Use the Blueprint functions RegisterVirtualTextureOverride_* and UnregisterVirtualTextureOverride_* to globaly override an texture asset pixel data.

Example continue

Performance !

Look in Window >> Developer Tools >> Output log. If it prints something like:

 LogPopcornFX:Warning: [1][HH_PARTICLES]> Cannot SampleRawValues, Sampler 'MyImage' needs Fp32Lum, but image 'Textures/_VirtualTexture_Test._VirtualTexture_Test' is Fp32RGBA. Will convert. (Particles/Pk_VirtTexTest.pkfx/CParticleSamplerTexture_50201B9E)

It means a sampler named "MyImage" is set to float but you probably Register a Virtual Texture with a TArray<FLinearColor> (so Fp32RGBA, float4). So PopcornFX will duplicate and convert the pixel data.

Your sampler's ScriptOutputType must match the dimension of the texture data you sample (of the "true" texture, and of the virtual texture override data) (and not compressed).