Vis 2 Demo  1.0
Technical illustration type real-time rendering of geometry
 All Classes Namespaces Files Functions Variables Typedefs Macros
Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | List of all members
vis2::ShaderController Class Reference

This class manages the transport of information from the application to the shader program. More...

Public Member Functions

 ShaderController (Shader *_shader_program, unsigned int _shader_type)
 Constructor. More...
 
 ~ShaderController ()
 An empty destructor. More...
 
int setupShaderInVars (GLuint _position_buffer_handle, GLuint _normal_buffer_handle, GLuint _uv_buffer_handle, GLuint _index_buffer_handle)
 Function for connecting data streams (geometry -> shader) More...
 
GLuint getVAOHandle () const
 This function returns the handle of the created VAO suited for this particular shader. More...
 
void assignTexture (Texture *_texture, const unsigned int _slot)
 Function for assigning textures. More...
 
void setLightSource (const glm::vec3 _light_pos, const glm::vec3 _light_col, const unsigned int _slot)
 Function for setting the position and color of light souces. More...
 
void setViewData (const glm::vec3 _viewer_pos, const glm::vec3 _viewer_lookAt)
 Function for setting the position and target of the camera. More...
 
void setNearFar (float _near, float _far)
 Function for setting the view frustum near and far planes (for a logarithmic depth buffer) More...
 
void setBlurParams (const int _use_gaussian, const int _gauss_kernel_size, const int _blur_dist)
 Function for setting up blurring shaders. More...
 
void setMaskingParams (const glm::vec3 _masking_color, const glm::vec3 _exculde_color, const float _masking_tolerance, const int _use_prev_pass)
 Function for setting up masking shaders. More...
 
void setPeelingParams (float _window_w, float _window_h)
 Function for setting up peeling shaders. More...
 
void setPeelingBlendParams (const float _alpha, const glm::vec3 _bcgrd_col)
 Function for setting the transparency of layers to blend. More...
 
void setBlendAllParams (const glm::vec3 &_neighb_shading_col)
 Function for assigning a shading color to the complex blend shader. More...
 
int updateShaderUniforms (glm::mat4 &_projectionMatrix, glm::mat4 &_modelMatrix, const glm::vec3 &_obj_color, const glm::vec3 &_contour_color)
 Function for connecting data streams (environment -> shader) More...
 

Public Attributes

Shadershader_Ptr
 is the pointer to the shader program More...
 
const unsigned int shader_type
 is the type of the shader program, i.e VIS2_SHADER_TYPE_SOLID_COLOR More...
 

Private Member Functions

 ShaderController (const ShaderController &)
 Hidden copy-constructor. More...
 

Private Attributes

bool shader_InVars_setup_done
 is true, if the setup of the in vars was successful, false otherwise More...
 
bool shader_Uniforms_update_done
 is true, if the update of the uniforms was successful, false otherwise More...
 
GLuint vao_handle
 handle to the Vertex Array Object (VAO) containing the geometry Vertex Buffer Objects (VBO) More...
 
bool vao_setup_done
 signifies if the setup of the VAO was completed More...
 
bool texture_loaded [VIS2_NR_TEXTURE_SLOTS]
 is an array of binary flags indicating, if the texture was loaded More...
 
Texturetexture_slots [VIS2_NR_TEXTURE_SLOTS]
 is an array of textures (the complex blend shader needs 5 textures) More...
 
glm::vec3 vec_diffuse_color
 is the color of the object (id or other) More...
 
glm::vec3 vec_light_pos_0
 is the position of light source 0 (slot 0) More...
 
glm::vec3 vec_light_pos_1
 is the position of light source 1 (slot 1) More...
 
glm::vec3 vec_light_col_0
 is the color of light source 0 (slot 0) More...
 
glm::vec3 vec_light_col_1
 is the color of light source 1 (slot 1) More...
 
glm::vec3 vec_viewer_pos
 is the position of the camera / viewer More...
 
glm::vec3 vec_viewer_lookAt
 is the target at which the camera / viewer is looking More...
 
float near_plane
 is the far plane of the projection matrix More...
 
float far_plane
 is the near plane of the projection matrix More...
 
int use_gauss
 1 = use Gaussian kernel, 0 = use the blur distance instead More...
 
int gauss_kernel_size
 the size of the gaussian kernel in a BLUR shader More...
 
int blur_distance
 is the filter radius for blurring the mask in a BLUR shader More...
 
glm::vec3 masking_color
 is the color to be masked More...
 
glm::vec3 exculde_color
 is the background color, that is not to be masked (saves performance) More...
 
float masking_tolerance
 is the allowed distance from the detected color to the target color for masking to take place More...
 
int use_prev_pass
 if 1 then the result from the previous masking pass is added, if 0 - not More...
 
float window_w
 is the viewport width More...
 
float window_h
 is the viewport height More...
 
float depth_peel_blend [4]
 holds the blending coefficients based on the object alpha for the DEPTH PEEL BLEND shader More...
 
glm::vec3 depth_peel_bcgrd_col
 is the background color for the DEPTH PEEL BLEND shader More...
 
glm::vec3 blend_all_neighb_color
 

