25 INLINE
const std::string &TextureStage::
56 if (_used_by_auto_shader) {
57 GraphicsStateGuardianBase::mark_rehash_generated_shaders();
64 INLINE
int TextureStage::
88 if (_used_by_auto_shader) {
89 GraphicsStateGuardianBase::mark_rehash_generated_shaders();
99 INLINE
int TextureStage::
100 get_priority()
const {
110 if (name != _texcoord_name) {
111 _texcoord_name = name;
113 if (_used_by_auto_shader) {
114 GraphicsStateGuardianBase::mark_rehash_generated_shaders();
132 get_texcoord_name()
const {
133 return _texcoord_name;
141 get_tangent_name()
const {
142 if (_texcoord_name->get_parent() ==
nullptr) {
143 return InternalName::get_tangent();
145 return InternalName::get_tangent_name(_texcoord_name->get_basename());
154 get_binormal_name()
const {
155 if (_texcoord_name->get_parent() ==
nullptr) {
156 return InternalName::get_binormal();
158 return InternalName::get_binormal_name(_texcoord_name->get_basename());
170 if (_mode != M_combine) {
171 _num_combine_rgb_operands = 0;
172 _num_combine_alpha_operands = 0;
175 update_color_flags();
182 INLINE TextureStage::Mode TextureStage::
194 return (_mode < M_normal);
208 INLINE LColor TextureStage::
222 if (rgb_scale != _rgb_scale) {
223 nassertv(rgb_scale == 1 || rgb_scale == 2 || rgb_scale == 4);
224 _rgb_scale = rgb_scale;
226 if (_used_by_auto_shader) {
227 GraphicsStateGuardianBase::mark_rehash_generated_shaders();
235 INLINE
int TextureStage::
236 get_rgb_scale()
const {
248 if (alpha_scale != _alpha_scale) {
249 nassertv(alpha_scale == 1 || alpha_scale == 2 || alpha_scale == 4);
250 _alpha_scale = alpha_scale;
252 if (_used_by_auto_shader) {
253 GraphicsStateGuardianBase::mark_rehash_generated_shaders();
261 INLINE
int TextureStage::
262 get_alpha_scale()
const {
279 if (saved_result != _saved_result) {
280 _saved_result = saved_result;
282 if (_used_by_auto_shader) {
283 GraphicsStateGuardianBase::mark_rehash_generated_shaders();
292 INLINE
bool TextureStage::
293 get_saved_result()
const {
294 return _saved_result;
307 _tex_view_offset = tex_view_offset;
314 INLINE
int TextureStage::
315 get_tex_view_offset()
const {
316 return _tex_view_offset;
325 CombineSource source0, CombineOperand operand0) {
326 nassertv(get_expected_num_combine_operands(mode) == 1);
327 nassertv(operand_valid_for_rgb(operand0));
329 _num_combine_rgb_operands = 1;
330 _combine_rgb_mode = mode;
331 _combine_rgb_source0 = source0;
332 _combine_rgb_operand0 = operand0;
333 _combine_rgb_source1 = CS_undefined;
334 _combine_rgb_operand1 = CO_undefined;
335 _combine_rgb_source2 = CS_undefined;
336 _combine_rgb_operand2 = CO_undefined;
338 update_color_flags();
348 CombineSource source0, CombineOperand operand0,
349 CombineSource source1, CombineOperand operand1) {
350 nassertv(get_expected_num_combine_operands(mode) == 2);
351 nassertv(operand_valid_for_rgb(operand0));
352 nassertv(operand_valid_for_rgb(operand1));
354 _num_combine_rgb_operands = 2;
355 _combine_rgb_mode = mode;
356 _combine_rgb_source0 = source0;
357 _combine_rgb_operand0 = operand0;
358 _combine_rgb_source1 = source1;
359 _combine_rgb_operand1 = operand1;
360 _combine_rgb_source2 = CS_undefined;
361 _combine_rgb_operand2 = CO_undefined;
363 update_color_flags();
372 CombineSource source0, CombineOperand operand0,
373 CombineSource source1, CombineOperand operand1,
374 CombineSource source2, CombineOperand operand2) {
375 nassertv(get_expected_num_combine_operands(mode) == 3);
376 nassertv(operand_valid_for_rgb(operand0));
377 nassertv(operand_valid_for_rgb(operand1));
378 nassertv(operand_valid_for_rgb(operand2));
380 _num_combine_rgb_operands = 3;
381 _combine_rgb_mode = mode;
382 _combine_rgb_source0 = source0;
383 _combine_rgb_operand0 = operand0;
384 _combine_rgb_source1 = source1;
385 _combine_rgb_operand1 = operand1;
386 _combine_rgb_source2 = source2;
387 _combine_rgb_operand2 = operand2;
389 update_color_flags();
397 return _combine_rgb_mode;
406 return _num_combine_rgb_operands;
414 return _combine_rgb_source0;
422 return _combine_rgb_operand0;
430 return _combine_rgb_source1;
438 return _combine_rgb_operand1;
446 return _combine_rgb_source2;
454 return _combine_rgb_operand2;
463 CombineSource source0, CombineOperand operand0) {
464 nassertv(get_expected_num_combine_operands(mode) == 1);
465 nassertv(operand_valid_for_alpha(operand0));
467 _num_combine_alpha_operands = 1;
468 _combine_alpha_mode = mode;
469 _combine_alpha_source0 = source0;
470 _combine_alpha_operand0 = operand0;
471 _combine_alpha_source1 = CS_undefined;
472 _combine_alpha_operand1 = CO_undefined;
473 _combine_alpha_source2 = CS_undefined;
474 _combine_alpha_operand2 = CO_undefined;
476 update_color_flags();
486 CombineSource source0, CombineOperand operand0,
487 CombineSource source1, CombineOperand operand1) {
488 nassertv(get_expected_num_combine_operands(mode) == 2);
489 nassertv(operand_valid_for_alpha(operand0));
490 nassertv(operand_valid_for_alpha(operand1));
492 _num_combine_alpha_operands = 2;
493 _combine_alpha_mode = mode;
494 _combine_alpha_source0 = source0;
495 _combine_alpha_operand0 = operand0;
496 _combine_alpha_source1 = source1;
497 _combine_alpha_operand1 = operand1;
498 _combine_alpha_source2 = CS_undefined;
499 _combine_alpha_operand2 = CO_undefined;
501 update_color_flags();
510 CombineSource source0, CombineOperand operand0,
511 CombineSource source1, CombineOperand operand1,
512 CombineSource source2, CombineOperand operand2) {
513 nassertv(get_expected_num_combine_operands(mode) == 3);
514 nassertv(operand_valid_for_alpha(operand0));
515 nassertv(operand_valid_for_alpha(operand1));
516 nassertv(operand_valid_for_alpha(operand2));
518 _num_combine_alpha_operands = 3;
519 _combine_alpha_mode = mode;
520 _combine_alpha_source0 = source0;
521 _combine_alpha_operand0 = operand0;
522 _combine_alpha_source1 = source1;
523 _combine_alpha_operand1 = operand1;
524 _combine_alpha_source2 = source2;
525 _combine_alpha_operand2 = operand2;
527 update_color_flags();
535 return _combine_alpha_mode;
544 return _num_combine_alpha_operands;
552 return _combine_alpha_source0;
560 return _combine_alpha_operand0;
568 return _combine_alpha_source1;
576 return _combine_alpha_operand1;
584 return _combine_alpha_source2;
592 return _combine_alpha_operand2;
601 return _involves_color_scale;
619 return _uses_primary_color;
628 return _uses_last_saved_result;
634 INLINE
bool TextureStage::
642 INLINE
bool TextureStage::
650 INLINE
bool TextureStage::
662 if (_default_stage ==
nullptr) {
665 return _default_stage;
684 _used_by_auto_shader =
true;
691 INLINE
void TextureStage::
692 update_color_flags() {
693 _involves_color_scale =
694 (_mode == M_blend_color_scale ||
695 (_mode == M_combine &&
696 (_combine_rgb_source0 == CS_constant_color_scale ||
697 _combine_rgb_source1 == CS_constant_color_scale ||
698 _combine_rgb_source2 == CS_constant_color_scale ||
699 _combine_alpha_source0 == CS_constant_color_scale ||
700 _combine_alpha_source1 == CS_constant_color_scale ||
701 _combine_alpha_source2 == CS_constant_color_scale)));
704 (_mode == M_blend || _mode == M_blend_color_scale ||
705 (_mode == M_combine &&
706 (_combine_rgb_source0 == CS_constant ||
707 _combine_rgb_source1 == CS_constant ||
708 _combine_rgb_source2 == CS_constant ||
709 _combine_alpha_source0 == CS_constant ||
710 _combine_alpha_source1 == CS_constant ||
711 _combine_alpha_source2 == CS_constant)));
713 _uses_primary_color =
714 (_mode == M_combine &&
715 (_combine_rgb_source0 == CS_primary_color ||
716 _combine_rgb_source1 == CS_primary_color ||
717 _combine_rgb_source2 == CS_primary_color ||
718 _combine_alpha_source0 == CS_primary_color ||
719 _combine_alpha_source1 == CS_primary_color ||
720 _combine_alpha_source2 == CS_primary_color));
722 _uses_last_saved_result =
723 (_mode == M_combine &&
724 (_combine_rgb_source0 == CS_last_saved_result ||
725 _combine_rgb_source1 == CS_last_saved_result ||
726 _combine_rgb_source2 == CS_last_saved_result ||
727 _combine_alpha_source0 == CS_last_saved_result ||
728 _combine_alpha_source1 == CS_last_saved_result ||
729 _combine_alpha_source2 == CS_last_saved_result));
731 if (_used_by_auto_shader) {
732 GraphicsStateGuardianBase::mark_rehash_generated_shaders();
736 INLINE std::ostream &
737 operator << (std::ostream &out,
const TextureStage &ts) {
CombineSource get_combine_alpha_source2() const
Get source2 of combine_alpha_mode.
set_name
Changes the name of this texture stage.
CombineOperand get_combine_alpha_operand0() const
Get operand0 of combine_alpha_mode.
static UpdateSeq get_sort_seq()
Returns a global sequence number that is incremented any time any TextureStage in the world changes s...
set_saved_result
Sets the saved_result flag.
set_mode
Set the mode of this texture stage.
set_priority
Changes the relative importance of the texture associated with this stage relative to the other textu...
set_sort
Changes the order in which the texture associated with this stage is rendered relative to the other t...
set_color
Set the color for this stage.
int get_num_combine_alpha_operands() const
Returns the number of meaningful operands that may be retrieved via get_combine_alpha_sourceN() and g...
CombineOperand get_combine_rgb_operand1() const
Get operand1 of combine_rgb_mode.
CombineSource get_combine_rgb_source1() const
Get source1 of combine_rgb_mode.
set_tex_view_offset
Sets the tex_view_offset value.
void output(std::ostream &out) const
Just a single line output.
int compare_to(const TextureStage &other) const
Returns a number less than zero if this TextureStage sorts before the other one, greater than zero if...
bool uses_last_saved_result() const
Returns true if the TextureStage makes use of the CS_primary_color combine source.
CombineSource get_combine_alpha_source0() const
Get source0 of combine_alpha_mode.
bool uses_primary_color() const
Returns true if the TextureStage makes use of the CS_primary_color combine source.
void set_combine_alpha(CombineMode mode, CombineSource source0, CombineOperand operand0)
Specifies any of the CombineMode values that represent a one-parameter operation.
CombineSource get_combine_rgb_source2() const
Get source2 of combine_rgb_mode.
bool is_fixed_function() const
Returns true if the TextureStage is relevant to the classic fixed function pipeline.
CombineOperand get_combine_rgb_operand0() const
Get operand0 of combine_rgb_mode.
int get_num_combine_rgb_operands() const
Returns the number of meaningful operands that may be retrieved via get_combine_rgb_sourceN() and get...
void mark_used_by_auto_shader() const
Marks this TextureStage as having been used by the auto shader.
CombineMode get_combine_alpha_mode() const
Get combine_alpha_mode.
CombineOperand get_combine_alpha_operand1() const
Get operand1 of combine_alpha_mode.
Encodes a string name in a hash table, mapping it to a pointer.
CombineMode get_combine_rgb_mode() const
Get the combine_rgb_mode.
void set_combine_rgb(CombineMode mode, CombineSource source0, CombineOperand operand0)
Specifies any of the CombineMode values that represent a one-parameter operation.
CombineSource get_combine_rgb_source0() const
Get source0 of combine_rgb_mode.
set_texcoord_name
Indicate which set of UV's this texture stage will use.
bool involves_color_scale() const
Returns true if the TextureStage is affected by the setting of the current ColorScaleAttrib,...
CombineOperand get_combine_rgb_operand2() const
Get operand2 of combine_rgb_mode.
CombineSource get_combine_alpha_source1() const
Get source1 of combine_alpha_mode.
CombineOperand get_combine_alpha_operand2() const
Get operand2 of combine_alpha_mode.
bool uses_color() const
Returns true if the TextureStage makes use of whatever color is specified in set_color(),...
This is a sequence number that increments monotonically.
Defines the properties of a named stage of the multitexture pipeline.
set_rgb_scale
Sets an additional factor that will scale all three r, g, b components after the texture has been app...
set_alpha_scale
Sets an additional factor that will scale the alpha component after the texture has been applied.
TextureStage(const std::string &name)
Initialize the texture stage at construction.