mirror of
https://github.com/ZDoom/Raze.git
synced 2025-02-07 15:31:11 +00:00
Fullbright/glow material bit.
git-svn-id: https://svn.eduke32.com/eduke32@1169 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
b50b229c1d
commit
0c869a2254
2 changed files with 76 additions and 7 deletions
|
@ -48,6 +48,7 @@ typedef enum {
|
||||||
PR_BIT_DIFFUSE_MAP,
|
PR_BIT_DIFFUSE_MAP,
|
||||||
PR_BIT_DIFFUSE_DETAIL_MAP,
|
PR_BIT_DIFFUSE_DETAIL_MAP,
|
||||||
PR_BIT_DIFFUSE_MODULATION,
|
PR_BIT_DIFFUSE_MODULATION,
|
||||||
|
PR_BIT_DIFFUSE_GLOW_MAP,
|
||||||
PR_BIT_DEFAULT, // must be just before last
|
PR_BIT_DEFAULT, // must be just before last
|
||||||
PR_BIT_COUNT // must be last
|
PR_BIT_COUNT // must be last
|
||||||
} prbittype;
|
} prbittype;
|
||||||
|
@ -65,6 +66,8 @@ typedef struct s_prmaterial {
|
||||||
GLfloat detailscale[2];
|
GLfloat detailscale[2];
|
||||||
// PR_BIT_DIFFUSE_MODULATION
|
// PR_BIT_DIFFUSE_MODULATION
|
||||||
GLfloat diffusemodulation[4];
|
GLfloat diffusemodulation[4];
|
||||||
|
// PR_BIT_DIFFUSE_GLOW_MAP
|
||||||
|
GLuint glowmap;
|
||||||
} _prmaterial;
|
} _prmaterial;
|
||||||
|
|
||||||
typedef struct s_prrograminfo {
|
typedef struct s_prrograminfo {
|
||||||
|
@ -78,6 +81,8 @@ typedef struct s_prrograminfo {
|
||||||
// PR_BIT_DIFFUSE_DETAIL_MAP
|
// PR_BIT_DIFFUSE_DETAIL_MAP
|
||||||
GLint uniform_detailMap;
|
GLint uniform_detailMap;
|
||||||
GLint uniform_detailScale;
|
GLint uniform_detailScale;
|
||||||
|
// PR_BIT_DIFFUSE_GLOW_MAP
|
||||||
|
GLint uniform_glowMap;
|
||||||
} _prprograminfo;
|
} _prprograminfo;
|
||||||
|
|
||||||
#define PR_INFO_LOG_BUFFER_SIZE 512
|
#define PR_INFO_LOG_BUFFER_SIZE 512
|
||||||
|
|
|
@ -134,6 +134,7 @@ _prprogrambit prprogrambits[PR_BIT_COUNT] = {
|
||||||
// vert_prog
|
// vert_prog
|
||||||
" vec4 currentFramePosition;\n"
|
" vec4 currentFramePosition;\n"
|
||||||
" vec4 nextFramePosition;\n"
|
" vec4 nextFramePosition;\n"
|
||||||
|
"\n"
|
||||||
" currentFramePosition = gl_Vertex * (1.0 - frameProgress);\n"
|
" currentFramePosition = gl_Vertex * (1.0 - frameProgress);\n"
|
||||||
" nextFramePosition = nextFrameData * frameProgress;\n"
|
" nextFramePosition = nextFrameData * frameProgress;\n"
|
||||||
" currentFramePosition = currentFramePosition + nextFramePosition;\n"
|
" currentFramePosition = currentFramePosition + nextFramePosition;\n"
|
||||||
|
@ -188,6 +189,23 @@ _prprogrambit prprogrambits[PR_BIT_COUNT] = {
|
||||||
" result *= vec4(gl_Color);\n"
|
" result *= vec4(gl_Color);\n"
|
||||||
"\n",
|
"\n",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
1 << PR_BIT_DIFFUSE_GLOW_MAP,
|
||||||
|
// vert_def
|
||||||
|
"",
|
||||||
|
// vert_prog
|
||||||
|
"gl_TexCoord[2] = gl_MultiTexCoord0;\n"
|
||||||
|
"\n",
|
||||||
|
// frag_def
|
||||||
|
"uniform sampler2D glowMap;\n"
|
||||||
|
"\n",
|
||||||
|
// frag_prog
|
||||||
|
" vec4 glowTexel;\n"
|
||||||
|
"\n"
|
||||||
|
" glowTexel = texture2D(glowMap, gl_TexCoord[2].st);\n"
|
||||||
|
" result = vec4((result.rgb * (1.0 - glowTexel.a)) + (glowTexel.rgb * glowTexel.a), result.a);\n"
|
||||||
|
"\n",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
1 << PR_BIT_DEFAULT,
|
1 << PR_BIT_DEFAULT,
|
||||||
// vert_def
|
// vert_def
|
||||||
|
@ -2343,6 +2361,8 @@ static void polymer_drawmdsprite(spritetype *tspr)
|
||||||
if (!mdspritematerial.diffusemap)
|
if (!mdspritematerial.diffusemap)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if (r_detailmapping && !(tspr->cstat&1024))
|
||||||
|
{
|
||||||
mdspritematerial.detailmap =
|
mdspritematerial.detailmap =
|
||||||
mdloadskin((md2model *)m,tile2model[Ptile2tile(tspr->picnum,lpal)].skinnum,DETAILPAL,surfi);
|
mdloadskin((md2model *)m,tile2model[Ptile2tile(tspr->picnum,lpal)].skinnum,DETAILPAL,surfi);
|
||||||
|
|
||||||
|
@ -2351,6 +2371,13 @@ static void polymer_drawmdsprite(spritetype *tspr)
|
||||||
sk->skinnum == tile2model[Ptile2tile(tspr->picnum,lpal)].skinnum &&
|
sk->skinnum == tile2model[Ptile2tile(tspr->picnum,lpal)].skinnum &&
|
||||||
sk->surfnum == surfi)
|
sk->surfnum == surfi)
|
||||||
mdspritematerial.detailscale[0] = mdspritematerial.detailscale[1] = sk->param;
|
mdspritematerial.detailscale[0] = mdspritematerial.detailscale[1] = sk->param;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (r_glowmapping && !(tspr->cstat&1024))
|
||||||
|
{
|
||||||
|
mdspritematerial.glowmap =
|
||||||
|
mdloadskin((md2model *)m,tile2model[Ptile2tile(tspr->picnum,lpal)].skinnum,GLOWPAL,surfi);
|
||||||
|
}
|
||||||
|
|
||||||
if (pr_vbos > 1)
|
if (pr_vbos > 1)
|
||||||
{
|
{
|
||||||
|
@ -2455,12 +2482,15 @@ static void polymer_getscratchmaterial(_prmaterial* material)
|
||||||
material->diffusemodulation[1] =
|
material->diffusemodulation[1] =
|
||||||
material->diffusemodulation[2] =
|
material->diffusemodulation[2] =
|
||||||
material->diffusemodulation[3] = 1.0f;
|
material->diffusemodulation[3] = 1.0f;
|
||||||
|
// PR_BIT_DIFFUSE_GLOW_MAP
|
||||||
|
material->glowmap = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void polymer_getbuildmaterial(_prmaterial* material, short tilenum, char pal, signed char shade)
|
static void polymer_getbuildmaterial(_prmaterial* material, short tilenum, char pal, signed char shade)
|
||||||
{
|
{
|
||||||
pthtyp* pth;
|
pthtyp* pth;
|
||||||
pthtyp* detailpth;
|
pthtyp* detailpth;
|
||||||
|
pthtyp* glowpth;
|
||||||
|
|
||||||
polymer_getscratchmaterial(material);
|
polymer_getscratchmaterial(material);
|
||||||
|
|
||||||
|
@ -2514,6 +2544,19 @@ static void polymer_getbuildmaterial(_prmaterial* material, short tilenu
|
||||||
material->diffusemodulation[1] *= (float)hictinting[pal].g / 255.0;
|
material->diffusemodulation[1] *= (float)hictinting[pal].g / 255.0;
|
||||||
material->diffusemodulation[2] *= (float)hictinting[pal].b / 255.0;
|
material->diffusemodulation[2] *= (float)hictinting[pal].b / 255.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PR_BIT_DIFFUSE_GLOW_MAP
|
||||||
|
if (r_fullbrights && pth && pth->flags & 16)
|
||||||
|
material->glowmap = pth->ofb->glpic;
|
||||||
|
|
||||||
|
if (r_glowmapping && hicfindsubst(tilenum, GLOWPAL, 0))
|
||||||
|
{
|
||||||
|
glowpth = NULL;
|
||||||
|
glowpth = gltexcache(tilenum, GLOWPAL, 0);
|
||||||
|
|
||||||
|
if (glowpth && (glowpth->hicr->palnum == GLOWPAL))
|
||||||
|
material->glowmap = glowpth->glpic;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int polymer_bindmaterial(_prmaterial material)
|
static int polymer_bindmaterial(_prmaterial material)
|
||||||
|
@ -2542,6 +2585,10 @@ static int polymer_bindmaterial(_prmaterial material)
|
||||||
(material.diffusemodulation[2] != 1.0f) || (material.diffusemodulation[3] != 1.0f))
|
(material.diffusemodulation[2] != 1.0f) || (material.diffusemodulation[3] != 1.0f))
|
||||||
programbits |= prprogrambits[PR_BIT_DIFFUSE_MODULATION].bit;
|
programbits |= prprogrambits[PR_BIT_DIFFUSE_MODULATION].bit;
|
||||||
|
|
||||||
|
// PR_BIT_DIFFUSE_GLOW_MAP
|
||||||
|
if (material.glowmap)
|
||||||
|
programbits |= prprogrambits[PR_BIT_DIFFUSE_GLOW_MAP].bit;
|
||||||
|
|
||||||
// --------- program compiling
|
// --------- program compiling
|
||||||
if (!prprograms[programbits].handle)
|
if (!prprograms[programbits].handle)
|
||||||
polymer_compileprogram(programbits);
|
polymer_compileprogram(programbits);
|
||||||
|
@ -2597,6 +2644,17 @@ static int polymer_bindmaterial(_prmaterial material)
|
||||||
material.diffusemodulation[3]);
|
material.diffusemodulation[3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PR_BIT_DIFFUSE_GLOW_MAP
|
||||||
|
if (programbits & prprogrambits[PR_BIT_DIFFUSE_GLOW_MAP].bit)
|
||||||
|
{
|
||||||
|
bglActiveTextureARB(texunit + GL_TEXTURE0_ARB);
|
||||||
|
bglBindTexture(GL_TEXTURE_2D, material.glowmap);
|
||||||
|
|
||||||
|
bglUniform1iARB(prprograms[programbits].uniform_glowMap, texunit);
|
||||||
|
|
||||||
|
texunit++;
|
||||||
|
}
|
||||||
|
|
||||||
bglActiveTextureARB(GL_TEXTURE0_ARB);
|
bglActiveTextureARB(GL_TEXTURE0_ARB);
|
||||||
|
|
||||||
return (programbits);
|
return (programbits);
|
||||||
|
@ -2702,6 +2760,12 @@ static void polymer_compileprogram(int programbits)
|
||||||
prprograms[programbits].uniform_detailMap = bglGetUniformLocationARB(program, "detailMap");
|
prprograms[programbits].uniform_detailMap = bglGetUniformLocationARB(program, "detailMap");
|
||||||
prprograms[programbits].uniform_detailScale = bglGetUniformLocationARB(program, "detailScale");
|
prprograms[programbits].uniform_detailScale = bglGetUniformLocationARB(program, "detailScale");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PR_BIT_DIFFUSE_GLOW_MAP
|
||||||
|
if (programbits & prprogrambits[PR_BIT_DIFFUSE_GLOW_MAP].bit)
|
||||||
|
{
|
||||||
|
prprograms[programbits].uniform_glowMap = bglGetUniformLocationARB(program, "glowMap");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue