Panda3D
Classes | Public Member Functions | List of all members
MultitexReducer Class Reference

This object presents an interface for generating new texture images that represent the combined images from one or more individual textures, reproducing certain kinds of multitexture effects without depending on multitexture support in the hardware. More...

#include "multitexReducer.h"

Public Member Functions

void clear ()
 Removes the record of nodes that were previously discovered by scan(). More...
 
void flatten (GraphicsOutput *window)
 Actually performs the reducing operations on the nodes that were previously scanned. More...
 
void scan (const NodePath &node)
 Starts scanning the hierarchy beginning at the indicated node. More...
 
void scan (const NodePath &node, const NodePath &state_from)
 Starts scanning the hierarchy beginning at the indicated node. More...
 
void scan (PandaNode *node, const RenderState *state, const TransformState *transform)
 Starts scanning the hierarchy beginning at the indicated node. More...
 
void set_allow_tex_mat (bool allow_tex_mat)
 Indicates whether the resulting texture should be expected to be animated beyond its current range via a texture matrix (true), or whether the current range of texture coordinates will be sufficient forever (false). More...
 
void set_target (TextureStage *stage)
 Specifies the target TextureStage (and InternalName) that will be left on each multitexture node after the flatten operation has completed. More...
 
void set_use_geom (bool use_geom)
 Indicates whether the actual geometry will be used to generate the textures. More...
 

Detailed Description

This object presents an interface for generating new texture images that represent the combined images from one or more individual textures, reproducing certain kinds of multitexture effects without depending on multitexture support in the hardware.

This also flattens out texture matrices and removes extra texture coordinates from the Geoms. It is thus not a complete substitute for true multitexturing, because it does not lend itself well to dynamic animation of the textures once they have been flattened. It is, however, useful for "baking in" a particular multitexture effect.

Definition at line 47 of file multitexReducer.h.

Member Function Documentation

◆ clear()

void MultitexReducer::clear ( )

Removes the record of nodes that were previously discovered by scan().

Definition at line 64 of file multitexReducer.cxx.

◆ flatten()

void MultitexReducer::flatten ( GraphicsOutput window)

Actually performs the reducing operations on the nodes that were previously scanned.

A window that can be used to create texture buffers suitable for rendering this geometry must be supplied. This specifies the particular GSG that will be used to composite the textures.

Definition at line 165 of file multitexReducer.cxx.

References Texture::get_anisotropic_degree, Texture::get_magfilter, Texture::get_minfilter, GraphicsOutput::get_texture(), GraphicsOutput::make_display_region(), Texture::set_anisotropic_degree, Texture::set_magfilter, Texture::set_minfilter, and GraphicsOutput::set_one_shot.

◆ scan() [1/3]

void MultitexReducer::scan ( const NodePath node)
inline

Starts scanning the hierarchy beginning at the indicated node.

Any GeomNodes discovered in the hierarchy with multitexture will be added to internal structures in the MultitexReducer so that a future call to flatten() will operate on all of these at once.

This version of this method does not accumulate state from the parents of the indicated node; thus, only multitexture effects that have been applied at node and below will be considered.

Definition at line 25 of file multitexReducer.I.

References NodePath::node().

Referenced by scan().

◆ scan() [2/3]

void MultitexReducer::scan ( const NodePath node,
const NodePath state_from 
)
inline

Starts scanning the hierarchy beginning at the indicated node.

Any GeomNodes discovered in the hierarchy with multitexture will be added to internal structures in the MultitexReducer so that a future call to flatten() will operate on all of these at once.

The second parameter represents the NodePath from which to accumulate the state that is considered for the multitexture. Pass an empty NodePath to accumulate all the state from the root of the graph, or you may specify some other node here in order to not consider nodes above that as contributing to the state to be flattened. This is particularly useful if you have some texture stage which is applied globally to a scene (for instance, a caustics effect), which you don't want to be considered for flattening by the MultitexReducer.

Definition at line 45 of file multitexReducer.I.

References NodePath::get_parent, NodePath::node(), and scan().

◆ scan() [3/3]

void MultitexReducer::scan ( PandaNode node,
const RenderState state,
const TransformState transform 
)

Starts scanning the hierarchy beginning at the indicated node.

Any GeomNodes discovered in the hierarchy with multitexture will be added to internal structures in the MultitexReducer so that a future call to flatten() will operate on all of these at once.

The indicated transform and state are the state inherited from the node's ancestors; any multitexture operations will be accumulated from the indicated starting state.

Definition at line 80 of file multitexReducer.cxx.

◆ set_allow_tex_mat()

void MultitexReducer::set_allow_tex_mat ( bool  allow_tex_mat)

Indicates whether the resulting texture should be expected to be animated beyond its current range via a texture matrix (true), or whether the current range of texture coordinates will be sufficient forever (false).

If this is set to true, then the entire texture image must be generated, in the assumption that the user may animate the texture around on the surface after it has been composed.

If this is set to false (the default), then only the portion of the texture image which is actually in use must be generated, which may be a significant savings in texture memory.

Definition at line 152 of file multitexReducer.cxx.

◆ set_target()

void MultitexReducer::set_target ( TextureStage stage)

Specifies the target TextureStage (and InternalName) that will be left on each multitexture node after the flatten operation has completed.

Definition at line 111 of file multitexReducer.cxx.

◆ set_use_geom()

void MultitexReducer::set_use_geom ( bool  use_geom)

Indicates whether the actual geometry will be used to generate the textures.

If this is set to true, the geometry discovered by scan() will be used to generate the textures, which allows for the vertex and polygon colors to be made part of the texture itself (and makes the M_decal multitexture mode more reliable). However, this only works if the geometry does not contain multiple different polygons that map to the same UV range.

If this is set to false (the default), a plain flat card will be used to generate the textures, which is more robust in general, but the resulting texture will not include vertex colors and M_decal won't work properly.

Note that in case multiple sets of texture coordinates are in effect, then the additional sets will always use the geometry anyway regardless of the setting of this flag (but this will not affect vertex color).

Definition at line 134 of file multitexReducer.cxx.


The documentation for this class was generated from the following files: