Neatware Header
Home   Products   Forums   Partners   Buy   Company   Contact   Blog   

8. Vertex and Pixel Shader

8.1 Vertex Shader

Vertex shader is an application object to handle programmable vertex unit. The code could be written in HLSL or assembly language. The vertex command for asm is

	$app vertex asm  [inline|file] name [flags]

It creates a vertex shader with asm code from inline or file name and returns an object variable name. The flags may be the value debug, skipvalidation, or skipoptimization and its default value is zero. The inline tag specifies that the name is an evaluation of an inline function or an asm code string. The file tag specifies that the name is a file path. For example,

	set vt [$app vertex asm file code.vsh debug]

The vertex command for hlsl is

$app vertex hlsl [inline|file] name [function] [version] [flags]

It creates a vertex shader with hlsl code from inline or file name and returns an object variable name. The flags may be the value debug, skipvalidation, or skipoptimization and its default value is zero. The inline tag specifies that the name is an evaluation of an inline function or an asm code string. The file tag specifies that the name is a file path. The function is the function name of hlsl vertex shader and its default is main. The version indicates the version of the vertex shader. It can be vs_1_1, vs_2_0, vs_2_x, vs_3_0 and the default is vs_1_1. For example,

set vt [$app vertex hlsl inline [hlsl_vertex_code] main vs_2_0]

A vertex shader object has several subcommands as active, inactive, release, and set.

  • $vt active starts to execute the vertex shader vt.
  • $vt inactive disables the execution of the vertex shader vt.
  • $vt release finally deletes the vertex shader vt and releases its resource.
  • $vt set type name value assigns a vertex shader constant with one of a type bool, int, float, vector, or matrix. The vector has the float4 type. The name is a uniform parameter in the HLSL function or a global variable name. The value has the corresponding variable type.

8.2 Pixel Shader

Pixel shader is an application object to handle programmable pixel unit. The code could be written in HLSL or assembly language. The pixel command for asm is

	$app pixel asm  [inline|file] name [flags]

It creates a pixel shader with asm code from inline or file name and returns an object variable name. The flags may have value debug, skipvalidation, or skipoptimization and its default value is zero. The inline tag specifies that the name is an evaluation of an inline function or an asm code string. The file tag specifies that the name is a file path. For example,

set pl [$app pixel asm file code.psh debug]

The pixel command for HLSL is

$app pixel hlsl [inline|file] name [function] [version] [flags]

It creates a pixel shader with HLSL code from inline or file name and returns an object variable name. The flags may have value debug, skipvalidation, or skipoptimization and its default value is zero. The inline tag specifies that the name is an evaluation of an inline function or an asm code string. The file tag specifies that the name is a file path. The function is the function name of HLSL pixel shader and its default is main. The version is the version of the pixel shader. It could be ps_1_1, ps_1_2, ps_1_3, ps_1_4, ps_2_0, ps_2_x, ps_3_0 and the default is ps_1_1. For example,

set pl [$app pixel hlsl inline [hlsl_pixel_code] main ps_2_0] 

A pixel shader object has several subcommands as active, inactive, release, and set.

  • $pl active starts to execute the pixel shader pl.
  • $pl inactive disables the execution of the pixel shader pl.
  • $pl release finally deletes the pixel shader pl and releases its resource.
  • $pl set type name value assigns a pixel shader constant with one of a type bool, int, float, vector, or matrix. The vector has the float4 type. The name is a uniform parameter in the HLSL function or a global variable name. The value has the corresponding variable type.