~siretart/ubuntu/utopic/blender/libav10

« back to all changes in this revision

Viewing changes to intern/cycles/render/osl.cpp

  • Committer: Reinhard Tartler
  • Date: 2014-05-31 01:50:05 UTC
  • mfrom: (14.2.27 sid)
  • Revision ID: siretart@tauware.de-20140531015005-ml6druahuj82nsav
mergeĀ fromĀ debian

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
#include "osl.h"
22
22
#include "scene.h"
23
23
#include "shader.h"
 
24
#include "nodes.h"
24
25
 
25
26
#ifdef WITH_OSL
26
27
 
195
196
 
196
197
                /* our own ray types */
197
198
                static const char *raytypes[] = {
198
 
                        "camera",               /* PATH_RAY_CAMERA */
199
 
                        "reflection",   /* PATH_RAY_REFLECT */
200
 
                        "refraction",   /* PATH_RAY_TRANSMIT */
201
 
                        "diffuse",              /* PATH_RAY_DIFFUSE */
202
 
                        "glossy",               /* PATH_RAY_GLOSSY */
203
 
                        "singular",             /* PATH_RAY_SINGULAR */
204
 
                        "transparent",  /* PATH_RAY_TRANSPARENT */
205
 
                        "shadow",               /* PATH_RAY_SHADOW_OPAQUE */
206
 
                        "shadow",               /* PATH_RAY_SHADOW_TRANSPARENT */
 
199
                        "camera",                       /* PATH_RAY_CAMERA */
 
200
                        "reflection",           /* PATH_RAY_REFLECT */
 
201
                        "refraction",           /* PATH_RAY_TRANSMIT */
 
202
                        "diffuse",                      /* PATH_RAY_DIFFUSE */
 
203
                        "glossy",                       /* PATH_RAY_GLOSSY */
 
204
                        "singular",                     /* PATH_RAY_SINGULAR */
 
205
                        "transparent",          /* PATH_RAY_TRANSPARENT */
 
206
                        "shadow",                       /* PATH_RAY_SHADOW_OPAQUE */
 
207
                        "shadow",                       /* PATH_RAY_SHADOW_TRANSPARENT */
207
208
 
208
209
                        "__unused__",
209
210
                        "__unused__",
210
211
                        "diffuse_ancestor", /* PATH_RAY_DIFFUSE_ANCESTOR */
211
212
                        "glossy_ancestor",  /* PATH_RAY_GLOSSY_ANCESTOR */
212
213
                        "bssrdf_ancestor",  /* PATH_RAY_BSSRDF_ANCESTOR */
 
214
                        "__unused__",           /* PATH_RAY_SINGLE_PASS_DONE */
 
215
                        "volume_scatter",       /* PATH_RAY_VOLUME_SCATTER */
213
216
                };
214
217
 
215
218
                const int nraytypes = sizeof(raytypes)/sizeof(raytypes[0]);
724
727
        } while(!nodes_done);
725
728
}
726
729
 
727
 
void OSLCompiler::compile_type(Shader *shader, ShaderGraph *graph, ShaderType type)
 
730
OSL::ShadingAttribStateRef OSLCompiler::compile_type(Shader *shader, ShaderGraph *graph, ShaderType type)
728
731
{
729
732
        OSL::ShadingSystem *ss = (OSL::ShadingSystem*)shadingsys;
730
733
 
731
734
        current_type = type;
732
735
 
 
736
#if OSL_LIBRARY_VERSION_CODE >= 10501
 
737
        OSL::ShadingAttribStateRef group = ss->ShaderGroupBegin(shader->name.c_str());
 
738
#else
733
739
        ss->ShaderGroupBegin(shader->name.c_str());
 
740
#endif
734
741
 
735
742
        ShaderNode *output = graph->output();
736
743
        set<ShaderNode*> dependencies;
757
764
                assert(0);
758
765
 
759
766
        ss->ShaderGroupEnd();
 
767
 
 
768
#if OSL_LIBRARY_VERSION_CODE >= 10501
 
769
        return group;
 
770
#else
 
771
        OSL::ShadingAttribStateRef group = ss->state();
 
772
        ss->clear_state();
 
773
        return group;
 
774
#endif
760
775
}
761
776
 
762
777
void OSLCompiler::compile(OSLGlobals *og, Shader *shader)
763
778
{
764
779
        if(shader->need_update) {
765
 
                OSL::ShadingSystem *ss = (OSL::ShadingSystem*)shadingsys;
766
780
                ShaderGraph *graph = shader->graph;
767
781
                ShaderNode *output = (graph)? graph->output(): NULL;
768
782
 
788
802
 
789
803
                /* generate surface shader */
790
804
                if(shader->used && graph && output->input("Surface")->link) {
791
 
                        compile_type(shader, shader->graph, SHADER_TYPE_SURFACE);
792
 
                        shader->osl_surface_ref = ss->state();
 
805
                        shader->osl_surface_ref = compile_type(shader, shader->graph, SHADER_TYPE_SURFACE);
793
806
 
794
 
                        if(shader->graph_bump) {
795
 
                                ss->clear_state();
796
 
                                compile_type(shader, shader->graph_bump, SHADER_TYPE_SURFACE);
797
 
                                shader->osl_surface_bump_ref = ss->state();
798
 
                        }
 
807
                        if(shader->graph_bump)
 
808
                                shader->osl_surface_bump_ref = compile_type(shader, shader->graph_bump, SHADER_TYPE_SURFACE);
799
809
                        else
800
810
                                shader->osl_surface_bump_ref = shader->osl_surface_ref;
801
811
 
802
 
                        ss->clear_state();
803
 
 
804
812
                        shader->has_surface = true;
805
813
                }
806
814
                else {
810
818
 
811
819
                /* generate volume shader */
812
820
                if(shader->used && graph && output->input("Volume")->link) {
813
 
                        compile_type(shader, shader->graph, SHADER_TYPE_VOLUME);
 
821
                        shader->osl_volume_ref = compile_type(shader, shader->graph, SHADER_TYPE_VOLUME);
814
822
                        shader->has_volume = true;
815
 
 
816
 
                        shader->osl_volume_ref = ss->state();
817
 
                        ss->clear_state();
818
823
                }
819
824
                else
820
825
                        shader->osl_volume_ref = OSL::ShadingAttribStateRef();
821
826
 
822
827
                /* generate displacement shader */
823
828
                if(shader->used && graph && output->input("Displacement")->link) {
824
 
                        compile_type(shader, shader->graph, SHADER_TYPE_DISPLACEMENT);
 
829
                        shader->osl_displacement_ref = compile_type(shader, shader->graph, SHADER_TYPE_DISPLACEMENT);
825
830
                        shader->has_displacement = true;
826
 
                        shader->osl_displacement_ref = ss->state();
827
 
                        ss->clear_state();
828
831
                }
829
832
                else
830
833
                        shader->osl_displacement_ref = OSL::ShadingAttribStateRef();