mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-02 09:52:27 -04:00
texmat
This commit is contained in:
parent
19e0b0824c
commit
5c7be58565
@ -981,6 +981,8 @@ begin_draw_primitives(const GeomPipelineReader *geom_reader,
|
|||||||
// We only support single-texturing, so only bother with the first
|
// We only support single-texturing, so only bother with the first
|
||||||
// texture stage.
|
// texture stage.
|
||||||
bool needs_texcoord = false;
|
bool needs_texcoord = false;
|
||||||
|
bool needs_texmat = false;
|
||||||
|
LMatrix4f texmat;
|
||||||
const InternalName *texcoord_name = InternalName::get_texcoord();
|
const InternalName *texcoord_name = InternalName::get_texcoord();
|
||||||
int max_stage_index = _effective_texture->get_num_on_ff_stages();
|
int max_stage_index = _effective_texture->get_num_on_ff_stages();
|
||||||
if (max_stage_index > 0) {
|
if (max_stage_index > 0) {
|
||||||
@ -988,6 +990,11 @@ begin_draw_primitives(const GeomPipelineReader *geom_reader,
|
|||||||
rtexcoord = GeomVertexReader(data_reader, stage->get_texcoord_name());
|
rtexcoord = GeomVertexReader(data_reader, stage->get_texcoord_name());
|
||||||
rtexcoord.set_row(_min_vertex);
|
rtexcoord.set_row(_min_vertex);
|
||||||
needs_texcoord = rtexcoord.has_column();
|
needs_texcoord = rtexcoord.has_column();
|
||||||
|
|
||||||
|
if (needs_texcoord && _target._tex_matrix->has_stage(stage)) {
|
||||||
|
needs_texmat = true;
|
||||||
|
texmat = _target._tex_matrix->get_mat(stage);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool needs_color = false;
|
bool needs_color = false;
|
||||||
@ -1047,7 +1054,14 @@ begin_draw_primitives(const GeomPipelineReader *geom_reader,
|
|||||||
v->coord.Z = d[2];
|
v->coord.Z = d[2];
|
||||||
v->coord.W = d[3];
|
v->coord.W = d[3];
|
||||||
|
|
||||||
if (needs_texcoord) {
|
if (needs_texmat) {
|
||||||
|
// Transform texcoords as a four-component vector for most generality.
|
||||||
|
LVecBase4f d = rtexcoord.get_data4f() * texmat;
|
||||||
|
v->tex_coord.X = d[0];
|
||||||
|
v->tex_coord.Y = d[1];
|
||||||
|
|
||||||
|
} else if (needs_texcoord) {
|
||||||
|
// No need to transform, so just extract as two-component.
|
||||||
const LVecBase2f &d = rtexcoord.get_data2f();
|
const LVecBase2f &d = rtexcoord.get_data2f();
|
||||||
v->tex_coord.X = d[0];
|
v->tex_coord.X = d[0];
|
||||||
v->tex_coord.Y = d[1];
|
v->tex_coord.Y = d[1];
|
||||||
|
@ -78,19 +78,19 @@ void FNAME(ZB_fillTriangleMapping) (ZBuffer *zb,
|
|||||||
texture=zb->current_texture; \
|
texture=zb->current_texture; \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define PUT_PIXEL(_a) \
|
#define PUT_PIXEL(_a) \
|
||||||
{ \
|
{ \
|
||||||
zz=z >> ZB_POINT_Z_FRAC_BITS; \
|
zz=z >> ZB_POINT_Z_FRAC_BITS; \
|
||||||
if (ZCMP(pz[_a], zz)) { \
|
if (ZCMP(pz[_a], zz)) { \
|
||||||
tmp=texture[((t & 0x3FC00000) | s) >> 14]; \
|
tmp=texture[((t & 0x3FC00000) | (s & 0x3fc000)) >> 14]; \
|
||||||
if (ACMP(zb, PIXEL_A(tmp))) { \
|
if (ACMP(zb, PIXEL_A(tmp))) { \
|
||||||
STORE_PIX(pp[_a], tmp, PIXEL_R(tmp), PIXEL_G(tmp), PIXEL_B(tmp), PIXEL_A(tmp)); \
|
STORE_PIX(pp[_a], tmp, PIXEL_R(tmp), PIXEL_G(tmp), PIXEL_B(tmp), PIXEL_A(tmp)); \
|
||||||
STORE_Z(pz[_a], zz); \
|
STORE_Z(pz[_a], zz); \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
z+=dzdx; \
|
z+=dzdx; \
|
||||||
s+=dsdx; \
|
s+=dsdx; \
|
||||||
t+=dtdx; \
|
t+=dtdx; \
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "ztriangle.h"
|
#include "ztriangle.h"
|
||||||
@ -118,7 +118,7 @@ void FNAME(ZB_fillTriangleMappingFlat) (ZBuffer *zb,
|
|||||||
{ \
|
{ \
|
||||||
zz=z >> ZB_POINT_Z_FRAC_BITS; \
|
zz=z >> ZB_POINT_Z_FRAC_BITS; \
|
||||||
if (ZCMP(pz[_a], zz)) { \
|
if (ZCMP(pz[_a], zz)) { \
|
||||||
tmp=texture[((t & 0x3FC00000) | s) >> 14]; \
|
tmp=texture[((t & 0x3FC00000) | (s & 0x3fc000)) >> 14]; \
|
||||||
int a = oa * PIXEL_A(tmp) >> 16; \
|
int a = oa * PIXEL_A(tmp) >> 16; \
|
||||||
if (ACMP(zb, a)) { \
|
if (ACMP(zb, a)) { \
|
||||||
STORE_PIX(pp[_a], \
|
STORE_PIX(pp[_a], \
|
||||||
@ -159,7 +159,7 @@ void FNAME(ZB_fillTriangleMappingSmooth) (ZBuffer *zb,
|
|||||||
{ \
|
{ \
|
||||||
zz=z >> ZB_POINT_Z_FRAC_BITS; \
|
zz=z >> ZB_POINT_Z_FRAC_BITS; \
|
||||||
if (ZCMP(pz[_a], zz)) { \
|
if (ZCMP(pz[_a], zz)) { \
|
||||||
tmp=texture[((t & 0x3FC00000) | s) >> 14]; \
|
tmp=texture[((t & 0x3FC00000) | (s & 0x3fc000)) >> 14]; \
|
||||||
int a = oa1 * PIXEL_A(tmp) >> 16; \
|
int a = oa1 * PIXEL_A(tmp) >> 16; \
|
||||||
if (ACMP(zb, a)) { \
|
if (ACMP(zb, a)) { \
|
||||||
STORE_PIX(pp[_a], \
|
STORE_PIX(pp[_a], \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user