ComputerGraphik TU WIEN
|
Implementation of tessellation, abstract class. More...
#include <tessellation.hpp>
Public Member Functions | |
Tessellation (const std::string &name, Scene *scene=0, Model *model=0, const glm::mat4 &modelMatrix=glm::mat4(1)) | |
virtual | ~Tessellation () |
void | draw () const |
bool | animate (double time) |
void | update (double deltaT) |
void | setShader (Shader *val) |
GLuint | getDispTexture () const |
unsigned int | getTessLevelIn () const |
unsigned int | getTessLevelOut () const |
void | setTessLevelIn (unsigned int val) |
void | setTessLevelOut (unsigned int val) |
Public Member Functions inherited from SceneObject | |
SceneObject (std::shared_ptr< SceneObject > &effectParent, const glm::mat4 &modelMatrix=glm::mat4(1)) | |
SceneObject (const std::string &name, Scene *scene=0, Model *model=0, const glm::mat4 &modelMatrix=glm::mat4(1)) | |
virtual | ~SceneObject () |
Model * | getModel () const |
Shader * | getShader () const |
glm::mat4 | getModelMatrix () const |
glm::mat4 | getGlobalModelMatrix () const |
std::string | getName () const |
std::shared_ptr< SceneObject > | getParent () const |
void | setAnimationTime (double time) |
bool | setAnimation (const Animation &anim) |
bool | delChild (size_t idx) |
bool | getChild (size_t idx, std::shared_ptr< SceneObject > &child) const |
bool | addChild (std::shared_ptr< SceneObject > &child) |
bool | remEffect (const std::string &name) |
SceneObject * | getEffect (const std::string &name) const |
bool | addEffect (const std::string &name, std::unique_ptr< SceneObject > &effect) |
bool | doNotRender () |
bool | getIsVolSun () |
virtual void | reset () |
Protected Attributes | |
GLuint | dispTexture |
unsigned int | tessLevelIn |
unsigned int | tessLevelOut |
Protected Attributes inherited from SceneObject | |
GLuint | vao |
Scene * | scene |
Model * | model |
Shader * | shader |
glm::mat4 | modelMatrix |
std::string | name |
std::weak_ptr< SceneObject > | parent |
std::vector< std::shared_ptr< SceneObject > > | childs |
std::map< std::string, std::unique_ptr< SceneObject > > | effectChilds |
size_t | animIDX |
Animation | animation |
bool | norender |
bool | isVolSun |
Private Attributes | |
float | dispTime |
Additional Inherited Members | |
Public Types inherited from SceneObject | |
typedef std::vector< std::pair< double, glm::mat4 > > | Animation |
Implementation of tessellation, abstract class.
For the rendering of animated flying bullets effect, tessellation was implemented using the Tessellation Shader. Since this effect is part of the GPU Particle System, this section will have some references on particles. The Vertex Shader is only a pass-through shader. In the Tessellation Control Shader, the inner and outer tessellation level can be set. The visualization of this two variable on triangles can be see on following image:
Using the life of a particle, the vertices of the object are scaled. For this purpose, level-of-detail is used, where larger objects will have more vertices generated. The value of tessellation levels are computed using the life of a particle. The effect uses triangles to tessellate, therefore Barycentric coordinates are received in the Tessellation Evaluation Shader. The vertices are computed by interpolating the Barycentric coordinates of the tessellated values with the control points. Then they are normalized to transform the cube model into a sphere. If quads would be tessellated, interpolation would be necessary only for normals. Displacement mapping is used in order to modify the shape of the sphere. To achieve a simple animation a 3D texture is used, which stores layers of Gaussian functions with increasing sigma value. The coordinates of the texture is the usual u, v and the third coordinate is the life of the particle. The positions are translated along the normal in local space to achieve displacement. To improve the normals of the displaced surface a Geometry Shader is used, where the tessellated normals are interpolated with the normal of the face, where the normal of the face is the cross product of two vectors computed from the displaced vertices. Finally the Fragment Shader of the OmniShadow effect is used. To achieve shadows with OmniShadow, only a simplified Tessellation Evaluation Shader is necessary for rendering the tessellation effect within the OmniShadow effect.
Tessellation::Tessellation | ( | const std::string & | name, |
Scene * | scene = 0 , |
||
Model * | model = 0 , |
||
const glm::mat4 & | modelMatrix = glm::mat4(1) |
||
) |
|
virtual |
|
virtual |
Reimplemented from SceneObject.
|
virtual |
Reimplemented from SceneObject.
|
inline |
|
inline |
|
inline |
|
virtual |
Reimplemented from SceneObject.
|
inline |
|
inline |
|
virtual |
Reimplemented from SceneObject.
|
protected |
Displacement texture.
|
private |
Global animation time.
|
protected |
Inner tessellation level.
|
protected |
Outer tessellation level.