Added derivative textures

This commit is contained in:
Josh Yelon 2005-10-05 16:25:02 +00:00
parent 8f74f5eaaf
commit 9478e2bf08
6 changed files with 230 additions and 166 deletions

View File

@ -1,90 +1,90 @@
###########################################################
### ###
### Panda3D Configuration File - Auto-Generated Portion ###
### ###
### Editing this file is not recommended. Most of these ###
### directives can be overriden in Config.prc ###
### ###
###########################################################
# Define the display types that have been compiled in. Panda will
# pick one of these by going through the list in this order until one
# is found that works, unless the user specifically requests a
# particular display type with the load-display directive.
aux-display pandagl
aux-display pandadx9
aux-display pandadx8
aux-display pandadx7
# The egg loader is handy to have available by default. This allows
# clients to load egg files. (The bam loader is built-in so bam files
# are always loadable).
# By qualifying with the extension "egg", we indicate the egg loader
# should be made available only if you explicitly name a file with an
# .egg extension.
load-file-type egg pandaegg
# The following lines define some handy object types to use within the
# egg syntax. This remaps <ObjectType> { name } into whatever egg
# syntax is given by egg-object-type-name, which makes a handy
# abbreviation for modeling packages (like Maya) to insert
# sophisticated egg syntax into the generated egg file, using a single
# object type string.
egg-object-type-portal <Scalar> portal { 1 }
egg-object-type-polylight <Scalar> polylight { 1 }
egg-object-type-seq24 <Switch> { 1 } <Scalar> fps { 24 }
egg-object-type-seq12 <Switch> { 1 } <Scalar> fps { 12 }
egg-object-type-indexed <Scalar> indexed { 1 }
# These are just shortcuts to define the Model and DCS flags, which
# indicate nodes that should not be flattened out of the hierarchy
# during the conversion process. DCS goes one step further and
# indicates that the node's transform is important and should be
# preserved (DCS stands for Dynamic Coordinate System).
egg-object-type-model <Model> { 1 }
egg-object-type-dcs <DCS> { 1 }
# The following define various kinds of collision geometry. These
# mark the geometry at this level and below as invisible collision
# polygons, which can be used by Panda's collision system to detect
# collisions more optimally than regular visible polygons.
egg-object-type-barrier <Collide> { Polyset descend }
egg-object-type-sphere <Collide> { Sphere descend }
egg-object-type-invsphere <Collide> { InvSphere descend }
egg-object-type-tube <Collide> { Tube descend }
# As above, but these are flagged to be "intangible", so that they
# will trigger an event but not stop an object from passing through.
egg-object-type-trigger <Collide> { Polyset descend intangible }
egg-object-type-trigger-sphere <Collide> { Sphere descend intangible }
# "bubble" puts an invisible bubble around an object, but does not
# otherwise remove the geometry.
egg-object-type-bubble <Collide> { Sphere keep descend }
# "ghost" turns off the normal collide bit that is set on visible
# geometry by default, so that if you are using visible geometry for
# collisions, this particular geometry will not be part of those
# collisions--it is ghostlike.
egg-object-type-ghost <Scalar> collide-mask { 0 }
# This module allows direct loading of formats like .flt, .mb, or .dxf
load-file-type ptloader
# Define a new egg object type. See the comments in _panda.prc about this.
egg-object-type-direct-widget <Scalar> collide-mask { 0x80000000 } <Collide> { Polyset descend }
# Define a new cull bin that will render on top of everything else.
cull-bin gui-popup 60 unsorted
###########################################################
### ###
### Panda3D Configuration File - Auto-Generated Portion ###
### ###
### Editing this file is not recommended. Most of these ###
### directives can be overriden in Config.prc ###
### ###
###########################################################
# Define the display types that have been compiled in. Panda will
# pick one of these by going through the list in this order until one
# is found that works, unless the user specifically requests a
# particular display type with the load-display directive.
aux-display pandagl
aux-display pandadx9
aux-display pandadx8
aux-display pandadx7
# The egg loader is handy to have available by default. This allows
# clients to load egg files. (The bam loader is built-in so bam files
# are always loadable).
# By qualifying with the extension "egg", we indicate the egg loader
# should be made available only if you explicitly name a file with an
# .egg extension.
load-file-type egg pandaegg
# The following lines define some handy object types to use within the
# egg syntax. This remaps <ObjectType> { name } into whatever egg
# syntax is given by egg-object-type-name, which makes a handy
# abbreviation for modeling packages (like Maya) to insert
# sophisticated egg syntax into the generated egg file, using a single
# object type string.
egg-object-type-portal <Scalar> portal { 1 }
egg-object-type-polylight <Scalar> polylight { 1 }
egg-object-type-seq24 <Switch> { 1 } <Scalar> fps { 24 }
egg-object-type-seq12 <Switch> { 1 } <Scalar> fps { 12 }
egg-object-type-indexed <Scalar> indexed { 1 }
# These are just shortcuts to define the Model and DCS flags, which
# indicate nodes that should not be flattened out of the hierarchy
# during the conversion process. DCS goes one step further and
# indicates that the node's transform is important and should be
# preserved (DCS stands for Dynamic Coordinate System).
egg-object-type-model <Model> { 1 }
egg-object-type-dcs <DCS> { 1 }
# The following define various kinds of collision geometry. These
# mark the geometry at this level and below as invisible collision
# polygons, which can be used by Panda's collision system to detect
# collisions more optimally than regular visible polygons.
egg-object-type-barrier <Collide> { Polyset descend }
egg-object-type-sphere <Collide> { Sphere descend }
egg-object-type-invsphere <Collide> { InvSphere descend }
egg-object-type-tube <Collide> { Tube descend }
# As above, but these are flagged to be "intangible", so that they
# will trigger an event but not stop an object from passing through.
egg-object-type-trigger <Collide> { Polyset descend intangible }
egg-object-type-trigger-sphere <Collide> { Sphere descend intangible }
# "bubble" puts an invisible bubble around an object, but does not
# otherwise remove the geometry.
egg-object-type-bubble <Collide> { Sphere keep descend }
# "ghost" turns off the normal collide bit that is set on visible
# geometry by default, so that if you are using visible geometry for
# collisions, this particular geometry will not be part of those
# collisions--it is ghostlike.
egg-object-type-ghost <Scalar> collide-mask { 0 }
# This module allows direct loading of formats like .flt, .mb, or .dxf
load-file-type ptloader
# Define a new egg object type. See the comments in _panda.prc about this.
egg-object-type-direct-widget <Scalar> collide-mask { 0x80000000 } <Collide> { Polyset descend }
# Define a new cull bin that will render on top of everything else.
cull-bin gui-popup 60 unsorted

