Panda3D
panda
src
pgraph
shaderAttrib.I
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 shaderAttrib.I
10
* @author sshodhan
11
* @date 2004-07-10
12
* @author weifengh, PandaSE
13
* @date 2010-04-15
14
*/
15
16
/**
17
*
18
*/
19
INLINE ShaderAttrib::
20
ShaderAttrib() :
21
_shader(nullptr),
22
_shader_priority(0),
23
_auto_shader(false),
24
_has_shader(false),
25
_flags(0),
26
_has_flags(0),
27
_instance_count(0),
28
_auto_normal_on(false),
29
_auto_glow_on(false),
30
_auto_gloss_on(false),
31
_auto_ramp_on(false),
32
_auto_shadow_on(false)
33
{
34
}
35
36
/**
37
*
38
*/
39
INLINE ShaderAttrib::
40
ShaderAttrib(
const
ShaderAttrib
©) :
41
_shader(copy._shader),
42
_shader_priority(copy._shader_priority),
43
_auto_shader(copy._auto_shader),
44
_has_shader(copy._has_shader),
45
_flags(copy._flags),
46
_has_flags(copy._has_flags),
47
_instance_count(copy._instance_count),
48
_auto_normal_on(copy._auto_normal_on),
49
_auto_glow_on(copy._auto_glow_on),
50
_auto_gloss_on(copy._auto_gloss_on),
51
_auto_ramp_on(copy._auto_ramp_on),
52
_auto_shadow_on(copy._auto_shadow_on),
53
_inputs(copy._inputs)
54
{
55
}
56
57
/**
58
* If true, the shader field of this attribute overrides the shader field of
59
* the parent attribute.
60
*/
61
INLINE
bool
ShaderAttrib::
62
has_shader
()
const
{
63
return
_has_shader;
64
}
65
66
/**
67
* If true, then this ShaderAttrib does not contain an explicit shader -
68
* instead, it requests the automatic generation of a shader.
69
*/
70
INLINE
bool
ShaderAttrib::
71
auto_shader
()
const
{
72
return
_auto_shader;
73
}
74
75
/**
76
*
77
*/
78
INLINE
int
ShaderAttrib::
79
get_shader_priority()
const
{
80
return
_shader_priority;
81
}
82
83
/**
84
* Returns the number of geometry instances. A value of 0 means not to use
85
* instancing at all.
86
*/
87
INLINE
int
ShaderAttrib::
88
get_instance_count
()
const
{
89
return
_instance_count;
90
}
91
92
/**
93
*
94
*/
95
INLINE
bool
ShaderAttrib::
96
get_flag(
int
index)
const
{
97
return
(_flags & (1<<index)) ?
true
:
false
;
98
}
99
100
/**
101
* Returns true if there is a ShaderInput of the given name.
102
*/
103
bool
ShaderAttrib::
104
has_shader_input
(
CPT_InternalName
id
)
const
{
105
return
(_inputs.find(
id
) != _inputs.end());
106
}
107
108
/**
109
*
110
*/
111
INLINE CPT(
RenderAttrib
) ShaderAttrib::
112
set_shader_input(
CPT_InternalName
id
,
const
PTA_float &v,
int
priority)
const
{
113
return
set_shader_input(
ShaderInput
(std::move(
id
), v, priority));
114
}
115
116
/**
117
*
118
*/
119
INLINE CPT(
RenderAttrib
) ShaderAttrib::
120
set_shader_input(
CPT_InternalName
id
,
const
PTA_double &v,
int
priority)
const
{
121
return
set_shader_input(
ShaderInput
(std::move(
id
), v, priority));
122
}
123
124
/**
125
*
126
*/
127
INLINE CPT(
RenderAttrib
) ShaderAttrib::
128
set_shader_input(
CPT_InternalName
id
,
const
PTA_LVecBase4 &v,
int
priority)
const
{
129
return
set_shader_input(
ShaderInput
(std::move(
id
), v, priority));
130
}
131
132
/**
133
*
134
*/
135
INLINE CPT(
RenderAttrib
) ShaderAttrib::
136
set_shader_input(
CPT_InternalName
id
,
const
PTA_LVecBase3 &v,
int
priority)
const
{
137
return
set_shader_input(
ShaderInput
(std::move(
id
), v, priority));
138
}
139
140
141
/**
142
*
143
*/
144
INLINE CPT(
RenderAttrib
) ShaderAttrib::
145
set_shader_input(
CPT_InternalName
id
,
const
PTA_LVecBase2 &v,
int
priority)
const
{
146
return
set_shader_input(
ShaderInput
(std::move(
id
), v, priority));
147
}
148
149
/**
150
*
151
*/
152
INLINE CPT(
RenderAttrib
) ShaderAttrib::
153
set_shader_input(
CPT_InternalName
id
,
const
LVecBase4 &v,
int
priority)
const
{
154
return
set_shader_input(
ShaderInput
(std::move(
id
), v, priority));
155
}
156
157
/**
158
*
159
*/
160
INLINE CPT(
RenderAttrib
) ShaderAttrib::
161
set_shader_input(
CPT_InternalName
id
,
const
LVecBase3 &v,
int
priority)
const
{
162
return
set_shader_input(
ShaderInput
(std::move(
id
), v, priority));
163
}
164
165
/**
166
*
167
*/
168
INLINE CPT(
RenderAttrib
) ShaderAttrib::
169
set_shader_input(
CPT_InternalName
id
,
const
LVecBase2 &v,
int
priority)
const
{
170
return
set_shader_input(
ShaderInput
(std::move(
id
), v, priority));
171
}
172
173
/**
174
*
175
*/
176
INLINE CPT(
RenderAttrib
) ShaderAttrib::
177
set_shader_input(
CPT_InternalName
id
,
const
PTA_LMatrix4 &v,
int
priority)
const
{
178
return
set_shader_input(
ShaderInput
(std::move(
id
), v, priority));
179
}
180
181
/**
182
*
183
*/
184
INLINE CPT(
RenderAttrib
) ShaderAttrib::
185
set_shader_input(
CPT_InternalName
id
,
const
PTA_LMatrix3 &v,
int
priority)
const
{
186
return
set_shader_input(
ShaderInput
(std::move(
id
), v, priority));
187
}
188
189
/**
190
*
191
*/
192
INLINE CPT(
RenderAttrib
) ShaderAttrib::
193
set_shader_input(
CPT_InternalName
id
,
const
LMatrix4 &v,
int
priority)
const
{
194
return
set_shader_input(
ShaderInput
(std::move(
id
), v, priority));
195
}
196
197
/**
198
*
199
*/
200
INLINE CPT(
RenderAttrib
) ShaderAttrib::
201
set_shader_input(
CPT_InternalName
id
,
const
LMatrix3 &v,
int
priority)
const
{
202
return
set_shader_input(
ShaderInput
(std::move(
id
), v, priority));
203
}
204
205
/**
206
*
207
*/
208
INLINE CPT(
RenderAttrib
) ShaderAttrib::
209
set_shader_input(
CPT_InternalName
id
,
Texture
*tex,
int
priority)
const
{
210
return
set_shader_input(
ShaderInput
(std::move(
id
), tex, priority));
211
}
212
213
/**
214
*
215
*/
216
INLINE CPT(
RenderAttrib
) ShaderAttrib::
217
set_shader_input(
CPT_InternalName
id
,
const
NodePath
&np,
int
priority)
const
{
218
return
set_shader_input(
ShaderInput
(std::move(
id
), np, priority));
219
}
220
221
/**
222
*
223
*/
224
INLINE CPT(
RenderAttrib
) ShaderAttrib::
225
set_shader_input(
CPT_InternalName
id
,
double
n1,
double
n2,
double
n3,
double
n4,
int
priority)
const
{
226
return
set_shader_input(
ShaderInput
(std::move(
id
), LVecBase4((PN_stdfloat)n1, (PN_stdfloat)n2, (PN_stdfloat)n3, (PN_stdfloat)n4), priority));
227
}
228
229
INLINE
bool
ShaderAttrib::
230
auto_normal_on()
const
{
231
return
_auto_normal_on;
232
}
233
234
/**
235
*
236
*/
237
INLINE
bool
ShaderAttrib::
238
auto_glow_on()
const
{
239
return
_auto_glow_on;
240
}
241
242
/**
243
*
244
*/
245
INLINE
bool
ShaderAttrib::
246
auto_gloss_on()
const
{
247
return
_auto_gloss_on;
248
}
249
250
/**
251
*
252
*/
253
INLINE
bool
ShaderAttrib::
254
auto_ramp_on()
const
{
255
return
_auto_ramp_on;
256
}
257
258
/**
259
*
260
*/
261
INLINE
bool
ShaderAttrib::
262
auto_shadow_on()
const
{
263
return
_auto_shadow_on;
264
}
ShaderAttrib::auto_shader
bool auto_shader() const
If true, then this ShaderAttrib does not contain an explicit shader - instead, it requests the automa...
Definition:
shaderAttrib.I:71
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
ShaderAttrib
Definition:
shaderAttrib.h:39
Texture
Represents a texture object, which is typically a single 2-d image but may also represent a 1-d or 3-...
Definition:
texture.h:71
CPT_InternalName
This is a const pointer to an InternalName, and should be used in lieu of a CPT(InternalName) in func...
Definition:
internalName.h:193
NodePath
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
Definition:
nodePath.h:159
ShaderAttrib::has_shader_input
bool has_shader_input(CPT_InternalName id) const
Returns true if there is a ShaderInput of the given name.
Definition:
shaderAttrib.I:104
ShaderAttrib::get_instance_count
get_instance_count
Returns the number of geometry instances.
Definition:
shaderAttrib.h:127
ShaderAttrib::has_shader
bool has_shader() const
If true, the shader field of this attribute overrides the shader field of the parent attribute.
Definition:
shaderAttrib.I:62
ShaderInput
This is a small container class that can hold any one of the value types that can be passed as input ...
Definition:
shaderInput.h:40
Generated on Mon Sep 14 2020 15:07:02 for Panda3D by
1.8.20