Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


PreprocessVariant

Preprocesses a shader variant for this shader pass and returns the preprocessed code.
Read time 4 minutesLast updated 5 days ago

Definition

  • Type: Method
  • Namespace: UnityEditor
  • Assembly: UnityEditor.CoreModule

PreprocessVariant(ShaderType, string[], ShaderCompilerPlatform, BuildTarget, bool)

Preprocesses a shader variant for this shader pass and returns the preprocessed code.
public ShaderData.PreprocessedVariant PreprocessVariant(ShaderType shaderType, string[] keywords, ShaderCompilerPlatform shaderCompilerPlatform, BuildTarget buildTarget, bool stripLineDirectives)

Parameters

shaderType

The shader type within this pass to preprocess. (e.g. Vertex, Fragment, etc.) Some platforms (OpenGLCore, GLES3x, Switch and Vulkan) include all stages within the Vertex shader type.

keywords

The keywords to use during the preprocessing.

shaderCompilerPlatform

The shader compiler platform to preprocess for.

buildTarget

The build target to preprocess for.

stripLineDirectives

Whether to skip line number directives in the preprocessed output. When enabled, Unity produces more human-readable preprocessed source code and skips the line directives when the file name doesn't change. Otherwise, this method produces the exact preprocessed source that Unity passes to the compiler.

Returns

Type

Description

PreprocessedVariantThe preprocessed variant result. If the pass doesn't include the requested program, or if the pass is not the correct type, this function still succeeds but returns empty preprocessed code.

PreprocessVariant(ShaderType, string[], ShaderCompilerPlatform, BuildTarget, GraphicsTier, bool)

Preprocesses a shader variant for this shader pass and returns the preprocessed code.
public ShaderData.PreprocessedVariant PreprocessVariant(ShaderType shaderType, string[] keywords, ShaderCompilerPlatform shaderCompilerPlatform, BuildTarget buildTarget, GraphicsTier tier, bool stripLineDirectives)

Parameters

shaderType

The shader type within this pass to preprocess. (e.g. Vertex, Fragment, etc.) Some platforms (OpenGLCore, GLES3x, Switch and Vulkan) include all stages within the Vertex shader type.

keywords

The keywords to use during the preprocessing.

shaderCompilerPlatform

The shader compiler platform to preprocess for.

buildTarget

The build target to preprocess for.

An optional graphics tier.

stripLineDirectives

Whether to skip line number directives in the preprocessed output. When enabled, Unity produces more human-readable preprocessed source code and skips the line directives when the file name doesn't change. Otherwise, this method produces the exact preprocessed source that Unity passes to the compiler.

Returns

Type

Description

PreprocessedVariantThe preprocessed variant result. If the pass doesn't include the requested program, or if the pass is not the correct type, this function still succeeds but returns empty preprocessed code.

PreprocessVariant(ShaderType, string[], ShaderCompilerPlatform, BuildTarget, BuiltinShaderDefine[], bool)

Preprocesses a shader variant for this shader pass and returns the preprocessed code.
public ShaderData.PreprocessedVariant PreprocessVariant(ShaderType shaderType, string[] keywords, ShaderCompilerPlatform shaderCompilerPlatform, BuildTarget buildTarget, BuiltinShaderDefine[] platformKeywords, bool stripLineDirectives)

Parameters

shaderType

The shader type within this pass to preprocess. (e.g. Vertex, Fragment, etc.) Some platforms (OpenGLCore, GLES3x, Switch and Vulkan) include all stages within the Vertex shader type.

keywords

The keywords to use during the preprocessing.

shaderCompilerPlatform

The shader compiler platform to preprocess for.

buildTarget

The build target to preprocess for.

platformKeywords

An optional set of platform keywords. If you do not provide any, Unity uses the default keywords for the given platform, target, and tier.

stripLineDirectives

Whether to skip line number directives in the preprocessed output. When enabled, Unity produces more human-readable preprocessed source code and skips the line directives when the file name doesn't change. Otherwise, this method produces the exact preprocessed source that Unity passes to the compiler.

Returns

Type

Description

PreprocessedVariantThe preprocessed variant result. If the pass doesn't include the requested program, or if the pass is not the correct type, this function still succeeds but returns empty preprocessed code.

PreprocessVariant(ShaderType, string[], ShaderCompilerPlatform, BuildTarget, BuiltinShaderDefine[], GraphicsTier, bool)

Preprocesses a shader variant for this shader pass and returns the preprocessed code.
public ShaderData.PreprocessedVariant PreprocessVariant(ShaderType shaderType, string[] keywords, ShaderCompilerPlatform shaderCompilerPlatform, BuildTarget buildTarget, BuiltinShaderDefine[] platformKeywords, GraphicsTier tier, bool stripLineDirectives)

Parameters

shaderType

The shader type within this pass to preprocess. (e.g. Vertex, Fragment, etc.) Some platforms (OpenGLCore, GLES3x, Switch and Vulkan) include all stages within the Vertex shader type.

keywords

The keywords to use during the preprocessing.

shaderCompilerPlatform

The shader compiler platform to preprocess for.

buildTarget

The build target to preprocess for.

platformKeywords

An optional set of platform keywords. If you do not provide any, Unity uses the default keywords for the given platform, target, and tier.

An optional graphics tier.

stripLineDirectives

Whether to skip line number directives in the preprocessed output. When enabled, Unity produces more human-readable preprocessed source code and skips the line directives when the file name doesn't change. Otherwise, this method produces the exact preprocessed source that Unity passes to the compiler.

Returns

Type

Description

PreprocessedVariantThe preprocessed variant result. If the pass doesn't include the requested program, or if the pass is not the correct type, this function still succeeds but returns empty preprocessed code.