diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2011-09-28 00:03:16 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2011-09-28 00:03:16 +0400 |
commit | 136d27b350355232ebe4d0a13427777445334b05 (patch) | |
tree | 59c507acfc825bb00675ed7ab519c24a82655ee4 /intern/cycles/kernel/svm/volume.h | |
parent | f5b60afe4ec924f12ec859e4ca51cd8ed9eab3ad (diff) |
Cycles: add some volume nodes, they don't actually do anything, this is just
to give other developers who may want to work on this to get a starting point.
Diffstat (limited to 'intern/cycles/kernel/svm/volume.h')
-rw-r--r-- | intern/cycles/kernel/svm/volume.h | 95 |
1 files changed, 63 insertions, 32 deletions
diff --git a/intern/cycles/kernel/svm/volume.h b/intern/cycles/kernel/svm/volume.h index dc377b5c595..86cb2dcc24e 100644 --- a/intern/cycles/kernel/svm/volume.h +++ b/intern/cycles/kernel/svm/volume.h @@ -1,42 +1,73 @@ -/* - * Adapted from Open Shading Language with this license: - * - * Copyright (c) 2009-2010 Sony Pictures Imageworks Inc., et al. - * All Rights Reserved. - * - * Modifications Copyright 2011, Blender Foundation. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of Sony Pictures Imageworks nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ +/* + * 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. + */ CCL_NAMESPACE_BEGIN +/* note: the interfaces here are just as an example, need to figure + out the right functions and parameters to use */ + +/* ISOTROPIC VOLUME CLOSURE */ + +__device void volume_isotropic_setup(ShaderData *sd, ShaderClosure *sc, float density) +{ + sc->type = CLOSURE_VOLUME_ISOTROPIC_ID; + sd->flag |= SD_VOLUME; + sc->data0 = density; +} + +__device float3 volume_isotropic_eval_phase(const ShaderData *sd, const ShaderClosure *sc, const float3 omega_in, const float3 omega_out) +{ + return make_float3(1.0f, 1.0f, 1.0f); +} + +/* TRANSPARENT VOLUME CLOSURE */ + +__device void volume_transparent_setup(ShaderData *sd, ShaderClosure *sc, float density) +{ + sc->type = CLOSURE_VOLUME_TRANSPARENT_ID; + sd->flag |= SD_VOLUME; + sc->data0 = density; +} + +__device float3 volume_transparent_eval_phase(const ShaderData *sd, const ShaderClosure *sc, const float3 omega_in, const float3 omega_out) +{ + return make_float3(1.0f, 1.0f, 1.0f); +} + /* VOLUME CLOSURE */ __device float3 volume_eval_phase(const ShaderData *sd, const ShaderClosure *sc, const float3 omega_in, const float3 omega_out) { - return make_float3(1.0f, 1.0f, 1.0f); + float3 eval; + + switch(sc->type) { + case CLOSURE_VOLUME_ISOTROPIC_ID: + eval = volume_isotropic_eval_phase(sd, sc, omega_in, omega_out); + break; + case CLOSURE_VOLUME_TRANSPARENT_ID: + eval = volume_transparent_eval_phase(sd, sc, omega_in, omega_out); + break; + default: + eval = make_float3(0.0f, 0.0f, 0.0f); + break; + } + + return eval; } CCL_NAMESPACE_END |