00001 00002 // Copyright 1986, 2015 NVIDIA ARC GmbH. All rights reserved. 00004 // Created: 09.01.06 00005 // Module: api 00006 // Purpose: mental ray C++ shader interface extensions 00008 00029 00030 #ifndef MI_SHADER_IF_H 00031 #define MI_SHADER_IF_H 00032 00033 // if file is included internally 00034 #if !defined(SHADER_H) 00035 #include <mi_raylib.h> 00036 #include <mi_lib.h> 00037 #include <mi_shader.h> 00038 #endif 00039 00040 #ifndef __cplusplus 00041 #error mi_shader_if.h requires C++ compilation 00042 #endif 00043 00044 00046 static const int mi_ray_interface_version = 3; 00047 00048 namespace mi { 00049 namespace shader_v3 { 00050 struct Interface; 00051 }} 00052 00053 00071 00072 extern "C" mi::shader_v3::Interface *mi_get_shader_interface( 00073 int version = mi_ray_interface_version); 00074 00076 namespace mi { 00077 00078 00084 namespace shader_v3 { 00085 00086 00088 class Options; 00089 class LightList; 00090 class MISLightList; 00091 class Framebuffer; 00092 class Map_status; 00093 class Map_base; 00094 class Edit_map_dbhandle; 00095 class Access_map_dbhandle; 00096 class Access_map; 00097 class Edit_map; 00098 class Map_declaration_base; 00099 class Map_iterator_base; 00100 class Map_element_base; 00101 class Map_lookup_base; 00102 class Bsdf; 00103 class Access_bsdf; 00104 class Subdivision34; 00105 class Mip_remap; 00106 00107 00108 00128 00129 struct Interface { 00130 public: 00147 static inline Interface* get( 00148 int version = mi_ray_interface_version) 00149 { 00150 return mi_get_shader_interface(version); 00151 } 00152 00166 virtual Options *getOptions( 00167 miTag string_options); 00168 00172 virtual miTag createFramebuffer(); 00173 00178 virtual miTag copyFramebuffer( 00179 miTag old_buffer_tag); 00180 00193 virtual LightList *createLightList( 00194 miState *state, 00195 miTag *slist = 0, 00196 int n = 0); 00197 00204 virtual void release(); 00205 00206 00220 virtual LightList *createLightList( 00221 miState *state, 00222 const miVector &axis, 00223 miScalar spread_cos, 00224 miTag *slist = 0, 00225 int n = 0); 00226 00227 00234 virtual Edit_map_dbhandle *createMap( 00235 const Map_declaration_base *map_declaration = 0); 00236 00243 virtual Access_map_dbhandle *accessMap( 00244 const miTag map_tag); 00245 00252 virtual Edit_map_dbhandle *editMap( 00253 const miTag map_tag); 00254 00262 virtual Access_map_dbhandle *accessMap( 00263 const char *filename, 00264 Map_status *status); 00265 00273 virtual Edit_map_dbhandle *editMap( 00274 const char *filename, 00275 Map_status *status); 00276 00283 virtual Map_declaration_base *createMapDeclaration( 00284 const miUint dimension); 00285 00293 virtual Map_declaration_base *copyMapDeclaration( 00294 const Map_declaration_base *other, 00295 Map_status *status); 00296 00304 virtual Map_declaration_base *copyMapDeclaration( 00305 const Map_element_base *map_element, 00306 Map_status *status); 00307 00315 virtual Map_declaration_base *copyMapDeclaration( 00316 const Map_base *map, 00317 Map_status *status); 00318 00325 virtual Map_element_base *createMapElement( 00326 const Map_declaration_base *declaration = 0); 00327 00334 virtual Map_element_base *copyMapElement( 00335 const Map_element_base *other); 00336 00344 virtual Map_iterator_base *createMapIterator( 00345 const Map_base *map, 00346 Map_status *status); 00347 00355 virtual Map_iterator_base *copyMapIterator( 00356 const Map_iterator_base *other, 00357 Map_status *status); 00358 00366 virtual Map_lookup_base *createMapLookup( 00367 const Map_base *map, 00368 Map_status *status); 00369 00377 virtual Map_lookup_base *copyMapLookup( 00378 const Map_lookup_base *other, 00379 Map_status *status); 00380 00382 00389 virtual const Framebuffer *accessFramebuffer( 00390 miTag buffer_tag); 00391 00399 virtual bool releaseFramebuffer( 00400 const Framebuffer *buffer, 00401 miTag buffer_tag); 00402 00409 virtual Framebuffer *editFramebuffer( 00410 miTag buffer_tag); 00411 00419 virtual bool releaseFramebuffer( 00420 Framebuffer *buffer, 00421 miTag buffer_tag); 00422 00424 00426 00432 virtual Bsdf* allocBsdf( 00433 miState* state); 00434 00440 virtual void releaseBsdf( 00441 Bsdf* bsdf, 00442 miState* state); 00443 00445 00448 virtual Subdivision34 * accessSubdivision34( 00449 miTag tag); 00450 00453 virtual void releaseSubdivision34( 00454 const Subdivision34 *subdiv34); 00455 00465 virtual bool lookup_filter_color_texture( 00466 miColor * const color, 00467 miState * const state, 00468 const miTag tex, 00469 Mip_remap & remap, 00470 miVector * coord); 00471 00479 virtual bool open_output_image( 00480 miImg_image * &image, 00481 miState * state, 00482 const size_t idx); 00483 00490 virtual bool close_output_image( 00491 miState * state, 00492 const size_t idx); 00493 00494 00496 00502 virtual const void* renderpass_get_cur_sample( 00503 miState * state, 00504 const size_t idx); 00505 00511 virtual const void* renderpass_get_pass_sample( 00512 miState * state, 00513 const size_t idx); 00514 00520 virtual bool renderpass_set_sample( 00521 miState * state, 00522 const size_t idx, 00523 const void* sample); 00524 00528 virtual size_t renderpass_get_pass_number(miState *state); 00529 00538 enum Filtertype {Bilinear, Bicubic}; 00539 virtual bool lookup_filter_color_texture( 00540 miColor * const color, 00541 miState * const state, 00542 const miTag tex, 00543 Mip_remap & remap, 00544 miVector * coord, 00545 Filtertype ft); 00546 00559 virtual MISLightList *createMISLightList( 00560 miState *state, 00561 miTag *slist = 0, 00562 int n = 0); 00563 00577 virtual MISLightList *createMISLightList( 00578 miState *state, 00579 Access_bsdf &bsdf, 00580 miTag *slist = 0, 00581 int n = 0); 00582 00592 virtual bool lookup_filter_color_texture( 00593 miColor * const color, 00594 miState * const state, 00595 const miTag tex, 00596 Mip_remap & remap, 00597 miVector * coord, 00598 Filtertype ft, 00599 miScalar blur); 00600 }; 00601 00602 00641 00642 class Options { 00643 public: 00645 00649 virtual void set( 00650 const char *name, 00651 bool value) = 0; 00652 00658 virtual void set( 00659 const char *name, 00660 const char * value) = 0; 00661 00666 virtual void set( 00667 const char *name, 00668 int value) = 0; 00669 00673 virtual void set( 00674 const char *name, 00675 float value) = 0; 00676 00681 virtual void set( 00682 const char *name, 00683 float value1, 00684 float value2) = 0; 00685 00691 virtual void set( 00692 const char *name, 00693 float value1, 00694 float value2, 00695 float value3) = 0; 00696 00703 virtual void set( 00704 const char *name, 00705 float value1, 00706 float value2, 00707 float value3, 00708 float value4) = 0; 00709 00715 virtual bool get( 00716 const char *name, 00717 bool *value) const = 0; 00718 00726 virtual bool get( 00727 const char *name, 00728 const char **value) const = 0; 00729 00735 virtual bool get( 00736 const char *name, 00737 int *value) const = 0; 00738 00747 virtual bool get( 00748 const char *name, 00749 float *value) const = 0; 00750 00761 virtual bool get( 00762 const char *name, 00763 float *value1, 00764 float *value2) const = 0; 00765 00778 virtual bool get( 00779 const char *name, 00780 float *value1, 00781 float *value2, 00782 float *value3) const = 0; 00783 00798 virtual bool get( 00799 const char *name, 00800 float *value1, 00801 float *value2, 00802 float *value3, 00803 float *value4) const = 0; 00804 00810 virtual bool remove( 00811 const char *name) = 0; 00812 00816 virtual void release() = 0; 00817 }; 00818 00819 00820 00823 class Access_interface { 00824 public: 00826 Access_interface(int version = mi_ray_interface_version) 00827 : m_iface (mi_get_shader_interface(version)) 00828 {} 00829 00831 ~Access_interface() 00832 { 00833 m_iface->release(); 00834 m_iface = 0; 00835 } 00836 00838 mi::shader_v3::Interface * operator->() 00839 { 00840 return m_iface; 00841 } 00842 00843 private: 00844 mi::shader_v3::Interface *m_iface; 00845 }; 00846 00847 00851 typedef Access_interface Interface_access; 00852 00853 00854 } // namespace shader_v3 00855 00856 00857 // namespace alias, shaders should use it 00858 namespace shader = shader_v3; 00859 00860 } // namespace mi 00861 00862 #include "shader_framebuffer.h" 00863 #include "shader_output.h" 00864 #include "shader_map.h" 00865 #include "shader_lightlist.h" 00866 #include "shader_sds34.h" 00867 #include "shader_mipremap.h" 00868 #include "shader_importance.h" 00869 00870 #endif // MI_SHADER_IF_H
Copyright © 1986, 2015 NVIDIA ARC GmbH. All rights reserved.