Detailed Description

This class manages the transport of information from the application to the shader program.

This class contains the functionality for passing all in and uniform parameters to
a shader program according to its type.

Definition at line 57 of file ShaderController.h.

Constructor & Destructor Documentation

ShaderController::ShaderController ( Shader _shader_program,
unsigned int  _shader_type 
)

Constructor.

The constructor requires

Parameters
[in]_shader_programas the shader program to be controlled, and
[in]_shader_typeas its type.

Definition at line 5 of file ShaderController.cpp.

ShaderController::~ShaderController ( )

An empty destructor.

Definition at line 32 of file ShaderController.cpp.

vis2::ShaderController::ShaderController ( const ShaderController )
private

Hidden copy-constructor.

Member Function Documentation

void ShaderController::assignTexture ( Texture _texture,
const unsigned int  _slot 
)

Function for assigning textures.

Parameters
[in]_textureis the texture to be assigned to
[in]_slot.

Definition at line 100 of file ShaderController.cpp.

GLuint vis2::ShaderController::getVAOHandle ( ) const
inline

This function returns the handle of the created VAO suited for this particular shader.

Definition at line 87 of file ShaderController.h.

void ShaderController::setBlendAllParams ( const glm::vec3 &  _neighb_shading_col)

Function for assigning a shading color to the complex blend shader.

Parameters
[in]_neighb_shading_colis the color to be used for the neighbors of the selected object in the complex blend shader.

Definition at line 190 of file ShaderController.cpp.

void ShaderController::setBlurParams ( const int  _use_gaussian,
const int  _gauss_kernel_size,
const int  _blur_dist 
)

Function for setting up blurring shaders.

Parameters
[in]_use_gaussian: if true, the Gaussian kernel is used, otherwize - the blur distance,
[in]_gauss_kernel_sizeis the size of the Gaussian kernel,
[in]_blur_distis the sampling radius for blurring.

Definition at line 146 of file ShaderController.cpp.

void ShaderController::setLightSource ( const glm::vec3  _light_pos,
const glm::vec3  _light_col,
const unsigned int  _slot 
)

Function for setting the position and color of light souces.

Parameters
[in]_light_posis position,
[in]_light_col- the color of the light source in
[in]_slot.

Definition at line 112 of file ShaderController.cpp.

void ShaderController::setMaskingParams ( const glm::vec3  _masking_color,
const glm::vec3  _exculde_color,
const float  _masking_tolerance,
const int  _use_prev_pass 
)

Function for setting up masking shaders.

Parameters
[in]_masking_coloris the color to be masked,
[in]_exculde_coloris the color to be excluded from masking,
[in]_masking_toleranceis the color tolerance for the masking process,
[in]_use_prev_passsignifies, whether the result from a previous pass should be added.

Definition at line 156 of file ShaderController.cpp.

void ShaderController::setNearFar ( float  _near,
float  _far 
)

Function for setting the view frustum near and far planes (for a logarithmic depth buffer)

Parameters
[in]_nearis the near plane,
[in]_faris the far plane.

Definition at line 139 of file ShaderController.cpp.

void ShaderController::setPeelingBlendParams ( const float  _alpha,
const glm::vec3  _bcgrd_col 
)

Function for setting the transparency of layers to blend.

Parameters
[in]_alphais the desired alpha value: 1 is opaque, 0 is completely transparent.
[in]_bcgrd_colis the background color.

Definition at line 173 of file ShaderController.cpp.

void ShaderController::setPeelingParams ( float  _window_w,
float  _window_h 
)

Function for setting up peeling shaders.

Passes the viewport size to the depth peeling fragment shader for fragment coordinate normalization.

Parameters
[in]_window_wis the width of the viewport,
[in]_window_his the height of the viewport.

Definition at line 167 of file ShaderController.cpp.

int ShaderController::setupShaderInVars ( GLuint  _position_buffer_handle,
GLuint  _normal_buffer_handle,
GLuint  _uv_buffer_handle,
GLuint  _index_buffer_handle 
)

Function for connecting data streams (geometry -> shader)

This function passes the locations of the geometry buffers to the shader program
according to the shader type. It creates a vao_handle to the vertex array object
which then binds the vertex buffer object handles passed as input parameters.

Parameters
[in]_position_buffer_handleis the handle to the vertex coordinates in object space,
[in]_normal_buffer_handleis the handle to the vertex normals in object space,
[in]_uv_buffer_handleis the handle to the texture coordinates in object space,
[in]_index_buffer_handleis the handle to the the face indices for each polygon.
Returns
0, if the setup was successful, -1, if the setup failed.

Definition at line 37 of file ShaderController.cpp.

void ShaderController::setViewData ( const glm::vec3  _viewer_pos,
const glm::vec3  _viewer_lookAt 
)

Function for setting the position and target of the camera.

Parameters
[in]_viewer_posis its position,
[in]_viewer_lookAt- its target.

Definition at line 133 of file ShaderController.cpp.

int ShaderController::updateShaderUniforms ( glm::mat4 &  _projectionMatrix,
glm::mat4 &  _modelMatrix,
const glm::vec3 &  _obj_color,
const glm::vec3 &  _contour_color 
)

