Panda3D
|
00001 // Filename: lightRampAttrib.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 LIGHTRAMPATTRIB_H 00016 #define LIGHTRAMPATTRIB_H 00017 00018 #include "pandabase.h" 00019 #include "renderAttrib.h" 00020 00021 class FactoryParams; 00022 00023 //////////////////////////////////////////////////////////////////// 00024 // Class : LightRampAttrib 00025 // Description : A Light Ramp is any unary operator that takes a 00026 // rendered pixel as input, and adjusts the brightness 00027 // of that pixel. For example, gamma correction is a 00028 // kind of light ramp. So is HDR tone mapping. So is 00029 // cartoon shading. See the constructors for an 00030 // explanation of each kind of ramp. 00031 //////////////////////////////////////////////////////////////////// 00032 class EXPCL_PANDA_PGRAPH LightRampAttrib : public RenderAttrib { 00033 private: 00034 INLINE LightRampAttrib(); 00035 00036 PUBLISHED: 00037 enum LightRampMode { 00038 LRT_default, 00039 LRT_identity, 00040 LRT_single_threshold, 00041 LRT_double_threshold, 00042 LRT_hdr0, 00043 LRT_hdr1, 00044 LRT_hdr2, 00045 }; 00046 static CPT(RenderAttrib) make_default(); 00047 static CPT(RenderAttrib) make_identity(); 00048 static CPT(RenderAttrib) make_single_threshold(float thresh0, float lev0); 00049 static CPT(RenderAttrib) make_double_threshold(float thresh0, float lev0, float thresh1, float lev1); 00050 static CPT(RenderAttrib) make_hdr0(); 00051 static CPT(RenderAttrib) make_hdr1(); 00052 static CPT(RenderAttrib) make_hdr2(); 00053 00054 00055 INLINE LightRampMode get_mode() const; 00056 INLINE float get_level(int n) const; 00057 INLINE float get_threshold(int n) const; 00058 00059 public: 00060 virtual void output(ostream &out) const; 00061 00062 protected: 00063 virtual int compare_to_impl(const RenderAttrib *other) const; 00064 00065 private: 00066 LightRampMode _mode; 00067 float _level[2]; 00068 float _threshold[2]; 00069 00070 static CPT(RenderAttrib) _default; 00071 00072 PUBLISHED: 00073 static int get_class_slot() { 00074 return _attrib_slot; 00075 } 00076 virtual int get_slot() const { 00077 return get_class_slot(); 00078 } 00079 00080 public: 00081 static void register_with_read_factory(); 00082 virtual void write_datagram(BamWriter *manager, Datagram &dg); 00083 00084 protected: 00085 static TypedWritable *make_from_bam(const FactoryParams ¶ms); 00086 void fillin(DatagramIterator &scan, BamReader *manager); 00087 00088 public: 00089 static TypeHandle get_class_type() { 00090 return _type_handle; 00091 } 00092 static void init_type() { 00093 RenderAttrib::init_type(); 00094 register_type(_type_handle, "LightRampAttrib", 00095 RenderAttrib::get_class_type()); 00096 _attrib_slot = register_slot(_type_handle, 100, make_default); 00097 } 00098 virtual TypeHandle get_type() const { 00099 return get_class_type(); 00100 } 00101 virtual TypeHandle force_init_type() {init_type(); return get_class_type();} 00102 00103 private: 00104 static TypeHandle _type_handle; 00105 static int _attrib_slot; 00106 }; 00107 00108 #include "lightRampAttrib.I" 00109 00110 #endif 00111