View File

@ -1,74 +1,74 @@
###########################################################
### ###
### Panda3D Configuration File - User-Editable Portion ###
### ###
###########################################################
# Uncomment one of the following lines to choose whether you should
# run using OpenGL or DirectX rendering.
load-display pandagl
# These control the placement and size of the default rendering window.
win-origin 100 0
win-size 800 600
# Uncomment this line if you want to run Panda fullscreen instead of
# in a window.
fullscreen #f
# If you don't object to running OpenGL in software leave the keyword
# "software" in the following line, otherwise remove it to force
# hardware only.
framebuffer-mode rgba double-buffer depth hardware
# These control the amount of output Panda gives for some various
# categories. The severity levels, in order, are "spam", "debug",
# "info", "warning", and "fatal"; the default is "info". Uncomment
# one (or define a new one for the particular category you wish to
# change) to control this output.
notify-level warning
default-directnotify-level warning
# These specify where model files may be loaded from. You probably
# want to set this to a sensible path for yourself. $THIS_PRC_DIR is
# a special variable that indicates the same directory as this
# particular Config.prc file.
model-path .
model-path $THIS_PRC_DIR/..
model-path $THIS_PRC_DIR/../models
sound-path .
sound-path $THIS_PRC_DIR/..
sound-path $THIS_PRC_DIR/../models
texture-path .
texture-path $THIS_PRC_DIR/..
texture-path $THIS_PRC_DIR/../models
# This enable the automatic creation of a TK window when running
# Direct.
want-directtools #f
want-tk #f
# Enable/disable performance profiling tool and frame-rate meter
want-pstats #f
show-frame-rate-meter #f
# This enables simple networked programs to easily provide a DC file
dc-file sample.dc
# Enable audio using the FMod audio library by default:
audio-library-name fmod_audio
# The new version of panda supports hardware vertex animation, but it's not quite ready
hardware-animated-vertices 0
###########################################################
### ###
### Panda3D Configuration File - User-Editable Portion ###
### ###
###########################################################
# Uncomment one of the following lines to choose whether you should
# run using OpenGL or DirectX rendering.
load-display pandagl
# These control the placement and size of the default rendering window.
win-origin 100 0
win-size 800 600
# Uncomment this line if you want to run Panda fullscreen instead of
# in a window.
fullscreen #f
# If you don't object to running OpenGL in software leave the keyword
# "software" in the following line, otherwise remove it to force
# hardware only.
framebuffer-mode rgba double-buffer depth hardware
# These control the amount of output Panda gives for some various
# categories. The severity levels, in order, are "spam", "debug",
# "info", "warning", and "fatal"; the default is "info". Uncomment
# one (or define a new one for the particular category you wish to
# change) to control this output.
notify-level warning
default-directnotify-level warning
# These specify where model files may be loaded from. You probably
# want to set this to a sensible path for yourself. $THIS_PRC_DIR is
# a special variable that indicates the same directory as this
# particular Config.prc file.
model-path .
model-path $THIS_PRC_DIR/..
model-path $THIS_PRC_DIR/../models
sound-path .
sound-path $THIS_PRC_DIR/..
sound-path $THIS_PRC_DIR/../models
texture-path .
texture-path $THIS_PRC_DIR/..
texture-path $THIS_PRC_DIR/../models
# This enable the automatic creation of a TK window when running
# Direct.
want-directtools #f
want-tk #f
# Enable/disable performance profiling tool and frame-rate meter
want-pstats #f
show-frame-rate-meter #f
# This enables simple networked programs to easily provide a DC file
dc-file sample.dc
# Enable audio using the FMod audio library by default:
audio-library-name fmod_audio
# The new version of panda supports hardware vertex animation, but it's not quite ready
hardware-animated-vertices 0