Function for connecting data streams (environment -> shader)

This function passes the locations of the geometry-independent variables to the shader program
according to the shader type.

Parameters
[in]_projectionMatrixis the current projection matrix,
[in]_modelMatrixis the current model matrix,
[in]_obj_coloris the object color of the geometric object,
[in]_contour_coloris the color to use in edge detecting shaders.

Definition at line 195 of file ShaderController.cpp.

Member Data Documentation

glm::vec3 vis2::ShaderController::blend_all_neighb_color
private

Definition at line 219 of file ShaderController.h.

int vis2::ShaderController::blur_distance
private

is the filter radius for blurring the mask in a BLUR shader

Definition at line 206 of file ShaderController.h.

glm::vec3 vis2::ShaderController::depth_peel_bcgrd_col
private

is the background color for the DEPTH PEEL BLEND shader

Definition at line 217 of file ShaderController.h.

float vis2::ShaderController::depth_peel_blend[4]
private

holds the blending coefficients based on the object alpha for the DEPTH PEEL BLEND shader

Definition at line 216 of file ShaderController.h.

glm::vec3 vis2::ShaderController::exculde_color
private

is the background color, that is not to be masked (saves performance)

Definition at line 209 of file ShaderController.h.

float vis2::ShaderController::far_plane
private

is the near plane of the projection matrix

Definition at line 202 of file ShaderController.h.

int vis2::ShaderController::gauss_kernel_size
private

the size of the gaussian kernel in a BLUR shader

Definition at line 205 of file ShaderController.h.

glm::vec3 vis2::ShaderController::masking_color
private

is the color to be masked

Definition at line 208 of file ShaderController.h.

float vis2::ShaderController::masking_tolerance
private

is the allowed distance from the detected color to the target color for masking to take place

Definition at line 210 of file ShaderController.h.

float vis2::ShaderController::near_plane
private

is the far plane of the projection matrix

Definition at line 201 of file ShaderController.h.

bool vis2::ShaderController::shader_InVars_setup_done
private

is true, if the setup of the in vars was successful, false otherwise

Definition at line 180 of file ShaderController.h.

Shader* vis2::ShaderController::shader_Ptr

is the pointer to the shader program

Definition at line 173 of file ShaderController.h.

const unsigned int vis2::ShaderController::shader_type

is the type of the shader program, i.e VIS2_SHADER_TYPE_SOLID_COLOR

Definition at line 174 of file ShaderController.h.

bool vis2::ShaderController::shader_Uniforms_update_done
private

is true, if the update of the uniforms was successful, false otherwise

Definition at line 181 of file ShaderController.h.

bool vis2::ShaderController::texture_loaded[VIS2_NR_TEXTURE_SLOTS]
private

is an array of binary flags indicating, if the texture was loaded

Definition at line 187 of file ShaderController.h.

Texture* vis2::ShaderController::texture_slots[VIS2_NR_TEXTURE_SLOTS]
private

is an array of textures (the complex blend shader needs 5 textures)

Definition at line 188 of file ShaderController.h.

int vis2::ShaderController::use_gauss
private

1 = use Gaussian kernel, 0 = use the blur distance instead

Definition at line 204 of file ShaderController.h.

int vis2::ShaderController::use_prev_pass
private

if 1 then the result from the previous masking pass is added, if 0 - not

Definition at line 211 of file ShaderController.h.

GLuint vis2::ShaderController::vao_handle
private

handle to the Vertex Array Object (VAO) containing the geometry Vertex Buffer Objects (VBO)

Definition at line 184 of file ShaderController.h.

bool vis2::ShaderController::vao_setup_done
private

signifies if the setup of the VAO was completed

Definition at line 185 of file ShaderController.h.

glm::vec3 vis2::ShaderController::vec_diffuse_color
private

is the color of the object (id or other)

Definition at line 190 of file ShaderController.h.

glm::vec3 vis2::ShaderController::vec_light_col_0
private

is the color of light source 0 (slot 0)

Definition at line 195 of file ShaderController.h.

glm::vec3 vis2::ShaderController::vec_light_col_1
private

is the color of light source 1 (slot 1)

Definition at line 196 of file ShaderController.h.

glm::vec3 vis2::ShaderController::vec_light_pos_0
private

is the position of light source 0 (slot 0)

Definition at line 192 of file ShaderController.h.

glm::vec3 vis2::ShaderController::vec_light_pos_1
private

is the position of light source 1 (slot 1)

Definition at line 193 of file ShaderController.h.

glm::vec3 vis2::ShaderController::vec_viewer_lookAt
private

is the target at which the camera / viewer is looking

Definition at line 199 of file ShaderController.h.

glm::vec3 vis2::ShaderController::vec_viewer_pos
private

is the position of the camera / viewer

Definition at line 198 of file ShaderController.h.

float vis2::ShaderController::window_h
private

is the viewport height

Definition at line 214 of file ShaderController.h.

float vis2::ShaderController::window_w
private

is the viewport width

Definition at line 213 of file ShaderController.h.


The documentation for this class was generated from the following files: