Version: 2023.1
언어: 한국어
Experimental: this API is experimental and might be changed or removed in the future.

ShaderWarmup.WarmupShader

매뉴얼로 전환
public static void WarmupShader (Shader shader, Experimental.Rendering.ShaderWarmupSetup setup);

설명

Prewarms all shader variants for a given Shader, using a given rendering configuration.

For information on shader loading and prewarming, including a list of different prewarming techniques, see Shader loading.

Unity needs more information to correctly build GPU representations of the shader variants ('pipeline state objects' or PSOs) if your application runs on one of the following graphics APIs: DirectX 12 Metal Vulkan If Unity has this information, it's more likely the prewarmed variants match what the GPU needs when it renders your Scene.

To provide Unity with more information, you can do the following: Use the setup parameter to specify the vertex data layout you use with the shader. Before you call WarmupShader, set the render state so it's as close as possible to the state you use with the shader. For example, set the format of the render target, or use render state commands to set states such as blend mode. Unity also asynchronously prewarms shader variants using multiple background threads, if your application runs on a platform that supports it. Unity uses as many threads as it can. In your built application, you can use the -max-async-pso-job-count command line argument to set the number of threads Unity uses.

See Also: ShaderWarmup.WarmupShaderFromCollection, Shader.WarmupAllShaders, ShaderVariantCollection.WarmUp