Skip to content

Commit

Permalink
Continued work on revising the interface to RL_AddPoly. Everything is…
Browse files Browse the repository at this point in the history
… once again working other than the case of surfaces drawn with a modulation texture (first light on surface). For now, disable multi-textured lights "rend-light-multitex 0" until the problem is resolved.

* Revised world texture coordinate generation. Now uses the OpenGL texture matrix for the translation and scaling of all texture units on world surface polyons. This means that potentially, we can get rid of the global texcoord buffer (and let OpenGL calculate them for us).
* Fixed problems introduced in the last batch of changes with fakeradio shadow segs and shiny surfaces.
  • Loading branch information
danij committed Dec 3, 2008
1 parent e10e101 commit 7d78858
Show file tree
Hide file tree
Showing 8 changed files with 1,053 additions and 1,034 deletions.
15 changes: 12 additions & 3 deletions doomsday/engine/portable/include/r_data.h
Expand Up @@ -145,15 +145,15 @@ typedef struct {
short offY; // accounted for the patch's internal origin
} texpatch_t;

#define TXDF_NODRAW 0x1 // Not to be drawn.
#define TXDF_IWAD 0x2 // Defines an IWAD texture. Note the definition may NOT be from the IWAD.
#define TXDF_NODRAW 0x0001 // Not to be drawn.
#define TXDF_IWAD 0x0002 // Defines an IWAD texture. Note the definition may NOT be from the IWAD.

// Describes a rectangular texture, which is composed of one
// or more texpatch_t structures that arrange graphic patches.
typedef struct {
char name[9];
short width, height;
byte flags;
short flags;
short patchCount;
texpatch_t patches[1]; // [patchcount] drawn back to front into the cached texture.
} texturedef_t;
Expand Down Expand Up @@ -300,6 +300,15 @@ void R_FreeRendColors(rcolor_t* rcolors);
void R_FreeRendTexCoords(rtexcoord_t* rtexcoords);
void R_InfoRendVerticesPool(void);

void R_DivVerts(rvertex_t* dst, const rvertex_t* src,
const walldiv_t* divs);
void R_DivVertColors(rcolor_t* dst, const rcolor_t* src,
const walldiv_t* divs, float bL, float tL,
float bR, float tR);
void R_DivTexCoords(rtexcoord_t* dst, const rtexcoord_t* src,
const walldiv_t* divs, float bL, float tL,
float bR, float tR);

void R_InitData(void);
void R_UpdateData(void);
void R_ShutdownData(void);
Expand Down
49 changes: 17 additions & 32 deletions doomsday/engine/portable/include/rend_list.h
Expand Up @@ -51,33 +51,24 @@ typedef enum {
RPT_SHINY // A shiny polygon.
} rendpolytype_t;

// Helper macro for accessing texture map units.
#define TMU(x, n) (&((x)->texmapunits[(n)]))

typedef enum {
TMU_PRIMARY = 0,
TMU_PRIMARY_DETAIL,
TMU_INTER,
TMU_INTER_DETAIL,
TU_PRIMARY = 0,
TU_PRIMARY_DETAIL,
TU_INTER,
TU_INTER_DETAIL,
TU_SHINY,
TU_SHINY_MASK,
NUM_TEXMAP_UNITS
} texmapunit_t;

typedef struct rtexmapuint_s {
DGLuint tex;
int magMode;
float blend;
float scale[2], offset[2]; // For use with the texture matrix.
blendmode_t blendMode; // Currently used only with shiny pass.
} rtexmapunit_t;

// rladdpoly_params_t is only for convenience; the data written in the rendering
// list data buffer is taken from this struct.
typedef struct rladdpoly_params_s {
rendpolytype_t type;
rtexmapunit_t texmapunits[NUM_TEXMAP_UNITS];
float interPos; // Blending strength (0..1).
DGLuint modTex;
float modColor[3];
} rladdpoly_params_t;

extern int renderTextures;
extern int renderWireframe;
extern int useMultiTexLights;
Expand All @@ -95,23 +86,17 @@ boolean RL_IsMTexDetails(void);
void RL_ClearLists(void);
void RL_DeleteLists(void);

void RL_AddPoly(primtype_t type, const rvertex_t* vertices,
void RL_AddPoly(primtype_t type, rendpolytype_t polyType,
const rvertex_t* vertices,
const rtexcoord_t* rtexcoords,
const rtexcoord_t* rtexcoords1,
const rtexcoord_t* rtexcoords2,
const rtexcoord_t* rtexcoords5,
const rcolor_t* colors, uint numVertices,
blendmode_t blendMode, boolean isLit,
const rladdpoly_params_t* params);
void RL_AddMaskedPoly(const rvertex_t* vertices,
const rcolor_t* colors, float wallLength,
float texWidth, float texHeight,
const float texOffset[2],
blendmode_t blendMode,
uint lightListIdx, boolean glow,
boolean masked,
const rladdpoly_params_t* params);
const rtexcoord_t* srtexcoords,
const rtexcoord_t* srtexcoords1,
const rcolor_t* colors, const rcolor_t* scolors,
uint numVertices,
uint numLights, DGLuint modTex, float modColor[3],
const rtexmapunit_t tu[NUM_TEXMAP_UNITS]);
void RL_RenderAllLists(void);

void RL_FloatRGB(byte* rgb, float* dest);

#endif
2 changes: 0 additions & 2 deletions doomsday/engine/portable/include/rend_main.h
Expand Up @@ -41,7 +41,6 @@ extern boolean usingFog;
extern float fogColor[4];
extern int rAmbient;
extern float rendLightDistanceAttentuation;

