![]() |
||||||
|
|
||||||
|
Bezier Surfaces
Bezier surfaces are supported in opengl with evaluators, a more or less deprecated part of the pipeline. This tutorial descibes a faster and more flexible solution, based on vertex shaders and instances (requires a GF8), that allows to draw bezier surfaces like primitives. This tutorial requires Lumina 0.3.0-r3 The best known bezier object is the teapot, other are the teacup, spoon and the flowerbox screensaver. The first step is to create new node with a Buffer. Console:
The "Teapots" context menu contains a script named "Bezier Objects" execute it and select the Teapot and check the "Create Vertexshader" checkbox. The "Teapot" should store 512 float 3 vectors now. That are 32 bezier surfaces with each 16 controll points. The script will also create a vertexshader. Now the other required stuff should be created: A Fragmentshader a script and a Quadric mesh. Console:
The Quadric mesh can be created with the updated "Test Object" script in the Nodes contextmenu. Now write the Script:
and Fragmentshader:
The Vertexshader should contain code like this:
The first 6 lines in main() are required to create the factors for the coefficients. wx and wy are the coefficients, for the cubic bezier surface. tx and ty are the tangential coefficients. The two loops in two dimensions weighting the 4x4 Points and finally the calculated points and vectors are projected into the ModelViewspace. The shader creates Normal, Tangent and Bitangent, so that bumpmapping or other anisotropic lighting models shouldn't be a problem. The only required per vertex inputs are the texcoords stored in gl_Vertex.
|
||||||
|
|
|
|
|
|
|
|