![]() |
||||||
|
|
||||||
|
This tutorial demonstrate simple dot3 bump-mapping
Basic dot3 shader For a bump-mapping setup we need a node with some items: Script, Fragmentshader, Vertexshader, two textures ("Colormap" and "Normalmap") and a Torus as test object. For this tutorial are also a color map and a normal map texture file needed. A specular map could be used to prevent the shaded object against the clear lacquer look. Lets start with a basic script: shader = gl.Shader(Vertexshader,Fragmentshader); A simple vertexshader transforms the data from the stream. It's important to transform the "Tangent" like the normal vector. Both vectors have to been projected into the worldspace. For the bitangent vector, it saves some instruction and memory if it's calculated by a crossproduct. attribute vec3 Tangent; Now a simple bummapping shader is needed. The first line in main fetch the value from the normalmap, that will be transformed into the worldspace by the second line. The folowing two lines calculate the diffuse and specular lightning. The last line compose that two values. uniform sampler2D Colormap; |
||||||
|
|
|
|
|
|
|
|