Panda3D

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