Panda3D
|
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 virtual size_t get_hash_impl() const; 00080 virtual CPT(RenderAttrib) get_auto_shader_attrib_impl(const RenderState *state) const; 00081 00082 private: 00083 int _outputs; 00084 00085 static CPT(RenderAttrib) _default; 00086 00087 PUBLISHED: 00088 static int get_class_slot() { 00089 return _attrib_slot; 00090 } 00091 virtual int get_slot() const { 00092 return get_class_slot(); 00093 } 00094 00095 public: 00096 static void register_with_read_factory(); 00097 virtual void write_datagram(BamWriter *manager, Datagram &dg); 00098 00099 protected: 00100 static TypedWritable *make_from_bam(const FactoryParams ¶ms); 00101 void fillin(DatagramIterator &scan, BamReader *manager); 00102 00103 public: 00104 static TypeHandle get_class_type() { 00105 return _type_handle; 00106 } 00107 static void init_type() { 00108 RenderAttrib::init_type(); 00109 register_type(_type_handle, "AuxBitplaneAttrib", 00110 RenderAttrib::get_class_type()); 00111 _attrib_slot = register_slot(_type_handle, 100, make_default); 00112 } 00113 virtual TypeHandle get_type() const { 00114 return get_class_type(); 00115 } 00116 virtual TypeHandle force_init_type() {init_type(); return get_class_type();} 00117 00118 private: 00119 static TypeHandle _type_handle; 00120 static int _attrib_slot; 00121 }; 00122 00123 #include "auxBitplaneAttrib.I" 00124 00125 #endif 00126