diff --git a/sources/plugins/nonlinear_fresnel_schlick/function.cpp b/sources/plugins/nonlinear_fresnel_schlick/function.cpp index f0f52c7fb6f613ad6cc6e50d6e3f9711f7ccc3bb..7c262944d523645270d735c1ed05217da18fdb2f 100644 --- a/sources/plugins/nonlinear_fresnel_schlick/function.cpp +++ b/sources/plugins/nonlinear_fresnel_schlick/function.cpp @@ -11,7 +11,7 @@ ALTA_DLL_EXPORT function* provide_function() { - return new schlick(); + return new schlick(); } //! Load function specific files @@ -19,56 +19,64 @@ void schlick::load(std::istream& in) { fresnel::load(in); - // Parse line until the next comment - while(in.peek() != '#') - { - char line[256]; - in.getline(line, 256); - } + // Parse line until the next comment + while(in.peek() != '#') + { + char line[256]; + in.getline(line, 256); + } - // Checking for the comment line #FUNC nonlinear_fresnel_schlick - std::string token; - in >> token; - if(token != "#FUNC") { std::cerr << "<> parsing the stream. The #FUNC is not the next line defined." << std::endl; } + // Checking for the comment line #FUNC nonlinear_fresnel_schlick + std::string token; + in >> token; + if(token != "#FUNC") { std::cerr << "<> parsing the stream. The #FUNC is not the next line defined." << std::endl; } - in >> token; - if(token != "nonlinear_fresnel_schlick") { std::cerr << "<> parsing the stream. function name is not the next token." << std::endl; } + in >> token; + if(token != "nonlinear_fresnel_schlick") { std::cerr << "<> parsing the stream. function name is not the next token." << std::endl; } - // R [double] - in >> token >> R; + // R [double] + in >> token >> R; } - + void schlick::save_call(std::ostream& out, const arguments& args) const { - out << "("; f->save_call(out, args); out << ")"; - bool is_alta = !args.is_defined("export") || args["export"] == "alta"; - - if(is_alta) - { - out << "#FUNC nonlinear_fresnel_schlick" << std::endl ; - out << "R " << R << std::endl; - out << std::endl; - } - else - { - out << " * schlick_fresnel(L, V, N, X, Y, " << R << ")"; - } + bool is_alta = !args.is_defined("export") || args["export"] == "alta"; + + if(is_alta) + { + out << "("; f->save_call(out, args); out << ")"; + } + else + { + f->save_call(out, args); + } + + if(is_alta) + { + out << "#FUNC nonlinear_fresnel_schlick" << std::endl ; + out << "R " << R << std::endl; + out << std::endl; + } + else + { + out << " * schlick_fresnel(L, V, N, X, Y, " << R << ")"; + } } void schlick::save_body(std::ostream& out, const arguments& args) const { - f->save_body(out, args); - bool is_shader = args["export"] == "shader" || args["export"] == "explorer"; - - if(is_shader) - { - out << std::endl; - out << "vec3 schlick_fresnel(vec3 L, vec3 V, vec3 N, vec3 X, vec3 Y, float R)" << std::endl; - out << "{" << std::endl; - out << "\tvec3 H = normalize(L + V);" << std::endl; - out << "\treturn vec3(R + (1.0f - R) * pow(1.0f - clamp(dot(H,L), 0.0f, 1.0f), 5));" << std::endl; - out << "}" << std::endl; - } + f->save_body(out, args); + bool is_shader = args["export"] == "shader" || args["export"] == "explorer"; + + if(is_shader) + { + out << std::endl; + out << "vec3 schlick_fresnel(vec3 L, vec3 V, vec3 N, vec3 X, vec3 Y, float R)" << std::endl; + out << "{" << std::endl; + out << "\tvec3 H = normalize(L + V);" << std::endl; + out << "\treturn vec3(R + (1.0f - R) * pow(1.0f - clamp(dot(H,L), 0.0f, 1.0f), 5));" << std::endl; + out << "}" << std::endl; + } } @@ -127,5 +135,5 @@ vec schlick::getFresnelParametersJacobian(const vec& x) const void schlick::fresnelBootstrap(const data* d, const arguments& args) { - R = 0.5; + R = 0.5; } diff --git a/sources/plugins/nonlinear_fresnel_schlick/function.h b/sources/plugins/nonlinear_fresnel_schlick/function.h index 9ed6510844bd599b8d2024e905fb6807472814d3..c18c5f7328fbc20b90f73b1168d1f975ce5246e4 100644 --- a/sources/plugins/nonlinear_fresnel_schlick/function.h +++ b/sources/plugins/nonlinear_fresnel_schlick/function.h @@ -36,10 +36,26 @@ class schlick : public fresnel //! \brief Update the vector of parameters for the function virtual void setFresnelParameters(const vec& p) ; + //! Get the vector of min parameters for the function + virtual vec getFresnelParametersMin() const + { + vec m(1); + m[0] = 0.0; + return m; + } + + //! Get the vector of min parameters for the function + virtual vec getFresnelParametersMax() const + { + vec M(1); + M[0] = 1.0; + return M; + } + //! \brief Obtain the derivatives of the function with respect to the //! parameters. virtual vec getFresnelParametersJacobian(const vec& x) const ; - + //! \brief Boostrap the function by defining the diffuse term virtual void fresnelBootstrap(const data* d, const arguments& args);