2
* Copyright 2011, Blender Foundation.
4
* This program is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU General Public License
6
* as published by the Free Software Foundation; either version 2
7
* of the License, or (at your option) any later version.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software Foundation,
16
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
2
* Copyright 2011-2013 Blender Foundation
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
8
* http://www.apache.org/licenses/LICENSE-2.0
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License
19
17
#include <string.h>
84
82
ustring OSLRenderServices::u_curve_tangent_normal("geom:curve_tangent_normal");
86
84
ustring OSLRenderServices::u_path_ray_length("path:ray_length");
85
ustring OSLRenderServices::u_path_ray_depth("path:ray_depth");
87
86
ustring OSLRenderServices::u_trace("trace");
88
87
ustring OSLRenderServices::u_hit("hit");
89
88
ustring OSLRenderServices::u_hitdist("hitdist");
660
660
float f = sd->ray_length;
661
661
return set_attribute_float(f, type, derivatives, val);
663
else if (name == u_path_ray_depth) {
665
int f = sd->ray_depth;
666
return set_attribute_int(f, type, derivatives, val);
663
668
else if (name == u_ndc) {
664
669
/* NDC coordinates with special exception for otho */
665
670
OSLThreadData *tdata = kg->osl_tdata;
697
702
int object, prim, segment;
699
704
/* lookup of attribute on another object */
700
if (object_name != u_empty || sd == NULL) {
705
if (object_name != u_empty) {
701
706
OSLGlobals::ObjectNameMap::iterator it = kg->osl->object_name_map.find(object_name);
703
708
if (it == kg->osl->object_name_map.end())
769
774
float dsdy, float dtdy, float *result)
771
776
OSL::TextureSystem *ts = osl_ts;
772
bool status = ts->texture(filename, options, s, t, dsdx, dtdx, dsdy, dtdy, result);
777
ShaderData *sd = (ShaderData *)(sg->renderstate);
778
KernelGlobals *kg = sd->osl_globals;
779
OSLThreadData *tdata = kg->osl_tdata;
780
OIIO::TextureSystem::Perthread *thread_info = tdata->oiio_thread_info;
782
OIIO::TextureSystem::TextureHandle *th = ts->get_texture_handle(filename, thread_info);
784
bool status = ts->texture(th, thread_info,
785
options, s, t, dsdx, dtdx, dsdy, dtdy, result);
775
788
if(options.nchannels == 3 || options.nchannels == 4) {
791
804
const OSL::Vec3 &dPdz, float *result)
793
806
OSL::TextureSystem *ts = osl_ts;
794
bool status = ts->texture3d(filename, options, P, dPdx, dPdy, dPdz, result);
807
ShaderData *sd = (ShaderData *)(sg->renderstate);
808
KernelGlobals *kg = sd->osl_globals;
809
OSLThreadData *tdata = kg->osl_tdata;
810
OIIO::TextureSystem::Perthread *thread_info = tdata->oiio_thread_info;
812
OIIO::TextureSystem::TextureHandle *th = ts->get_texture_handle(filename, thread_info);
814
bool status = ts->texture3d(th, thread_info,
815
options, P, dPdx, dPdy, dPdz, result);
797
818
if(options.nchannels == 3 || options.nchannels == 4) {
813
834
const OSL::Vec3 &dRdx, const OSL::Vec3 &dRdy, float *result)
815
836
OSL::TextureSystem *ts = osl_ts;
816
bool status = ts->environment(filename, options, R, dRdx, dRdy, result);
837
ShaderData *sd = (ShaderData *)(sg->renderstate);
838
KernelGlobals *kg = sd->osl_globals;
839
OSLThreadData *tdata = kg->osl_tdata;
840
OIIO::TextureSystem::Perthread *thread_info = tdata->oiio_thread_info;
842
OIIO::TextureSystem::TextureHandle *th = ts->get_texture_handle(filename, thread_info);
843
bool status = ts->environment(th, thread_info,
844
options, R, dRdx, dRdy, result);
819
847
if(options.nchannels == 3 || options.nchannels == 4) {
920
948
if(!tracedata->setup) {
921
949
/* lazy shader data setup */
922
shader_setup_from_ray(kg, sd, &tracedata->isect, &tracedata->ray);
950
ShaderData *original_sd = (ShaderData *)(sg->renderstate);
951
int bounce = original_sd->ray_depth + 1;
953
shader_setup_from_ray(kg, sd, &tracedata->isect, &tracedata->ray, bounce);
923
954
tracedata->setup = true;