shader_bsdf.h

00001 /******************************************************************************
00002  * Copyright 1986-2009 by mental images GmbH, Fasanenstr. 81, D-10623 Berlin
00003  * All rights reserved.
00004  ******************************************************************************
00005  * Created:     22.01.2009
00006  * Purpose:     BSDF interface for mental ray
00007  *
00008  * Note: This file is generated automatically from the mental ray sources, do
00009  * not edit. Some definitions exist for internal reasons and are subject to
00010  * change between mental ray versions. See the mental ray user's manual for
00011  * a definitive description of the shader interface. Avoid using features not
00012  * documented in the manual because they may change in future versions.
00013  *****************************************************************************/
00014 
00015 #ifndef SHADER_BSDF_H
00016 #define SHADER_BSDF_H
00017 
00018 
00019 /*------------ brdf.h ------------*/
00020 
00021 
00022 namespace mi {
00023 namespace shader_v3 {
00024 
00025 
00068 class Bsdf
00069 {
00070 public:
00072     
00074     typedef bool Transport;
00075     static const Transport From_eye     = false;  
00076     static const Transport From_light   = true;   
00077 
00078     
00083     enum {
00084         // single types
00085         Invalid           = 0x00, 
00086         Reflect_diffuse   = 0x01, 
00087         Reflect_glossy    = 0x02, 
00088         Reflect_specular  = 0x04, 
00089         Transmit_diffuse  = 0x10, 
00090         Transmit_glossy   = 0x20, 
00091         Transmit_specular = 0x40, 
00092         
00093         // compound types
00094         Reflect_regular           
00095         = Reflect_diffuse
00096         | Reflect_glossy,
00097         Transmit_regular          
00098         = Transmit_diffuse
00099         | Transmit_glossy,
00100         All_diffuse               
00101         = Reflect_diffuse 
00102         | Transmit_diffuse,
00103         All_glossy                
00104         = Reflect_glossy 
00105         | Transmit_glossy,
00106         All_specular              
00107         = Reflect_specular 
00108         | Transmit_specular,
00109         All_regular               
00110         = Reflect_regular 
00111         | Transmit_regular,
00112         All_reflect               
00113         = Reflect_regular 
00114         | Reflect_specular,
00115         All_transmit              
00116         = Transmit_regular 
00117         | Transmit_specular,
00118         All                       
00119         = All_reflect 
00120         | All_transmit
00121     };
00122     typedef miUint4 Type;
00123 
00124     
00144     virtual miColor eval(
00145             const miVector&     ray,
00146             const miVector&     out,
00147             Type                flags = All,
00148             Transport           dir = From_eye
00149             ) const = 0;
00150     
00151 
00194     virtual Type sample(
00195             const miVector&     ray,
00196             miVector*           out,
00197             miColor*            weight,
00198             double              xi[3],
00199             Type                flags = All,
00200             Transport           dir = From_eye
00201             ) const = 0;
00202     
00203     
00214     virtual bool all_components(Type type) const = 0;
00215     
00216     
00227     virtual bool any_component(Type type) const = 0;
00228     
00229     
00238     virtual Type get_components() const = 0;
00239 };
00240 
00241 
00242 
00246 class Access_bsdf
00247 {
00248 public:
00249     
00258     Access_bsdf(miState* state)
00259     : m_state(state)
00260     {
00261         m_bsdf = Access_interface()->allocBsdf(state);
00262     }
00263 
00264     
00269     Access_bsdf()
00270     : m_state(0), m_bsdf(0)
00271     {}
00272     
00273     
00277     ~Access_bsdf()
00278     {
00279         Access_interface()->releaseBsdf(m_bsdf,m_state);
00280     }
00281     
00282     
00284     const Bsdf* operator->() const { return m_bsdf; }
00285     
00286     
00291     bool valid() const { return 0 != m_bsdf; }
00292     
00293     
00299     void reset(miState* state = 0)
00300     {
00301         Access_interface()->releaseBsdf(m_bsdf,m_state);
00302         m_state = state;
00303         m_bsdf = state ? Access_interface()->allocBsdf(state) : 0;
00304     }
00305     
00306     
00307 private:
00308     Access_bsdf(const Access_bsdf&);
00309     Access_bsdf& operator=(const Access_bsdf&);
00310     
00311     miState*    m_state;
00312     Bsdf*       m_bsdf;
00313 };
00314 
00315 }}
00316 
00317 
00318 #endif

Copyright © 1986-2009 by mental images GmbH