Panda3D

Loading...
Searching...
No Matches
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
32PUBLISHED:
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
55PUBLISHED:
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
72PUBLISHED:
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
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::make_hdr2
static ConstPointerTo< RenderAttrib > make_hdr2()
Constructs a new LightRampAttrib object.
Definition lightRampAttrib.cxx:169
LightRampAttrib::get_mode
get_mode
Returns the LightRampAttrib mode.
Definition lightRampAttrib.h:56
LightRampAttrib::make_single_threshold
static ConstPointerTo< RenderAttrib > make_single_threshold(PN_stdfloat thresh0, PN_stdfloat lev0)
Constructs a new LightRampAttrib object.
Definition lightRampAttrib.cxx:64
LightRampAttrib::get_level
PN_stdfloat get_level(int n) const
Returns the nth lighting level.
Definition lightRampAttrib.I:38
LightRampAttrib::make_identity
static ConstPointerTo< RenderAttrib > make_identity()
Constructs a new LightRampAttrib object.
Definition lightRampAttrib.cxx:45
LightRampAttrib::make_double_threshold
static ConstPointerTo< RenderAttrib > make_double_threshold(PN_stdfloat thresh0, PN_stdfloat lev0, PN_stdfloat thresh1, PN_stdfloat lev1)
Constructs a new LightRampAttrib object.
Definition lightRampAttrib.cxx:87
LightRampAttrib::get_threshold
PN_stdfloat get_threshold(int n) const
Returns the nth threshold level.
Definition lightRampAttrib.I:47
LightRampAttrib::make_hdr1
static ConstPointerTo< RenderAttrib > make_hdr1()
Constructs a new LightRampAttrib object.
Definition lightRampAttrib.cxx:143
LightRampAttrib::make_default
static ConstPointerTo< RenderAttrib > make_default()
Constructs a new LightRampAttrib object.
Definition lightRampAttrib.cxx:31
LightRampAttrib::make_hdr0
static ConstPointerTo< RenderAttrib > make_hdr0()
Constructs a new LightRampAttrib object.
Definition lightRampAttrib.cxx:117
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
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.