(Bailey and Cunningham, 2012). Listing 1 presents
exemplary part of simple shader, and listing 2
presents the same part after simple optimization by
replacing few processor instruction with one, which
is equivalent to: (A - 0.3) × 2.5 = A × 2.5 + ( -0.75 ).
It is easy to imagine, the code complication level of
a typical, optimized shader.
Listing 1. Part of exemplary shader.
def c0, 0.3, 2.5, 0 , 0
textld r0, t0
sub r0, r0, c0.x
mul r0, r0, c0.y
Listing 2. Part of exemplary shader after
optimization.
def c0, -0.75, 2.5, 0 , 0
textld r0, t0
mad r0, r0, c0.y, c0.x
The need for more programmer friendly syntax was
obvious. Next step in evolution of languages for
programing shaders has been triggered by popularity
of C / C++ languages. Their programmer friendly
syntax was inspiration for High Level Shader
Language (HLSL) for DirectX (Feinstein, 2013),
OpenGL Shading Language (GLSL) for OpenGL
(Rost et. al., 2010) and Cg language for both
platforms. They became popular as they speed-up
development process, ease-up maintaining code and
decrease number of code version iterations needed to
obtain final effect. Listing 3 presents exemplary
shader written using C / C++ like language.
Listing 3. Basic shader written in C / C++ like
language.
void main (void)
{
vec4 base = texture2D(text, uv);
gl_FragColor.rgb = mix(
gl_Fog.color.rgb,
base.rgb * ambient,
fog_param );
gl_FragColor.a = base.a;
}
Currently, in parallel to the above mentioned
languages, state of the art (sharing in some degree
MDE concepts) solutions exist. They are developed
and published along with well-known commercial
and open source projects for 3D graphics
manipulation and game design. The nature of such
projects - releasing to the broad audience of users,
implies the need for maximal ease of converting
designer’s concepts to the shader language. The
approaches worth mentioning are presented below.
Blender’s Node Editor. The concept of designing
materials covering the objects has been made
available to basic level users by utilizing Node
Editor. It allows to graphically mount visual effects
applied to the material. The whole process of
designing effect is reduced to connecting graphical
units (nodes) and adjusting parameters. The
connection is kept in tree model allowing for many
outputs and single input of a node. The graphical
representation of a node allows for in-place
presentation of the effect acquired at the specific
point (Valenza, 2013). The example of whole
concept is presented in the figure 1. The nodes
available for designer are grouped into sets
dedicated to different aspects of material creation.
The user of Node Editor is required only to possess
knowledge about specific material creation, without
the need to understand low or high level shader
language.
3DS Max Slate Material Editor. The Slate
Material Editor is designed according to the same
concepts, thus the overall look of it is similar to the
Node Editor. One can argue which one borrows
concepts from which. The design elements are
divided into Material, Map and Controller units,
where material is the main object, controlled by
connecting sets of other type objects. Final solution
is connected to the graphical object of choice. As in
the Node Editor case, the user is required only to
possess knowledge about specific material creation.
His actions are applied instantly to the connected
graphical element but a render pass is required to
actually see the changes on an object (Murdock,
2011).
UDK Editors. The Unreal Development Kit
provides several DSLs as an aid in game
development. The Material Editor is another
example of “connect objects” approach to material
creation, resulting in creation of specific shader. It is
similar in user operation to other approaches. What’s
more, the created materials can be used by a set of
additional tools e.g. Cascade Particle Editor
allowing for, simple in operation, conducting of
complicated task like preparing system of particle
emitters (Doran, 2013). UDK is also equipped with
Kismet DSL - much more complex approach. Due to
its general game control purpose, not fixed on
developing shaders, it is not considered in this list.
All of these approaches share the same concepts
of connecting elements and behaviours well known
to 3D object designers, thus it is quite simple for
them to develop materials accordingly to their needs.
The similarity and utilization of common
concepts allows for simplification of explaining used
Domain-specificLanguagesasToolsforTeaching3DGraphics
499