Panda3D

auxBitplaneAttrib.h

00001 // Filename: auxBitplaneAttrib.h
00002 // Created by:  drose (04Mar02)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 #ifndef AUXBITPLANEATTRIB_H
00016 #define AUXBITPLANEATTRIB_H
00017 
00018 #include "pandabase.h"
00019 #include "renderAttrib.h"
00020 
00021 class FactoryParams;
00022 
00023 ////////////////////////////////////////////////////////////////////
00024 //       Class : AuxBitplaneAttrib
00025 // Description : Modern frame buffers can have 'aux' bitplanes, which
00026 //               are additional bitplanes above and beyond the
00027 //               standard depth and color.  This attrib controls what
00028 //               gets rendered into those additional bitplanes.  It
00029 //               can also affect what goes into the alpha channel
00030 //               of the primary color buffer.
00031 //
00032 //               ABO_glow: copy the glow map into the alpha channel
00033 //               of the primary frame buffer.  If there is no glow
00034 //               map, set it to zero.  Caveat: it is not
00035 //               possible to write glow or depth values to the
00036 //               framebuffer alpha channel at the same time as using
00037 //               alpha blending or alpha testing.  Any attempt to use
00038 //               transparency, blending, or alpha testing will cause
00039 //               this flag to be overridden.
00040 //
00041 //               ABO_aux_normal: put the camera-space normal into
00042 //               the into the R,G components of the first auxiliary
00043 //               bitplane.
00044 //
00045 //               ABO_aux_modelz: put the clip-space Z coordinate of
00046 //               the center of the model (after perspective divide)
00047 //               into the B channel of the first auxiliary bitplane.
00048 //
00049 //               ABO_aux_glow: put a copy of the glow map into the
00050 //               alpha channel of the first auxiliary bitplane.
00051 //               If there is no glow map, set it to zero.
00052 //
00053 //               AuxBitplaneAttrib is relevant only when shader
00054 //               generation is enabled. Otherwise, it has no effect.
00055 //
00056 ////////////////////////////////////////////////////////////////////
00057 class EXPCL_PANDA_PGRAPH AuxBitplaneAttrib : public RenderAttrib {
00058 private:
00059   INLINE AuxBitplaneAttrib(int outputs);
00060 
00061 PUBLISHED:
00062   enum AuxBitplaneOutput {
00063     ABO_glow = 1,
00064     
00065     ABO_aux_normal = 2,
00066     ABO_aux_glow = 4,
00067   };
00068   static CPT(RenderAttrib) make();
00069   static CPT(RenderAttrib) make(int outputs);
00070   static CPT(RenderAttrib) make_default();
00071   
00072   INLINE int get_outputs() const;
00073   
00074 public:
00075   virtual void output(ostream &out) const;
00076   
00077 protected:
00078   virtual int compare_to_impl(const RenderAttrib *other) const;
00079   
00080 private:
00081   int _outputs;
00082 
00083   static CPT(RenderAttrib) _default;
00084 
00085 PUBLISHED:
00086   static int get_class_slot() {
00087     return _attrib_slot;
00088   }
00089   virtual int get_slot() const {
00090     return get_class_slot();
00091   }
00092 
00093 public:
00094   static void register_with_read_factory();
00095   virtual void write_datagram(BamWriter *manager, Datagram &dg);
00096 
00097 protected:
00098   static TypedWritable *make_from_bam(const FactoryParams &params);
00099   void fillin(DatagramIterator &scan, BamReader *manager);
00100   
00101 public:
00102   static TypeHandle get_class_type() {
00103     return _type_handle;
00104   }
00105   static void init_type() {
00106     RenderAttrib::init_type();
00107     register_type(_type_handle, "AuxBitplaneAttrib",
00108                   RenderAttrib::get_class_type());
00109     _attrib_slot = register_slot(_type_handle, 100, make_default);
00110   }
00111   virtual TypeHandle get_type() const {
00112     return get_class_type();
00113   }
00114   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00115 
00116 private:
00117   static TypeHandle _type_handle;
00118   static int _attrib_slot;
00119 };
00120 
00121 #include "auxBitplaneAttrib.I"
00122 
00123 #endif
00124 
 All Classes Functions Variables Enumerations