~ubuntu-branches/ubuntu/utopic/blender/utopic-proposed

« back to all changes in this revision

Viewing changes to intern/cycles/kernel/osl/osl_services.cpp

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2014-02-19 11:24:23 UTC
  • mfrom: (14.2.23 sid)
  • Revision ID: package-import@ubuntu.com-20140219112423-rkmaz2m7ha06d4tk
Tags: 2.69-3ubuntu1
* Merge with Debian; remaining changes:
  - Configure without OpenImageIO on armhf, as it is not available on
    Ubuntu.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * Copyright 2011, Blender Foundation.
3
 
 *
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.
8
 
 *
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.
13
 
 *
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
 
3
 *
 
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
 
7
 *
 
8
 * http://www.apache.org/licenses/LICENSE-2.0
 
9
 *
 
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
17
15
 */
18
16
 
19
17
#include <string.h>
84
82
ustring OSLRenderServices::u_curve_tangent_normal("geom:curve_tangent_normal");
85
83
#endif
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");
98
97
OSLRenderServices::OSLRenderServices()
99
98
{
100
99
        kernel_globals = NULL;
 
100
        osl_ts = NULL;
101
101
}
102
102
 
103
103
OSLRenderServices::~OSLRenderServices()
660
660
                float f = sd->ray_length;
661
661
                return set_attribute_float(f, type, derivatives, val);
662
662
        }
 
663
        else if (name == u_path_ray_depth) {
 
664
                /* Ray Depth */
 
665
                int f = sd->ray_depth;
 
666
                return set_attribute_int(f, type, derivatives, val);
 
667
        }
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;
698
703
 
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);
702
707
 
703
708
                if (it == kg->osl->object_name_map.end())
769
774
                                float dsdy, float dtdy, float *result)
770
775
{
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;
 
781
 
 
782
        OIIO::TextureSystem::TextureHandle *th = ts->get_texture_handle(filename, thread_info);
 
783
 
 
784
        bool status = ts->texture(th, thread_info,
 
785
                                  options, s, t, dsdx, dtdx, dsdy, dtdy, result);
773
786
 
774
787
        if(!status) {
775
788
                if(options.nchannels == 3 || options.nchannels == 4) {
791
804
                                  const OSL::Vec3 &dPdz, float *result)
792
805
{
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;
 
811
 
 
812
        OIIO::TextureSystem::TextureHandle *th =  ts->get_texture_handle(filename, thread_info);
 
813
 
 
814
        bool status = ts->texture3d(th, thread_info,
 
815
                                    options, P, dPdx, dPdy, dPdz, result);
795
816
 
796
817
        if(!status) {
797
818
                if(options.nchannels == 3 || options.nchannels == 4) {
813
834
                                    const OSL::Vec3 &dRdx, const OSL::Vec3 &dRdy, float *result)
814
835
{
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;
 
841
 
 
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);
817
845
 
818
846
        if(!status) {
819
847
                if(options.nchannels == 3 || options.nchannels == 4) {
919
947
 
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;
 
952
 
 
953
                                        shader_setup_from_ray(kg, sd, &tracedata->isect, &tracedata->ray, bounce);
923
954
                                        tracedata->setup = true;
924
955
                                }
925
956