Blender V2.61 - r43446

volume.h

Go to the documentation of this file.
00001 /*
00002  * Copyright 2011, Blender Foundation.
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License
00006  * as published by the Free Software Foundation; either version 2
00007  * of the License, or (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software Foundation,
00016  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017  */
00018 
00019 CCL_NAMESPACE_BEGIN
00020 
00021 /* note: the interfaces here are just as an example, need to figure
00022    out the right functions and parameters to use */
00023 
00024 /* ISOTROPIC VOLUME CLOSURE */
00025 
00026 __device void volume_isotropic_setup(ShaderData *sd, ShaderClosure *sc, float density)
00027 {
00028     sc->type = CLOSURE_VOLUME_ISOTROPIC_ID;
00029     sd->flag |= SD_VOLUME;
00030     sc->data0 = density;
00031 }
00032 
00033 __device float3 volume_isotropic_eval_phase(const ShaderData *sd, const ShaderClosure *sc, const float3 omega_in, const float3 omega_out)
00034 {
00035     return make_float3(1.0f, 1.0f, 1.0f);
00036 }
00037 
00038 /* TRANSPARENT VOLUME CLOSURE */
00039 
00040 __device void volume_transparent_setup(ShaderData *sd, ShaderClosure *sc, float density)
00041 {
00042     sc->type = CLOSURE_VOLUME_TRANSPARENT_ID;
00043     sd->flag |= SD_VOLUME;
00044     sc->data0 = density;
00045 }
00046 
00047 __device float3 volume_transparent_eval_phase(const ShaderData *sd, const ShaderClosure *sc, const float3 omega_in, const float3 omega_out)
00048 {
00049     return make_float3(1.0f, 1.0f, 1.0f);
00050 }
00051 
00052 /* VOLUME CLOSURE */
00053 
00054 __device float3 volume_eval_phase(const ShaderData *sd, const ShaderClosure *sc, const float3 omega_in, const float3 omega_out)
00055 {
00056     float3 eval;
00057 
00058     switch(sc->type) {
00059         case CLOSURE_VOLUME_ISOTROPIC_ID:
00060             eval = volume_isotropic_eval_phase(sd, sc, omega_in, omega_out);
00061             break;
00062         case CLOSURE_VOLUME_TRANSPARENT_ID:
00063             eval = volume_transparent_eval_phase(sd, sc, omega_in, omega_out);
00064             break;
00065         default:
00066             eval = make_float3(0.0f, 0.0f, 0.0f);
00067             break;
00068     }
00069 
00070     return eval;
00071 }
00072 
00073 CCL_NAMESPACE_END
00074