<shader> ‐ A shader-based rendering
This element defines the shader property of a node. A shader property is made of two shader programs (a vertex shader and a fragment program or pixel shader) for programmable graphics hardware that are used to produce interactive graphic rendering. These programs can use OpenGL parameters produced by Virtual Choreographer (vertex, normal and light positions). They also possibly rely on textures given in the shader_source child element.
The vertex and fragment programs are written in Cg language http://www.nvidia.com/developer that is documented in the Cg language online reference manual http://www.nvidia.com/developer. A minimal knowledge of this programing language is necessary to understand and create sample shaders.
The shader programs are defined in the vertexShader and fragmentShader children element and the shader parameters, including additional shader_source_textures, are defined in the shader_source child element.
The string value of the type attribute is equal to general in the case of a general shader. Only this type of shader that is currently documented. Two other types of shaders, burst for dynamic texture blending and bump for bump mapping are also available. They will be documented in later versions of the software when they will be stabilized.
Each shader requires a base texture or video that must be provided before the shader definition in the material properties of the current media-object.
The following elements must occur in general shaders: vertexShader, fragmentShader, and shader_source.
The example below defines a shader based on the video texture Film/Seine.avi. The shader is displayed on a quad and relies on the cammap-noblend-VP.cg vertex shader and cammap-noblend-FS.cg fragment program. In addition to the base video texture, these two programs use the textures/silhouette.png texture and the Video/skin.avi video.
<node id="film.1" displayed="true"> <quad id="screen" x1="7.68" y1="0.0" z1="-20.42" x2="7.68" y2="0.0" z2="20.42" x3="-7.68" y3="0.0" z3="20.42" x4="-7.68" y4="0.0" z4="-20.42"> <video xlink:href="Film/Seine.avi" id="Wall" type="videoloop" begin="0.0" end="1000000.0" dur="1000000.0" period="1000000.0" tile_s="(1600/2048)" tile_t="(600/1024)"/> <shader id="video-shader" type="general"> <vertexShader xlink:href="cammap-noblend-VP.cg"/> <fragmentShader xlink:href="cammap-noblend-FS.cg"/> <shader_source id="bump_#1" type="shaderfinite" nb_textures="2" cg_vp_widthRatio="(800.0 / 2048.0)" cg_vp_heightRatio="(600.0 / 1024.0)" cg_fs_blend="0.0" cg_fs_heightfield="0.5" cg_fs_hue="0.0"> <shader_source_texture index="1" encoding="pnga" xlink:href="textures/silhouette.png" id="hand"/> <shader_source_video index="1" xlink:href="Video/skin.avi" id="Wall" type="videoloop" begin="0.0" end="1000000.0" dur="1000000.0" period="1000000.0" /> </shader_source> </shader> </quad> </node>