EduGraf Programming: Shading

There is a low- and a high-level framework to define the visual appearance, i.e. shading, of objects that can be used alternatively.

Low-level Framework

Eventually, a program running on the GPU calculates the color of each displayed pixel for best performance. The low-level framework allows the programmer to write such GPU programs and to apply them to surfaces. GPU programs are obviously platform dependent. Therefore, when targeting OpenGL, inherit directly or indirectly from the class GlShading of the EduGraf.OpenGL assembly. Write the GPU program in the OpenGL Shading Language (GLSL). EduGraf has extra built-in support to ensure that host arguments are correctly passed to GLSL parameters. In addition to custom parameters, there are a few predefined parameters being passed to all GPU programs by the framework.

High-level Framework

In the real world, the color visual objects emerges from the interaction of light and matter. The high-level framework carries this over into the programming model. Each of the two aspects, represented by the abstract classes Light and Material, can be defined separately in geometrical manner. Using this information, the framework composes a GPU program that implements the combined visual effect. The framework provides a number of classes for different lights and materials. It is also possible to implement additional lights and materials. For this purpose, there are two kinds of properties. Properties marked with the Data attribute are transferred as arguments to the GPU. Properties marked with the Calc attribute describe calculations running on the GPU.