extern float lightModRange[255];

void Rend_Register(void);
Expand All @@ -54,7 +53,6 @@ void Rend_ModelViewMatrix(boolean use_angles);
#define Rend_PointDist2D(c) (fabs((vz-c[VY])*viewsidex - (vx-c[VX])*viewsidey))

float Rend_PointDist3D(const float c[3]);
//float Rend_SignedPointDist2D(const float c[2]);
float Rend_SectorLight(sector_t* sec);
void Rend_ApplyTorchLight(float* color, float distance);
int Rend_MidMaterialPos(float* bottomleft, float* bottomright,
Expand Down
135 changes: 135 additions & 0 deletions doomsday/engine/portable/src/r_data.c
Expand Up @@ -465,6 +465,141 @@ void R_FreeRendTexCoords(rtexcoord_t* rtexcoords)
#endif
}

void R_DivVerts(rvertex_t* dst, const rvertex_t* src, const walldiv_t* divs)
{
#define COPYVERT(d, s) (d)->pos[VX] = (s)->pos[VX]; \
(d)->pos[VY] = (s)->pos[VY]; \
(d)->pos[VZ] = (s)->pos[VZ];

uint i;
uint numL = 3 + divs[0].num;
uint numR = 3 + divs[1].num;

// Right fan:
COPYVERT(&dst[numL + 0], &src[0])
COPYVERT(&dst[numL + 1], &src[3]);
COPYVERT(&dst[numL + numR - 1], &src[2]);

for(i = 0; i < divs[1].num; ++i)
{
dst[numL + 2 + i].pos[VX] = src[2].pos[VX];
dst[numL + 2 + i].pos[VY] = src[2].pos[VY];
dst[numL + 2 + i].pos[VZ] = divs[1].pos[i];
}

// Left fan:
COPYVERT(&dst[0], &src[3]);
COPYVERT(&dst[1], &src[0]);
COPYVERT(&dst[numL - 1], &src[1]);

for(i = 0; i < divs[0].num; ++i)
{
dst[2 + i].pos[VX] = src[0].pos[VX];
dst[2 + i].pos[VY] = src[0].pos[VY];
dst[2 + i].pos[VZ] = divs[0].pos[i];
}

#undef COPYVERT
}

void R_DivTexCoords(rtexcoord_t* dst, const rtexcoord_t* src,
const walldiv_t* divs, float bL, float tL, float bR,
float tR)
{
#define COPYTEXCOORD(d, s) (d)->st[0] = (s)->st[0]; \
(d)->st[1] = (s)->st[1];

uint i;
uint numL = 3 + divs[0].num;
uint numR = 3 + divs[1].num;
float height;

// Right fan:
COPYTEXCOORD(&dst[numL + 0], &src[0]);
COPYTEXCOORD(&dst[numL + 1], &src[3]);
COPYTEXCOORD(&dst[numL + numR-1], &src[2]);

height = tR - bR;
for(i = 0; i < divs[1].num; ++i)
{
float inter = (divs[1].pos[i] - bR) / height;

dst[numL + 2 + i].st[0] = src[2].st[0];
dst[numL + 2 + i].st[1] = src[2].st[1] +
(src[3].st[1] - src[2].st[1]) * inter;
}

// Left fan:
COPYTEXCOORD(&dst[0], &src[3]);
COPYTEXCOORD(&dst[1], &src[0]);
COPYTEXCOORD(&dst[numL - 1], &src[1]);

height = tL - bL;
for(i = 0; i < divs[0].num; ++i)
{
float inter = (divs[0].pos[i] - bL) / height;

dst[2 + i].st[0] = src[0].st[0];
dst[2 + i].st[1] = src[0].st[1] +
(src[1].st[1] - src[0].st[1]) * inter;
}

#undef COPYTEXCOORD
}

void R_DivVertColors(rcolor_t* dst, const rcolor_t* src,
const walldiv_t* divs, float bL, float tL, float bR,
float tR)
{
#define COPYVCOLOR(d, s) (d)->rgba[CR] = (s)->rgba[CR]; \
(d)->rgba[CG] = (s)->rgba[CG]; \
(d)->rgba[CB] = (s)->rgba[CB]; \
(d)->rgba[CA] = (s)->rgba[CA];

uint i;
uint numL = 3 + divs[0].num;
uint numR = 3 + divs[1].num;
float height;

// Right fan:
COPYVCOLOR(&dst[numL + 0], &src[0]);
COPYVCOLOR(&dst[numL + 1], &src[3]);
COPYVCOLOR(&dst[numL + numR-1], &src[2]);

height = tR - bR;
for(i = 0; i < divs[1].num; ++i)
{
uint c;
float inter = (divs[1].pos[i] - bR) / height;

for(c = 0; c < 4; ++c)
{
dst[numL + 2 + i].rgba[c] = src[2].rgba[c] +
(src[3].rgba[c] - src[2].rgba[c]) * inter;
}
}

// Left fan:
COPYVCOLOR(&dst[0], &src[3]);
COPYVCOLOR(&dst[1], &src[0]);
COPYVCOLOR(&dst[numL - 1], &src[1]);

height = tL - bL;
for(i = 0; i < divs[0].num; ++i)
{
uint c;
float inter = (divs[0].pos[i] - bL) / height;

for(c = 0; c < 4; ++c)
{
dst[2 + i ].rgba[c] = src[0].rgba[c] +
(src[1].rgba[c] - src[0].rgba[c]) * inter;
}
}

#undef COPYVCOLOR
}

void R_ShutdownData(void)
{
R_ShutdownMaterials();
Expand Down

0 comments on commit 7d78858

Please sign in to comment.