shader_bsdf.h

00001 /******************************************************************************
00002  * Copyright 1986-2009 by mental images GmbH, Fasanenstr. 81, D-10623 Berlin
00003  * All rights reserved.
00004  ******************************************************************************
00005  * Created:     06.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:
00071     // no virtual dtor
00072 
00074     typedef bool Transport;
00075     static const Transport From_eye     = false;  
00076     static const Transport From_light   = true;   
00077 
00082     enum {
00083         // single types
00084         Invalid           = 0x00, 
00085         Reflect_diffuse   = 0x01, 
00086         Reflect_glossy    = 0x02, 
00087         Reflect_specular  = 0x04, 
00088         Transmit_diffuse  = 0x10, 
00089         Transmit_glossy   = 0x20, 
00090         Transmit_specular = 0x40, 
00091         
00092         // compound types
00093         Reflect_regular           
00094         = Reflect_diffuse
00095         | Reflect_glossy,
00096         Transmit_regular          
00097         = Transmit_diffuse
00098         | Transmit_glossy,
00099         All_diffuse               
00100         = Reflect_diffuse 
00101         | Transmit_diffuse,
00102         All_glossy                
00103         = Reflect_glossy 
00104         | Transmit_glossy,
00105         All_specular              
00106         = Reflect_specular 
00107         | Transmit_specular,
00108         All_regular               
00109         = Reflect_regular 
00110         | Transmit_regular,
00111         All_reflect               
00112         = Reflect_regular 
00113         | Reflect_specular,
00114         All_transmit              
00115         = Transmit_regular 
00116         | Transmit_specular,
00117         All                       
00118         = All_reflect 
00119         | All_transmit
00120     };
00121     typedef miUint4 Type;
00122 
00123     
00143     virtual miColor eval(
00144             const miVector&     ray,
00145             const miVector&     out,
00146             Type                flags = All,
00147             Transport           dir = From_eye
00148             ) const = 0;
00149 
00150 
00184     virtual Type sample(
00185             const miVector&     ray,
00186             miVector*           out,
00187             miColor*            weight,
00188             double              xi[3],
00189             Type                flags = All,
00190             Transport           dir = From_eye
00191             ) const = 0;
00192     
00203     virtual bool all_components(Type type) const = 0;
00204 
00205 
00216     virtual bool any_component(Type type) const = 0;
00217     
00218     
00227     virtual Type get_components() const = 0;
00228 };
00229 
00233 class Access_bsdf
00234 {
00235 public:
00236     
00245     Access_bsdf(miState* state)
00246     : m_state(state)
00247     {
00248         m_bsdf = Access_interface()->allocBsdf(state);
00249     }
00250 
00251     
00256     Access_bsdf()
00257     : m_state(0), m_bsdf(0)
00258     {}
00259     
00260     
00264     ~Access_bsdf()
00265     {
00266         Access_interface()->releaseBsdf(m_bsdf,m_state);
00267     }
00268     
00269     
00271     const Bsdf* operator->() const { return m_bsdf; }
00272     
00273     
00278     bool valid() const { return 0 != m_bsdf; }
00279 
00280 
00286     void reset(miState* state = 0)
00287     {
00288         Access_interface()->releaseBsdf(m_bsdf,m_state);
00289         m_state = state;
00290         m_bsdf = state ? Access_interface()->allocBsdf(state) : 0;
00291     }
00292 
00293 
00294 private:
00295     Access_bsdf(const Access_bsdf&);
00296     Access_bsdf& operator=(const Access_bsdf&);
00297     
00298     miState*    m_state;
00299     Bsdf*       m_bsdf;
00300 };
00301 
00302 }}
00303 
00304 
00305 #endif

Copyright © 1986-2010 by mental images GmbH