View File

@ -362,6 +362,13 @@ update_shader_texture_bindings(CLP(ShaderContext) *prev, GSG *gsg)
TextureStage *stage = gsg->_target._texture->get_on_stage(_cg_texbind[i].stage);
tex = gsg->_target._texture->get_on_texture(stage);
}
if (_cg_texbind[i].suffix != 0) {
// The suffix feature is inefficient. It is a temporary hack.
if (tex == 0) {
continue;
}
tex = tex->load_related(_cg_texbind[i].suffix);
}
if ((tex == 0) || (tex->get_texture_type() != _cg_texbind[i].desiredtype)) {
continue;
}
@ -824,11 +831,14 @@ compile_cg_parameter(CGparameter p)
}
if (pieces[0] == "tex") {
if ((!errchk_cg_parameter_words(p,2)) ||
(!errchk_cg_parameter_direction(p, CG_IN)) ||
if ((!errchk_cg_parameter_direction(p, CG_IN)) ||
(!errchk_cg_parameter_variance(p, CG_UNIFORM)) ||
(!errchk_cg_parameter_sampler(p)))
return false;
if ((pieces.size() != 2)&&(pieces.size() != 3)) {
errchk_cg_output(p, "Invalid parameter name");
return false;
}
ShaderTexBind bind;
bind.parameter = p;
bind.name = 0;
@ -842,6 +852,9 @@ compile_cg_parameter(CGparameter p)
errchk_cg_output(p, "Invalid type for a tex-parameter");
return false;
}
if (pieces.size()==3) {
bind.suffix = InternalName::make(((string)"-") + pieces[2]);
}
_cg_texbind.push_back(bind);
return true;
}

View File

@ -65,6 +65,7 @@ private:
PT(InternalName) name;
int stage;
int desiredtype;
PT(InternalName) suffix;
};
struct ShaderTransBind {
CGparameter parameter;

View File

@ -750,6 +750,45 @@ store(PNMImage &pnmimage, int z) const {
return false;
}
////////////////////////////////////////////////////////////////////
// Function: Texture::load_related
// Access: Published
// Description: Loads a texture whose filename is derived by
// concatenating a suffix to the filename of this
// texture. May return NULL, for example, if this
// texture doesn't have a filename.
////////////////////////////////////////////////////////////////////
Texture *Texture::
load_related(const PT(InternalName) &suffix) const {
RelatedTextures::const_iterator ti;
ti = _related_textures.find(suffix);
if (ti != _related_textures.end()) {
return (*ti).second;
}
if (!has_fullpath()) {
return (Texture*)NULL;
}
Filename main = get_fullpath();
main.set_basename_wo_extension(main.get_basename_wo_extension() +
suffix->get_name());
Texture *res;
if (has_alpha_fullpath()) {
Filename alph = get_alpha_fullpath();
alph.set_basename_wo_extension(alph.get_basename_wo_extension() +
suffix->get_name());
res = TexturePool::load_texture(main, alph,
_primary_file_num_channels,
_alpha_file_channel);
} else {
res = TexturePool::load_texture(main,
_primary_file_num_channels);
}
// I'm casting away the const-ness of 'this' because this
// field is only a cache.
((Texture *)this)->_related_textures.insert(RelatedTextures::value_type(suffix, res));
return res;
}
////////////////////////////////////////////////////////////////////
// Function: Texture::set_wrap_u
// Access: Published

View File

@ -24,6 +24,7 @@
#include "filename.h"
#include "typedWritableReferenceCount.h"
#include "namable.h"
#include "internalName.h"
#include "graphicsStateGuardianBase.h"
#include "pmap.h"
@ -181,6 +182,8 @@ PUBLISHED:
virtual bool load(const PNMImage &pnmimage, int z = 0);
bool store(PNMImage &pnmimage, int z = 0) const;
Texture *load_related(const PT(InternalName) &suffix) const;
INLINE bool has_filename() const;
INLINE const Filename &get_filename() const;
INLINE bool has_alpha_filename() const;
@ -353,6 +356,14 @@ protected:
typedef pmap<PreparedGraphicsObjects *, TextureContext *> Contexts;
Contexts _contexts;
// It is common, when using normal maps, specular maps, gloss maps,
// and such, to use a file naming convention where the filenames
// of the special maps are derived by concatenating a suffix to
// the name of the diffuse map. The following table enables
// lookup of the special maps given the diffuse map and the suffix.
typedef pmap<PT(InternalName), PT(Texture)> RelatedTextures;
RelatedTextures _related_textures;
// This value represents the intersection of all the dirty flags of
// the various TextureContexts that might be associated with this
// texture.