Commit e1cbb49d authored by Laurent Belcour's avatar Laurent Belcour

Working retro-Blinn using Schlick's back vector

parent 82fe7701
......@@ -10,24 +10,25 @@ struct param_info
std::string info;
};
#ifdef WIN32
//#ifdef WIN32
std::map<params::input, const param_info> create_map()
{
std::map<params::input, const param_info> _map;
/* 1D Params */
_map.insert(std::make_pair<params::input, const param_info>(params::COS_TH, param_info("COS_TH", 1, "Cosine of the Half angle")));
std::map<params::input, const param_info> _map;
/* 1D Params */
_map.insert(std::make_pair<params::input, const param_info>(params::COS_TH, param_info("COS_TH", 1, "Cosine of the Half angle")));
_map.insert(std::make_pair<params::input, const param_info>(params::COS_TK, param_info("COS_TK", 1, "Cosine of the Back angle")));
/* 2D Params */
_map.insert(std::make_pair<params::input, const param_info>(params::RUSIN_TH_TD, param_info("RUSIN_TH_TD", 2, "Radialy symmetric Half angle parametrization")));
/* 3D Params */
_map.insert(std::make_pair<params::input, const param_info>(params::RUSIN_TH_TD_PD, param_info("RUSIN_TH_TD_PD", 3, "Isotropic Half angle parametrization")));
_map.insert(std::make_pair<params::input, const param_info>(params::ISOTROPIC_TV_TL_DPHI, param_info("ISOTROPIC_TV_TL_DPHI", 3, "Isotropic Light/View angle parametrization")));
/* 4D Params */
_map.insert(std::make_pair<params::input, const param_info>(params::RUSIN_TH_PH_TD_PD, param_info("RUSIN_TH_PH_TD_PD", 4, "Complete Half angle parametrization")));
_map.insert(std::make_pair<params::input, const param_info>(params::SPHERICAL_TL_PL_TV_PV, param_info("SPHERICAL_TL_PL_TV_PV", 4, "Complete classical parametrization")));
_map.insert(std::make_pair<params::input, const param_info>(params::STEREOGRAPHIC, param_info("STEREOGRAPHIC", 4, "Light/View vector in stereographic projection"))),
_map.insert(std::make_pair<params::input, const param_info>(params::STEREOGRAPHIC, param_info("STEREOGRAPHIC", 4, "Light/View vector in stereographic projection"))),
/* 6D Param */
_map.insert(std::make_pair<params::input, const param_info>(params::CARTESIAN, param_info("CARTESIAN", 6, "Complete vector parametrization")));
......@@ -35,29 +36,29 @@ std::map<params::input, const param_info> create_map()
return _map;
}
static const std::map<params::input, const param_info> input_map = create_map();
#else
//#else
// Assing the input params map
static const std::map<params::input, const param_info> input_map = {
//static const std::map<params::input, const param_info> input_map = {
/* 1D Params */
{params::COS_TH, {"COS_TH", 1, "Cosine of the Half angle"}},
// {params::COS_TH, {"COS_TH", 1, "Cosine of the Half angle"}},
/* 2D Params */
{params::RUSIN_TH_TD, {"RUSIN_TH_TD", 2, "Radialy symmetric Half angle parametrization"}},
// {params::RUSIN_TH_TD, {"RUSIN_TH_TD", 2, "Radialy symmetric Half angle parametrization"}},
/* 3D Params */
{params::RUSIN_TH_TD_PD, {"RUSIN_TH_TD_PD", 3, "Isotropic Half angle parametrization"}},
{params::ISOTROPIC_TV_TL_DPHI, {"ISOTROPIC_TV_TL_DPHI", 3, "Isotropic Light/View angle parametrization"}},
// {params::RUSIN_TH_TD_PD, {"RUSIN_TH_TD_PD", 3, "Isotropic Half angle parametrization"}},
// {params::ISOTROPIC_TV_TL_DPHI, {"ISOTROPIC_TV_TL_DPHI", 3, "Isotropic Light/View angle parametrization"}},
/* 4D Params */
{params::RUSIN_TH_PH_TD_PD, {"RUSIN_TH_PH_TD_PD", 4, "Complete Half angle parametrization"}},
{params::SPHERICAL_TL_PL_TV_PV, {"SPHERICAL_TL_PL_TV_PV", 4, "Complete classical parametrization"}},
{params::STEREOGRAPHIC, {"STEREOGRAPHIC", 4, "Light/View vector in stereographic projection"}},
// {params::RUSIN_TH_PH_TD_PD, {"RUSIN_TH_PH_TD_PD", 4, "Complete Half angle parametrization"}},
// {params::SPHERICAL_TL_PL_TV_PV, {"SPHERICAL_TL_PL_TV_PV", 4, "Complete classical parametrization"}},
// {params::STEREOGRAPHIC, {"STEREOGRAPHIC", 4, "Light/View vector in stereographic projection"}},
/* 6D Params */
{params::CARTESIAN, {"CARTESIAN", 6, "Complete vector parametrization"}}
};
#endif
// {params::CARTESIAN, {"CARTESIAN", 6, "Complete vector parametrization"}}
//};
//#endif
void params::to_cartesian(const double* invec, params::input intype,
double* outvec)
......@@ -66,16 +67,15 @@ void params::to_cartesian(const double* invec, params::input intype,
{
// 1D Parametrizations
case params::COS_TH:
#ifndef USE_HALF
half_to_cartesian(acos(invec[0]), 0.0, 0.0, 0.0, outvec);
#else
outvec[0] = sqrt(1.0 - invec[0]*invec[0]);
outvec[1] = 0;
outvec[2] = invec[0];
outvec[3] = sqrt(1.0 - invec[0]*invec[0]);
outvec[4] = 0;
outvec[5] = invec[0];
#endif
break;
case params::COS_TK:
outvec[0] = invec[0]*invec[0]-1.0;
outvec[1] = 0.0;
outvec[2] = invec[0];
outvec[3] = 1.0-invec[0]*invec[0];
outvec[4] = 0.0;
outvec[5] = invec[0];
break;
// 2D Parametrizations
......@@ -171,6 +171,14 @@ void params::from_cartesian(const double* invec, params::input outtype,
case params::COS_TH:
outvec[0] = half[2];
break;
case params::COS_TK:
{
double Kx = invec[0]-invec[3];
double Ky = invec[1]-invec[4];
double Kz = invec[2]+invec[5];
outvec[0] = (invec[2] + invec[5]) / sqrt(Kx*Kx + Ky*Ky + Kz*Kz);
}
break;
// 2D Parametrizations
case params::COS_TH_TD:
......
......@@ -38,6 +38,9 @@ class params
COS_TH_TD,
COS_TH,
SCHLICK_TK_PK, /*!< Schlick's back vector parametrization */
COS_TK, /*!< Schlick's back vector dot product with the normal */
STEREOGRAPHIC, /*!< Stereographic projection of the Light and View vectors */
SPHERICAL_TL_PL_TV_PV, /*!< Light and View vectors represented in spherical coordinates */
......
......@@ -57,7 +57,7 @@ class retroblinn_function : public nonlinear_function
//! \brief Provide the parametrization of the input space of the function.
virtual params::input input_parametrization() const
{
return params::COS_TH ;
return params::COS_TK ;
}
virtual void setParametrization(params::input new_param)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment