Shaders

Shaders are programs you use to create appropriate levels of light and color in an image, to produce special effects, or do post-processing. Shaders in Kanzi are based on the OpenGL ES 2.0 shading language.

Each material type in Kanzi comes with shaders that define the shading algorithm. The shaders consist of vertex shaders (.vert.glsl) and fragment shaders (.frag.glsl).

In Kanzi Studio projects shader programs are stored as files on the computer hard drive. When you add shaders to the <KanziWorkspace>/Projects/<ProjectName>/Shaders directory of your Kanzi Studio project, Kanzi Studio automatically shows them in the Library > Resource Files > Shaders.

You can find the shaders that come with Kanzi in <KanziInstallation>/Studio/Asset Library/MaterialTypes:

Kanzi comes with these shaders:

Type Shader Description
Common ColorTexture Displays colored texture data.
DefaultBlit Default shader used by the Blit Render Pass. See Rendering.
FontDefault Renders text font. This shader combines the glyph texture with font color and displays the output. You can use it with the Text Block 3D and Text Block 2D nodes. See Using the Text Block nodes.
MaskTexture Displays texture data where one texture masks another texture.
SweepTextures Displays texture data with a transition from one texture to another.
Textured Displays texture data. See Textures and Creating textured materials.
FragmentPhong FragmentPhong Implements the Blinn-Phong shading model. By default this shader supports one directional, one spot light, and two point lights. The shader calculates the lighting for each fragment.
FragmentPhongCube Displays cube map reflection, calculated from the view vector and reflection of the surface normal, and combines the result with the Phong shading.
FragmentPhongSkinned Displays skinned mesh data. See Using skinned meshes.
FragmentPhongTextured Displays texture data you can use on 3D nodes. See Textures and Creating textured materials.
FragmentPhongTexturedSkinned Combines the FragmentPhongSkinned and FragmentPhongTextured shaders.
FragmentPhongTexturedCube Combines the FragmentPhongCube and FragmentPhongTextured shaders.
FragmentPhongTexturedNormalMap Calculates the surface normal based on mesh geometry and deforms it using additional normal map. The NormalMapStrength property controls how much the normals are deformed.
FragmentPhongTexturedCubeNormalMap Combines the FragmentPhongTexturedNormalMap shader with cube map reflection, calculated from the view vector and reflection of the surface normal.
VertexPhong VertexPhong Implements the Blinn-Phong shading model. By default this shader supports one directional, one spot light, and two point lights. The shader calculates the lighting for each vertex.
VertexPhongCube Displays cube map reflection, calculated from the view vector and reflection of the surface normal, and combines the result with the Phong shading.
VertexPhongMorph Enables morphing. See Using Morph resources.
VertexPhongSkinned Displays skinned mesh data. This shader transforms vertices based on multiple transformations and weights, and combines the result with the Phong shading.
If you define the matrix palette and weights in a third-party content creation tool, they are part of mesh attributes.
This shader is not compatible with geometry that does not contain skin data (matrix palette and weights) in mesh data.
See Using skinned meshes.
VertexPhongTextured Displays texture data you can use on 3D nodes. See Textures and Creating textured materials.
VertexPhongTexturedCube Combines the VertexPhongCube and VertexPhongTextured shaders.
VertexPhongTexturedMorph Combines the VertexPhongMorph and VertexPhongTextured shaders.
VertexPhongTexturedSkinned Combines the VertexPhongSkinned and VertexPhongTextured shaders.
   

You can also write your own shaders. See Editing shaders.

In Kanzi you can also use binary shaders. Binary shaders are shader programs you pre-compile with compilers provided by hardware manufacturers before the application passes them to the device GPU. This enables your target device to load your application faster. See Using binary shaders.

See also

Shaders best practices

Using binary shaders

Optimizing fragment shaders

Reducing shader switches

Editing shaders

Material types and materials

Using the light nodes