2011-09-27 20:03:16 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2011, Blender Foundation.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
2011-04-27 11:58:34 +00:00
|
|
|
|
|
|
|
CCL_NAMESPACE_BEGIN
|
|
|
|
|
2011-09-27 20:03:16 +00:00
|
|
|
/* note: the interfaces here are just as an example, need to figure
|
2012-06-09 17:22:52 +00:00
|
|
|
* out the right functions and parameters to use */
|
2011-09-27 20:03:16 +00:00
|
|
|
|
|
|
|
/* ISOTROPIC VOLUME CLOSURE */
|
|
|
|
|
2012-10-20 12:18:00 +00:00
|
|
|
__device int volume_isotropic_setup(ShaderClosure *sc, float density)
|
2011-09-27 20:03:16 +00:00
|
|
|
{
|
|
|
|
sc->type = CLOSURE_VOLUME_ISOTROPIC_ID;
|
|
|
|
sc->data0 = density;
|
2012-10-20 12:18:00 +00:00
|
|
|
|
|
|
|
return SD_VOLUME;
|
2011-09-27 20:03:16 +00:00
|
|
|
}
|
|
|
|
|
2012-10-20 12:18:00 +00:00
|
|
|
__device float3 volume_isotropic_eval_phase(const ShaderClosure *sc, const float3 omega_in, const float3 omega_out)
|
2011-09-27 20:03:16 +00:00
|
|
|
{
|
|
|
|
return make_float3(1.0f, 1.0f, 1.0f);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* TRANSPARENT VOLUME CLOSURE */
|
|
|
|
|
2012-10-20 12:18:00 +00:00
|
|
|
__device int volume_transparent_setup(ShaderClosure *sc, float density)
|
2011-09-27 20:03:16 +00:00
|
|
|
{
|
|
|
|
sc->type = CLOSURE_VOLUME_TRANSPARENT_ID;
|
|
|
|
sc->data0 = density;
|
2012-10-20 12:18:00 +00:00
|
|
|
|
|
|
|
return SD_VOLUME;
|
2011-09-27 20:03:16 +00:00
|
|
|
}
|
|
|
|
|
2012-10-20 12:18:00 +00:00
|
|
|
__device float3 volume_transparent_eval_phase(const ShaderClosure *sc, const float3 omega_in, const float3 omega_out)
|
2011-09-27 20:03:16 +00:00
|
|
|
{
|
|
|
|
return make_float3(1.0f, 1.0f, 1.0f);
|
|
|
|
}
|
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
/* VOLUME CLOSURE */
|
|
|
|
|
2012-12-15 10:18:42 +00:00
|
|
|
__device float3 volume_eval_phase(KernelGlobals *kg, const ShaderClosure *sc, const float3 omega_in, const float3 omega_out)
|
2011-04-27 11:58:34 +00:00
|
|
|
{
|
2012-12-15 10:18:42 +00:00
|
|
|
#ifdef __OSL__
|
|
|
|
if(kg->osl && sc->prim)
|
|
|
|
return OSLShader::volume_eval_phase(sc, omega_in, omega_out);
|
|
|
|
#endif
|
|
|
|
|
2011-09-27 20:03:16 +00:00
|
|
|
float3 eval;
|
|
|
|
|
|
|
|
switch(sc->type) {
|
|
|
|
case CLOSURE_VOLUME_ISOTROPIC_ID:
|
2012-10-20 12:18:00 +00:00
|
|
|
eval = volume_isotropic_eval_phase(sc, omega_in, omega_out);
|
2011-09-27 20:03:16 +00:00
|
|
|
break;
|
|
|
|
case CLOSURE_VOLUME_TRANSPARENT_ID:
|
2012-10-20 12:18:00 +00:00
|
|
|
eval = volume_transparent_eval_phase(sc, omega_in, omega_out);
|
2011-09-27 20:03:16 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
eval = make_float3(0.0f, 0.0f, 0.0f);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return eval;
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
CCL_NAMESPACE_END
|
|
|
|
|