When using materials with CustomData inputs, such as the Eye material with Iris Distance and Mask, Virtual Texture samples will increase the instruction count for each unique VTPageResult.
Each custom data pin connection will duplicate the material graph into the GetCustomData<X> function, where X appears to be the index of the custom data pins. For non-virtual textures, the samplers have no side-effects, and the compiler will correctly identify that no data dependency exists. In this case, the function will be elided.
Unforunately, Virtual Texture's use TextureLoadVirtualPageTable to get a VTPageTableResult struct that is used in the virtual texture sample. The sample itself is elided as nothing depends on it; however, the TextureLoadVirtualPageTable is not elided as it appears to have a side-effect. Looking at the DXIL, it appears the VTPageResult.PackedRequest is being written to 7 addresses, including the VirtualTextureFeedback member of the MaterialParameters struct.
The net result of this superfluous operation is the addition of 67 instructions per TextureLoadVirtualPageTable call.
Expectation: Instruction count is the same or similar
Result: The instruction count increases by an unexpected amount for a parameter. In testing, 67 instructions was the most common increase.
Git Diff shows the following difference between the constant and parameterised versions:
-'s are the code from the parameterised version
+'s are the code from the constant version
float GetMaterialCustomData0(in out FMaterialPixelParameters Parameters)
{
- float3 Local0 = lerp(float3(0.00000000,0.00000000,0.00000000),Material_PreshaderBuffer[0].yzw,Material_PreshaderBuffer[0].x);
- float2 Local1 = Parameters.TexCoords[0].xy;
- float Local2 = 1.0f;
- VTPageTableResult Local3 = TextureLoadVirtualPageTable(Material_VirtualTexturePageTable0_0, VTPageTableUniform_Unpack(Material_VTPackedPageTableUniform[0*2], Material_VTPackedPageTableUniform[0*2+1]), Local1 , 1u, 1u, View_MaterialTextureMipBias, Parameters.SvPosition.xy, 0U + 0, Parameters.VirtualTextureFeedback);
- float4 Local4 = TextureVirtualSample(Material_VirtualTexturePhysical_0, Material_VirtualTexturePhysical_0Sampler, Local3, 0, VTUniform_Unpack(Material_VTPackedUniform[0]));
- float Local5 = 1.0f;
- float Local6 = 1.0f;
- return Material_PreshaderBuffer[1].y;;
+ return 0.00000000;;
}
I am not able to find world outliner how to enable it?
What method is used to fill polygonal regions when drawing spline mesh at run time?
How to achieve HLSL Multiple Render Target in Material blueprints?
How does UMG set overlapping layouts?
How does TextureRenderTarget2D get TArray<uint8> type data?
How can PaintContext be used as function parameter in OnPaint?
How to properly terminate the DoWork thread function in FAsyncTask?
Undefined sysmbol: typeinfo for AActor when cross-compile linux dedicated server on windows
There's no existing public thread on this issue, so head over to Questions & Answers just mention UE-232142 in the post.
2 |
Component | UE - Rendering Architecture - Materials |
---|---|
Affects Versions | 5.5, 5.4.4 |
Target Fix | 5.6 |
Created | Dec 4, 2024 |
---|---|
Updated | Dec 5, 2024 |