void ShaderProgram::set_uniform(const std::string& name, const kmVec4* vec) { GLint loc = get_uniform_loc(name); if(loc >= 0) { glUniform4fv(get_uniform_loc(name), 1, (GLfloat*) vec); check_and_log_error(__FILE__, __LINE__); } }
void ShaderProgram::set_uniform(const std::string& name, const kmMat3* matrix) { GLint loc = get_uniform_loc(name); if(loc >= 0) { float mat[9]; unsigned char i = 9; while(i--) { mat[i] = (float) matrix->mat[i]; } glUniformMatrix3fv(get_uniform_loc(name), 1, false, (GLfloat*)mat); check_and_log_error(__FILE__, __LINE__); } }
bool BinaryImageShader::get_variable_locs() { get_uniform_loc("toon_tex", _tex_loc); get_uniform_loc("threshold", _thresh_loc); // other variables here as needed... return true; }
bool GLSLPerlinTest::get_variable_locs() { get_uniform_loc("toon_tex", _tex_loc); // other variables here as needed... //create_perlin_texture2(); return true; }
/***************************************************************** * halftone_layer_t: *****************************************************************/ void halftone_layer_t::get_var_locs(int i, GLuint& program) { layer_base_t::get_var_locs(i,program); char tmp[32]; sprintf(tmp, "%d", i); string p = string("layer[") + tmp; get_uniform_loc(p + "].use_tone_correction", _use_tone_correction_loc, program); get_uniform_loc(p + "].use_lod_only", _use_lod_only_loc, program); get_uniform_loc(p + "].tone_correction_tex", _tone_correction_tex_loc, program); get_uniform_loc(p + "].r_function_tex", _r_function_tex_loc, program); }
bool GLSLToonShaderHalo::get_variable_locs() { if (!get_uniform_loc("toon_tex", _tex_loc)) return false; // other variables here as needed... return true; }
bool SimpleImageLineShader::get_variable_locs() { // other variables here as needed... // // get_uniform_loc("tone_map", _tone_tex_loc); get_uniform_loc("x_1", _width_loc); get_uniform_loc("y_1", _height_loc); get_uniform_loc("upper_curv_thd", _curv_loc[0]); get_uniform_loc("lower_curv_thd", _curv_loc[1]); get_uniform_loc("half_width", _line_width_loc); get_uniform_loc("curv_opacity_ctrl", _curv_opacity_ctrl_loc); get_uniform_loc("dist_opacity_ctrl", _dist_opacity_ctrl_loc); get_uniform_loc("moving_factor", _moving_factor_loc); get_uniform_loc("tone_opacity_ctrl", _tone_opacity_ctrl_loc); return true; }
bool GLSLXToonShader::get_variable_locs() { //set values to pass into the vertex shader XToonStripCB* cb = dynamic_cast<XToonStripCB*>(_cb); GLint normLoc = glGetAttribLocation(_program,"blendNorm"); cb->set_loc(normLoc); cb->set_blendType(_smoothNormal); get_uniform_loc("toonTex", _tex_loc); get_uniform_loc("detailMap",_Dmap_loc); get_uniform_loc("smoothDetail",_Sdtl_loc); get_uniform_loc("smoothFactor",_Sfct_loc); get_uniform_loc("targetLength", _trgt_loc); get_uniform_loc("maxFactor", _Mfct_loc); get_uniform_loc("focusPoint", _Fpnt_loc); get_uniform_loc("lightIndex",_Lidx_loc); get_uniform_loc("lightDir",_Ldir_loc); get_uniform_loc("lightCoords", _Lcoord_loc); return true; }
bool GLSLToonShader::get_variable_locs() { get_uniform_loc("toon_tex", _tex_loc); if (debug) { cerr << "GLSLToonShader::get_variable_locs: toon tex loc: " << _tex_loc << endl; } // other variables here as needed... return true; }
bool DotsShader::get_variable_locs() { get_uniform_loc("origin", _origin_loc); get_uniform_loc("u_vec", _u_vec_loc); get_uniform_loc("v_vec", _v_vec_loc); get_uniform_loc("st", _st_loc); get_uniform_loc("style", _style_loc); // tone map variables get_uniform_loc("tone_map", _tone_tex_loc); get_uniform_loc("width", _width_loc); get_uniform_loc("height", _height_loc); return true; }
bool HalftoneShaderEx::get_variable_locs() { //get_uniform_loc("lod", _lod_loc); //make sure it has at least an automatic generator if (!_patch->tex_coord_gen() ) { _patch->set_tex_coord_gen(new GLSphirTexCoordGen); } get_uniform_loc("tone_map", m_tex_loc); get_uniform_loc("width", m_width); get_uniform_loc("height", m_height); get_uniform_loc("sampler2D_perlin", _perlin_loc); get_uniform_loc("style", _style_loc); get_uniform_loc("P_inverse", _proj_der_loc); GLint tmp; //query the vertex attribute loacations tmp = glGetAttribLocation(program(),"dU_XYZ"); ((StripTexCoordsCB2*)cb())->set_dU_loc(tmp); cerr << "dU_loc = " << tmp <<endl; tmp = glGetAttribLocation(program(),"dV_XYZ"); ((StripTexCoordsCB2*)cb())->set_dV_loc(tmp); cerr << "dV_loc = " << tmp <<endl; return true; }
// Optimistic convenience version of above: GLint get_uniform_loc(const string& name) { GLint ret = -1; get_uniform_loc(name, ret); return ret; }
int shader_program::uniform(string identifier) { return get_uniform_loc(identifier.c_str(), program_id); }
bool Halftone_TX::get_variable_locs() { get_uniform_loc("origin", _origin_loc); get_uniform_loc("u_vec", _u_vec_loc); get_uniform_loc("v_vec", _v_vec_loc); get_uniform_loc("st", _st_loc); get_uniform_loc("op_remap", _opacity_remap_loc); get_uniform_loc("timed_lod_hi", _timed_lod_hi); get_uniform_loc("timed_lod_lo", _timed_lod_lo); // tone map variables get_uniform_loc("tone_tex", _tone_tex_loc); get_uniform_loc("halo_tex", _halo_tex_loc); get_uniform_loc("dims", _dims_loc); // XXX - hack for demoing alpha transitions. // to save instructions in the shader this is normally // not enabled if (enable_alpha_transitions) get_uniform_loc("use_alpha_transitions",_use_alpha_loc); get_layers_variable_names(); //query the vertex attribute loacations //part of the patch blending StripOpCB* s = dynamic_cast<StripOpCB*>(cb()); if (s) { s->set_opacity_attr_loc(glGetAttribLocation(program(),"opacity_attr")); s->set_patch(_patch); } return true; }
bool BlurShader::get_variable_locs() { // other variables here as needed... ImageLineStripCB* cb = dynamic_cast<ImageLineStripCB*>(_cb); GLint loc = glGetAttribLocation(_program,"local_edge_len"); cb->set_loc(loc); get_uniform_loc("tone_map", _tone_tex_loc); get_uniform_loc("x_1", _width_loc); get_uniform_loc("y_1", _height_loc); get_uniform_loc("blur_size", _blur_size_loc); get_uniform_loc("detail_func", _detail_func_loc); get_uniform_loc("unit_len", _unit_len_loc); get_uniform_loc("edge_len_scale", _edge_len_scale_loc); get_uniform_loc("ratio_scale", _ratio_scale_loc); get_uniform_loc("user_depth", _user_depth_loc); get_uniform_loc("global_edge_len", _global_edge_len_loc); get_uniform_loc("P_matrix", _proj_der_loc); return true; }
bool BasecoatShader::get_variable_locs() { ToneStripCB* cb = dynamic_cast<ToneStripCB*>(_cb); GLint normLoc = glGetAttribLocation(_program,"blendNorm"); cb->set_norm_loc(normLoc); cb->set_blendType(_smoothNormal); GLint lenLoc = glGetAttribLocation(_program,"local_edge_len"); cb->set_len_loc(lenLoc); get_uniform_loc("blend_normal", _blend_normal_loc); get_uniform_loc("unit_len", _unit_len_loc); get_uniform_loc("edge_len_scale", _edge_len_scale_loc); get_uniform_loc("ratio_scale", _ratio_scale_loc); get_uniform_loc("user_depth", _user_depth_loc); get_uniform_loc("toon_tex", _tex_loc); get_uniform_loc("tex_2d", _tex_2d_loc); get_uniform_loc("is_tex_2d", _is_tex_2d_loc); get_uniform_loc("is_enabled", _is_enabled_loc); get_uniform_loc("remap_nl", _remap_nl_loc ); get_uniform_loc("remap", _remap_loc ); get_uniform_loc("backlight", _backlight_loc ); get_uniform_loc("e0", _e0_loc ); get_uniform_loc("e1", _e1_loc ); get_uniform_loc("s0", _s0_loc ); get_uniform_loc("s1", _s1_loc ); get_uniform_loc("base_color0", _base_color_loc[0]); get_uniform_loc("base_color1", _base_color_loc[1]); get_uniform_loc("color_offset", _color_offset_loc); get_uniform_loc("color_steepness", _color_steepness_loc); get_uniform_loc("light_separation", _light_separation_loc); get_uniform_loc("global_edge_len", _global_edge_len_loc); get_uniform_loc("P_matrix", _proj_der_loc); return true; }
void ShaderProgram::set_uniform(const std::string& name, const int32_t x) { glUniform1i(get_uniform_loc(name), x); check_and_log_error(__FILE__, __LINE__); }
bool ShaderProgram::has_uniform(const std::string& name) { return get_uniform_loc(name) != -1; }
bool GLSLHatching::get_variable_locs() { GLSLPaperShader::get_variable_locs(); // tone map variables get_uniform_loc("tone_map", _tone_tex_loc); get_uniform_loc("width", _width_loc); get_uniform_loc("height", _height_loc); get_uniform_loc("sampler2D_perlin", _perlin_loc); get_uniform_loc("visible", _visible_loc); //is this layer visible get_uniform_loc("color", _color_loc); get_uniform_loc("line_spacing", _line_spacing_loc); get_uniform_loc("line_width", _line_width_loc); get_uniform_loc("do_paper", _do_paper_loc); get_uniform_loc("angle", _angle_loc); get_uniform_loc("perlin_amp", _perlin_amp_loc); get_uniform_loc("perlin_freq", _perlin_freq_loc); get_uniform_loc("min_tone", _min_tone_loc); get_uniform_loc("highlight", _highlight_loc); get_uniform_loc("channel", _channel_loc); return true; }