Panda3D
 All Classes Functions Variables Enumerations
lightRampAttrib.h
1 // Filename: lightRampAttrib.h
2 // Created by: drose (04Mar02)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef LIGHTRAMPATTRIB_H
16 #define LIGHTRAMPATTRIB_H
17 
18 #include "pandabase.h"
19 #include "renderAttrib.h"
20 
21 class FactoryParams;
22 
23 ////////////////////////////////////////////////////////////////////
24 // Class : LightRampAttrib
25 // Description : A Light Ramp is any unary operator that takes a
26 // rendered pixel as input, and adjusts the brightness
27 // of that pixel. For example, gamma correction is a
28 // kind of light ramp. So is HDR tone mapping. So is
29 // cartoon shading. See the constructors for an
30 // explanation of each kind of ramp.
31 ////////////////////////////////////////////////////////////////////
32 class EXPCL_PANDA_PGRAPH LightRampAttrib : public RenderAttrib {
33 private:
34  INLINE LightRampAttrib();
35 
36 PUBLISHED:
37  enum LightRampMode {
38  LRT_default,
39  LRT_identity,
40  LRT_single_threshold,
41  LRT_double_threshold,
42  LRT_hdr0,
43  LRT_hdr1,
44  LRT_hdr2,
45  };
46  static CPT(RenderAttrib) make_default();
47  static CPT(RenderAttrib) make_identity();
48  static CPT(RenderAttrib) make_single_threshold(PN_stdfloat thresh0, PN_stdfloat lev0);
49  static CPT(RenderAttrib) make_double_threshold(PN_stdfloat thresh0, PN_stdfloat lev0, PN_stdfloat thresh1, PN_stdfloat lev1);
50  static CPT(RenderAttrib) make_hdr0();
51  static CPT(RenderAttrib) make_hdr1();
52  static CPT(RenderAttrib) make_hdr2();
53 
54 
55  INLINE LightRampMode get_mode() const;
56  INLINE PN_stdfloat get_level(int n) const;
57  INLINE PN_stdfloat get_threshold(int n) const;
58 
59 public:
60  virtual void output(ostream &out) const;
61 
62 protected:
63  virtual int compare_to_impl(const RenderAttrib *other) const;
64  virtual size_t get_hash_impl() const;
65  virtual CPT(RenderAttrib) get_auto_shader_attrib_impl(const RenderState *state) const;
66 
67 private:
68  LightRampMode _mode;
69  PN_stdfloat _level[2];
70  PN_stdfloat _threshold[2];
71 
72  static CPT(RenderAttrib) _default;
73 
74 PUBLISHED:
75  static int get_class_slot() {
76  return _attrib_slot;
77  }
78  virtual int get_slot() const {
79  return get_class_slot();
80  }
81 
82 public:
83  static void register_with_read_factory();
84  virtual void write_datagram(BamWriter *manager, Datagram &dg);
85 
86 protected:
87  static TypedWritable *make_from_bam(const FactoryParams &params);
88  void fillin(DatagramIterator &scan, BamReader *manager);
89 
90 public:
91  static TypeHandle get_class_type() {
92  return _type_handle;
93  }
94  static void init_type() {
95  RenderAttrib::init_type();
96  register_type(_type_handle, "LightRampAttrib",
97  RenderAttrib::get_class_type());
98  _attrib_slot = register_slot(_type_handle, 100, make_default);
99  }
100  virtual TypeHandle get_type() const {
101  return get_class_type();
102  }
103  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
104 
105 private:
106  static TypeHandle _type_handle;
107  static int _attrib_slot;
108 };
109 
110 #include "lightRampAttrib.I"
111 
112 #endif
113 
static int register_slot(TypeHandle type_handle, int sort, RenderAttribRegistry::MakeDefaultFunc *make_default_func)
Adds the indicated TypeHandle to the registry, if it is not there already, and returns a unique slot ...
Definition: renderAttrib.I:163
This is the base class for a number of render attributes (other than transform) that may be set on sc...
Definition: renderAttrib.h:60
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition: bamReader.h:122
Base class for objects that can be written to and read from Bam files.
Definition: typedWritable.h:37
A Light Ramp is any unary operator that takes a rendered pixel as input, and adjusts the brightness o...
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
Definition: bamWriter.h:73
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
An instance of this class is passed to the Factory when requesting it to do its business and construc...
Definition: factoryParams.h:40
This represents a unique collection of RenderAttrib objects that correspond to a particular renderabl...
Definition: renderState.h:53
A class to retrieve the individual data elements previously stored in a Datagram. ...
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition: datagram.h:43