mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 10:22:45 -04:00
hardware-point-sprites, GR_point_sprite_tex_matrix
This commit is contained in:
parent
14a3fa8ac9
commit
23e43fc04e
@ -226,12 +226,11 @@ DXGraphicsStateGuardian8(const FrameBufferProperties &properties) :
|
||||
_copy_texture_inverted = true;
|
||||
|
||||
// D3DRS_POINTSPRITEENABLE doesn't seem to support remapping the
|
||||
// texture coordinates via a texture matrix, a fatal flaw. Without
|
||||
// that support, we don't advertise this capability, and fall back
|
||||
// to always generating quads for textured sprites.
|
||||
// texture coordinates via a texture matrix, so we don't advertise
|
||||
// GR_point_sprite_tex_matrix.
|
||||
_supported_geom_rendering =
|
||||
qpGeom::GR_point | qpGeom::GR_point_uniform_size |
|
||||
qpGeom::GR_point_perspective | /* qpGeom::GR_point_sprite |*/
|
||||
qpGeom::GR_point_perspective | qpGeom::GR_point_sprite |
|
||||
qpGeom::GR_triangle_strip | qpGeom::GR_triangle_fan |
|
||||
qpGeom::GR_flat_first_vertex;
|
||||
}
|
||||
|
@ -130,6 +130,14 @@ ConfigVariableBool hardware_animated_vertices
|
||||
"necessary on your computer's bus. However, in some cases it "
|
||||
"may actually reduce performance."));
|
||||
|
||||
ConfigVariableBool hardware_point_sprites
|
||||
("hardware-point-sprites", true,
|
||||
PRC_DESC("Set this true to allow the use of hardware extensions when "
|
||||
"rendering perspective-scaled points and point sprites. When "
|
||||
"false, these large points are always simulated via quads "
|
||||
"computed in software, even if the hardware claims it can "
|
||||
"support them directly."));
|
||||
|
||||
ConfigVariableBool matrix_palette
|
||||
("matrix-palette", false,
|
||||
PRC_DESC("Set this true to allow the use of the matrix palette when "
|
||||
|
@ -54,6 +54,7 @@ extern EXPCL_PANDA ConfigVariableBool retained_mode;
|
||||
extern EXPCL_PANDA ConfigVariableBool vertex_buffers;
|
||||
extern EXPCL_PANDA ConfigVariableBool display_lists;
|
||||
extern EXPCL_PANDA ConfigVariableBool hardware_animated_vertices;
|
||||
extern EXPCL_PANDA ConfigVariableBool hardware_point_sprites;
|
||||
extern EXPCL_PANDA ConfigVariableBool matrix_palette;
|
||||
extern EXPCL_PANDA ConfigVariableBool display_list_animation;
|
||||
extern EXPCL_PANDA ConfigVariableBool connect_triangle_strips;
|
||||
|
@ -116,23 +116,27 @@ PUBLISHED:
|
||||
// their face, to render textures as sprites.
|
||||
GR_point_sprite = 0x0080,
|
||||
|
||||
// If there is a texture matrix applied to the sprite's generated
|
||||
// texture coordinates.
|
||||
GR_point_sprite_tex_matrix = 0x0100,
|
||||
|
||||
// The union of all the above point attributes, except GR_indexed_point.
|
||||
GR_point_bits = 0x00f3,
|
||||
GR_point_bits = 0x01f3,
|
||||
|
||||
// If there are any of these composite types.
|
||||
GR_triangle_strip = 0x0100,
|
||||
GR_triangle_fan = 0x0200,
|
||||
GR_line_strip = 0x0400,
|
||||
GR_triangle_strip = 0x0200,
|
||||
GR_triangle_fan = 0x0400,
|
||||
GR_line_strip = 0x0800,
|
||||
|
||||
// The union of all of the above composite types.
|
||||
GR_composite_bits = 0x0700,
|
||||
GR_composite_bits = 0x0e00,
|
||||
|
||||
// If the shade model requires a particular vertex for flat shading.
|
||||
GR_flat_first_vertex = 0x0800,
|
||||
GR_flat_last_vertex = 0x1000,
|
||||
GR_flat_first_vertex = 0x1000,
|
||||
GR_flat_last_vertex = 0x2000,
|
||||
|
||||
// The union of the above shade model types.
|
||||
GR_shade_model_bits = 0x1800,
|
||||
GR_shade_model_bits = 0x3000,
|
||||
};
|
||||
|
||||
// The shade model specifies whether the per-vertex colors and
|
||||
|
@ -54,7 +54,14 @@ munge_geom(GraphicsStateGuardianBase *gsg,
|
||||
int geom_rendering = _state->get_geom_rendering(qpgeom->get_geom_rendering());
|
||||
|
||||
GraphicsStateGuardianBase *gsg = traverser->get_gsg();
|
||||
int unsupported_bits = geom_rendering & ~gsg->get_supported_geom_rendering();
|
||||
int gsg_bits = gsg->get_supported_geom_rendering();
|
||||
if (!hardware_point_sprites) {
|
||||
// If support for hardware point sprites or perspective-scaled
|
||||
// points is disabled, we don't allow the GSG to tell us it
|
||||
// supports them.
|
||||
gsg_bits &= ~(qpGeom::GR_point_perspective | qpGeom::GR_point_sprite);
|
||||
}
|
||||
int unsupported_bits = geom_rendering & ~gsg_bits;
|
||||
if ((unsupported_bits & qpGeom::GR_point_bits) != 0) {
|
||||
// The GSG doesn't support rendering these fancy points
|
||||
// directly; we have to render them in software instead.
|
||||
|
@ -230,6 +230,25 @@ get_tex_gen() const {
|
||||
return _tex_gen;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: RenderState::get_tex_matrix
|
||||
// Access: Published
|
||||
// Description: This function is provided as an optimization, to
|
||||
// speed up the render-time checking for the existance
|
||||
// of a TexMatrixAttrib on this state. It returns a
|
||||
// pointer to the TexMatrixAttrib, if there is one, or
|
||||
// NULL if there is not.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE const TexMatrixAttrib *RenderState::
|
||||
get_tex_matrix() const {
|
||||
if ((_flags & F_checked_tex_matrix) == 0) {
|
||||
// We pretend this function is const, even though it transparently
|
||||
// modifies the internal tex_matrix cache.
|
||||
((RenderState *)this)->determine_tex_matrix();
|
||||
}
|
||||
return _tex_matrix;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: RenderState::get_render_mode
|
||||
// Access: Published
|
||||
@ -265,6 +284,9 @@ get_geom_rendering(int geom_rendering) const {
|
||||
if (get_tex_gen() != (const TexGenAttrib *)NULL) {
|
||||
geom_rendering = _tex_gen->get_geom_rendering(geom_rendering);
|
||||
}
|
||||
if (get_tex_matrix() != (const TexMatrixAttrib *)NULL) {
|
||||
geom_rendering = _tex_matrix->get_geom_rendering(geom_rendering);
|
||||
}
|
||||
|
||||
return geom_rendering;
|
||||
}
|
||||
|
@ -1575,6 +1575,21 @@ determine_tex_gen() {
|
||||
_flags |= F_checked_tex_gen;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: RenderState::determine_tex_matrix
|
||||
// Access: Private
|
||||
// Description: This is the private implementation of get_tex_matrix().
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void RenderState::
|
||||
determine_tex_matrix() {
|
||||
const RenderAttrib *attrib = get_attrib(TexMatrixAttrib::get_class_type());
|
||||
_tex_matrix = (const TexMatrixAttrib *)NULL;
|
||||
if (attrib != (const RenderAttrib *)NULL) {
|
||||
_tex_matrix = DCAST(TexMatrixAttrib, attrib);
|
||||
}
|
||||
_flags |= F_checked_tex_matrix;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: RenderState::determine_render_mode
|
||||
// Access: Private
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include "pStatCollector.h"
|
||||
#include "renderModeAttrib.h"
|
||||
#include "texGenAttrib.h"
|
||||
#include "texMatrixAttrib.h"
|
||||
|
||||
class GraphicsStateGuardianBase;
|
||||
class FogAttrib;
|
||||
@ -37,8 +38,6 @@ class TransparencyAttrib;
|
||||
class ColorAttrib;
|
||||
class ColorScaleAttrib;
|
||||
class TextureAttrib;
|
||||
class TexGenAttrib;
|
||||
class RenderModeAttrib;
|
||||
class FactoryParams;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@ -125,6 +124,7 @@ PUBLISHED:
|
||||
INLINE const ColorScaleAttrib *get_color_scale() const;
|
||||
INLINE const TextureAttrib *get_texture() const;
|
||||
INLINE const TexGenAttrib *get_tex_gen() const;
|
||||
INLINE const TexMatrixAttrib *get_tex_matrix() const;
|
||||
INLINE const RenderModeAttrib *get_render_mode() const;
|
||||
|
||||
INLINE int get_geom_rendering(int geom_rendering) const;
|
||||
@ -168,6 +168,7 @@ private:
|
||||
void determine_color_scale();
|
||||
void determine_texture();
|
||||
void determine_tex_gen();
|
||||
void determine_tex_matrix();
|
||||
void determine_render_mode();
|
||||
|
||||
INLINE void set_destructing();
|
||||
@ -246,6 +247,7 @@ private:
|
||||
const ColorScaleAttrib *_color_scale;
|
||||
const TextureAttrib *_texture;
|
||||
const TexGenAttrib *_tex_gen;
|
||||
const TexMatrixAttrib *_tex_matrix;
|
||||
const RenderModeAttrib *_render_mode;
|
||||
|
||||
enum Flags {
|
||||
@ -257,7 +259,8 @@ private:
|
||||
F_checked_color_scale = 0x0020,
|
||||
F_checked_texture = 0x0040,
|
||||
F_checked_tex_gen = 0x0080,
|
||||
F_checked_render_mode = 0x0100,
|
||||
F_checked_tex_matrix = 0x0100,
|
||||
F_checked_render_mode = 0x0200,
|
||||
F_is_destructing = 0x8000,
|
||||
};
|
||||
unsigned short _flags;
|
||||
|
@ -21,12 +21,11 @@
|
||||
|
||||
#include "pandabase.h"
|
||||
|
||||
#include "geom.h"
|
||||
#include "qpgeom.h"
|
||||
#include "renderAttrib.h"
|
||||
#include "textureStage.h"
|
||||
#include "texture.h"
|
||||
#include "pointerTo.h"
|
||||
#include "qpgeom.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Class : TexGenAttrib
|
||||
@ -83,6 +82,13 @@ PUBLISHED:
|
||||
// lower-right across the point's face. Without this, each point
|
||||
// will have just a single uniform texture coordinate value across
|
||||
// its face.
|
||||
|
||||
// Unfortunately, the generated texture coordinates are inverted
|
||||
// (upside-down) from Panda's usual convention, but this is what
|
||||
// the graphics card manufacturers decided to use. You could use
|
||||
// a texture matrix to re-invert the texture, but that will
|
||||
// probably force software rendering. You'll have to paint your
|
||||
// textures upside-down if you want true hardware sprites.
|
||||
M_point_sprite,
|
||||
};
|
||||
|
||||
|
@ -40,6 +40,25 @@ TexMatrixAttrib(const TexMatrixAttrib ©) :
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: TexMatrixAttrib::get_geom_rendering
|
||||
// Access: Published
|
||||
// Description: Returns the union of the Geom::GeomRendering bits
|
||||
// that will be required once this TexMatrixAttrib is
|
||||
// applied to a geom which includes the indicated
|
||||
// geom_rendering bits.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE int TexMatrixAttrib::
|
||||
get_geom_rendering(int geom_rendering) const {
|
||||
if ((geom_rendering & qpGeom::GR_point_sprite) != 0) {
|
||||
if (!is_empty()) {
|
||||
return geom_rendering |= qpGeom::GR_point_sprite_tex_matrix;
|
||||
}
|
||||
}
|
||||
|
||||
return geom_rendering;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: TexMatrixAttrib::check_stage_list
|
||||
// Access: Private
|
||||
|
@ -21,6 +21,7 @@
|
||||
|
||||
#include "pandabase.h"
|
||||
|
||||
#include "qpgeom.h"
|
||||
#include "renderAttrib.h"
|
||||
#include "textureStage.h"
|
||||
#include "transformState.h"
|
||||
@ -61,6 +62,8 @@ PUBLISHED:
|
||||
|
||||
CPT(TransformState) get_transform(TextureStage *stage) const;
|
||||
|
||||
INLINE int get_geom_rendering(int geom_rendering) const;
|
||||
|
||||
public:
|
||||
virtual void issue(GraphicsStateGuardianBase *gsg) const;
|
||||
virtual void output(ostream &out) const;
|
||||
|
Loading…
x
Reference in New Issue
Block a user