Adds specpower and specfactor definition tokens for textures.

git-svn-id: https://svn.eduke32.com/eduke32@1278 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
plagman 2009-03-28 12:14:37 +00:00
parent df26ab3c7d
commit 50af4984ad
6 changed files with 64 additions and 13 deletions

View file

@ -624,7 +624,7 @@ void hicinit(void);
// effect bitset: 1 = greyscale, 2 = invert
void hicsetpalettetint(int32_t palnum, char r, char g, char b, char effect);
// flags bitset: 1 = don't compress
int32_t hicsetsubsttex(int32_t picnum, int32_t palnum, char *filen, float alphacut, float xscale, float yscale, char flags);
int32_t hicsetsubsttex(int32_t picnum, int32_t palnum, char *filen, float alphacut, float xscale, float yscale, float specpower, float specfactor, char flags);
int32_t hicsetskybox(int32_t picnum, int32_t palnum, char *faces[6]);
int32_t hicclearsubst(int32_t picnum, int32_t palnum);

View file

@ -10,7 +10,7 @@ typedef struct hicreplc_t {
struct hicreplc_t *next;
char palnum, ignore, flags, filler;
char *filename;
float alphacut, xscale, yscale;
float alphacut, xscale, yscale, specpower, specfactor;
struct hicskybox_t *skybox;
} hicreplctyp;

View file

@ -52,6 +52,7 @@ typedef enum {
PR_BIT_DIFFUSE_MAP,
PR_BIT_DIFFUSE_DETAIL_MAP,
PR_BIT_DIFFUSE_MODULATION,
PR_BIT_SPECULAR_MATERIAL,
PR_BIT_MIRROR_MAP,
PR_BIT_GLOW_MAP,
PR_BIT_SHADOW_MAP,
@ -76,6 +77,8 @@ typedef struct s_prmaterial {
GLfloat detailscale[2];
// PR_BIT_DIFFUSE_MODULATION
GLfloat diffusemodulation[4];
// PR_BIT_SPECULAR_MATERIAL
GLfloat specmaterial[2];
// PR_BIT_MIRROR_MAP
GLuint mirrormap;
// PR_BIT_GLOW_MAP
@ -101,6 +104,8 @@ typedef struct s_prrograminfo {
// PR_BIT_DIFFUSE_DETAIL_MAP
GLint uniform_detailMap;
GLint uniform_detailScale;
// PR_BIT_SPECULAR_MATERIAL
GLint uniform_specMaterial;
// PR_BIT_MIRROR_MAP
GLint uniform_mirrorMap;
// PR_BIT_GLOW_MAP

View file

@ -62,7 +62,7 @@ enum
T_SKYBOX,
T_FRONT,T_RIGHT,T_BACK,T_LEFT,T_TOP,T_BOTTOM,
T_TINT,T_RED,T_GREEN,T_BLUE,
T_TEXTURE,T_ALPHACUT,T_XSCALE,T_YSCALE,T_NOCOMPRESS,T_NODOWNSIZE,
T_TEXTURE,T_ALPHACUT,T_XSCALE,T_YSCALE,T_SPECPOWER,T_SPECFACTOR,T_NOCOMPRESS,T_NODOWNSIZE,
T_UNDEFMODEL,T_UNDEFMODELRANGE,T_UNDEFMODELOF,T_UNDEFTEXTURE,T_UNDEFTEXTURERANGE,
T_ALPHAHACK,T_ALPHAHACKRANGE,
T_SPRITECOL,T_2DCOL,
@ -245,6 +245,8 @@ static tokenlist texturetokens_pal[] =
{ "alphacut", T_ALPHACUT },
{ "detailscale", T_XSCALE }, { "scale", T_XSCALE }, { "xscale", T_XSCALE }, { "intensity", T_XSCALE },
{ "yscale", T_YSCALE },
{ "specpower", T_SPECPOWER },
{ "specfactor", T_SPECFACTOR },
{ "nocompress", T_NOCOMPRESS },
{ "nodownsize", T_NODOWNSIZE },
};
@ -385,7 +387,7 @@ static int32_t defsparser(scriptfile *script)
else Bfree(tfn);
pathsearchmode = i;
hicsetsubsttex(tile,pal,fn,-1.0,1.0,1.0,0);
hicsetsubsttex(tile,pal,fn,-1.0,1.0,1.0,1.0,1.0,0);
}
break;
case T_DEFINESKYBOX:
@ -1530,7 +1532,7 @@ static int32_t defsparser(scriptfile *script)
char *paltokptr = script->ltextptr, *palend;
int32_t pal=-1, i;
char *fn = NULL, *tfn = NULL;
double alphacut = -1.0, xscale = 1.0, yscale = 1.0;
double alphacut = -1.0, xscale = 1.0, yscale = 1.0, specpower = 1.0, specfactor = 1.0;
char flags = 0;
if (scriptfile_getsymbol(script,&pal)) break;
@ -1547,6 +1549,10 @@ static int32_t defsparser(scriptfile *script)
scriptfile_getdouble(script,&xscale); break;
case T_YSCALE:
scriptfile_getdouble(script,&yscale); break;
case T_SPECPOWER:
scriptfile_getdouble(script,&specpower); break;
case T_SPECFACTOR:
scriptfile_getdouble(script,&specfactor); break;
case T_NOCOMPRESS:
flags |= 1; break;
case T_NODOWNSIZE:
@ -1590,7 +1596,7 @@ static int32_t defsparser(scriptfile *script)
xscale = 1.0f / xscale;
yscale = 1.0f / yscale;
hicsetsubsttex(tile,pal,fn,alphacut,xscale,yscale,flags);
hicsetsubsttex(tile,pal,fn,alphacut,xscale,yscale, specpower, specfactor,flags);
fnB=fn; alphacutB=alphacut; xscaleB=xscale; yscaleB=yscale; flagsB=flags;
if (pal<30)palbits|=1<<pal;
}
@ -1668,7 +1674,7 @@ static int32_t defsparser(scriptfile *script)
pal = GLOWPAL;
break;
}
hicsetsubsttex(tile,pal,fn,-1.0,xscale,yscale,flags);
hicsetsubsttex(tile,pal,fn,-1.0,xscale,yscale,1.0,1.0,flags);
}
break;
default:
@ -1682,7 +1688,7 @@ static int32_t defsparser(scriptfile *script)
int32_t i;
for (i=0; i<=25; i++)
if (!(palbits&(1<<i))&&(palmapbits&checkpalmaps(i)))
hicsetsubsttex(tile,i,fnB,alphacutB,xscaleB,yscaleB,flagsB);
hicsetsubsttex(tile,i,fnB,alphacutB,xscaleB,yscaleB,1.0,1.0,flagsB);
}
#endif

View file

@ -123,7 +123,7 @@ void hicsetpalettetint(int32_t palnum, char r, char g, char b, char effect)
// hicsetsubsttex(picnum,pal,filen,alphacut)
// Specifies a replacement graphic file for an ART tile.
//
int32_t hicsetsubsttex(int32_t picnum, int32_t palnum, char *filen, float alphacut, float xscale, float yscale, char flags)
int32_t hicsetsubsttex(int32_t picnum, int32_t palnum, char *filen, float alphacut, float xscale, float yscale, float specpower, float specfactor, char flags)
{
hicreplctyp *hr, *hrn;
@ -160,6 +160,8 @@ int32_t hicsetsubsttex(int32_t picnum, int32_t palnum, char *filen, float alphac
hrn->alphacut = min(alphacut,1.0);
hrn->xscale = xscale;
hrn->yscale = yscale;
hrn->specpower = specpower;
hrn->specfactor = specfactor;
hrn->flags = flags;
if (hr == NULL)
{

View file

@ -132,7 +132,6 @@ GLfloat shadowBias[] =
0.5, 0.5, 0.5, 1.0
};
// MATERIALS
_prprogrambit prprogrambits[PR_BIT_COUNT] = {
{
@ -259,6 +258,19 @@ _prprogrambit prprogrambits[PR_BIT_COUNT] = {
" result *= vec4(gl_Color);\n"
"\n",
},
{
1 << PR_BIT_SPECULAR_MATERIAL,
// vert_def
"",
// vert_prog
"",
// frag_def
"uniform vec2 specMaterial;\n"
"\n",
// frag_prog
" specularMaterial = specMaterial;\n"
"\n",
},
{
1 << PR_BIT_MIRROR_MAP,
// vert_def
@ -344,8 +356,8 @@ _prprogrambit prprogrambits[PR_BIT_COUNT] = {
" lightVector = gl_LightSource[0].ambient.rgb - vertexPos;\n"
"\n"
" if (isNormalMapped == 1) {\n"
" tangentSpaceLightVector = vec3(32376.0, -94.0, -32496.0) - vec3(curVertex);\n"
" tangentSpaceLightVector = TBN * tangentSpaceLightVector;\n"
" //tangentSpaceLightVector = vec3(32376.0, -94.0, -32496.0) - vec3(curVertex);\n"
" //tangentSpaceLightVector = TBN * tangentSpaceLightVector;\n"
" } else\n"
" vertexNormal = normalize(gl_NormalMatrix * curNormal);\n"
"\n",
@ -395,7 +407,7 @@ _prprogrambit prprogrambits[PR_BIT_COUNT] = {
" gl_LightSource[0].diffuse.rgb * lightAttenuation * spotAttenuation;\n"
" result += vec4(lightDiffuse * NdotL, 0.0);\n"
"\n"
" lightSpecular = pow( max(dot(R, E), 0.0), 60.0) * 10.0;\n"
" lightSpecular = pow( max(dot(R, E), 0.0), specularMaterial.x) * specularMaterial.y;\n"
" result += vec4(lightDiffuse * lightSpecular, 0.0);\n"
"\n",
},
@ -427,6 +439,7 @@ _prprogrambit prprogrambits[PR_BIT_COUNT] = {
" vec3 spotVector;\n"
" vec2 spotCosRadius;\n"
" float shadowResult = 1;\n"
" vec2 specularMaterial = vec2(1.0, 1.0);\n"
"\n",
// frag_prog
" gl_FragColor = result;\n"
@ -3037,6 +3050,8 @@ static void polymer_getscratchmaterial(_prmaterial* material)
material->diffusemodulation[1] =
material->diffusemodulation[2] =
material->diffusemodulation[3] = 1.0f;
// PR_BIT_SPECULAR_MATERIAL
material->specmaterial[0] = material->specmaterial[1] = 1.0f;
// PR_BIT_MIRROR_MAP
material->mirrormap = 0;
// PR_BIT_GLOW_MAP
@ -3114,6 +3129,13 @@ static void polymer_getbuildmaterial(_prmaterial* material, int16_t tile
material->diffusemodulation[2] *= (float)hictinting[pal].b / 255.0;
}
// PR_BIT_SPECULAR_MATERIAL
if (pth->hicr)
{
material->specmaterial[0] = pth->hicr->specpower;
material->specmaterial[1] = pth->hicr->specfactor;
}
// PR_BIT_GLOW_MAP
if (r_fullbrights && pth && pth->flags & 16)
material->glowmap = pth->ofb->glpic;
@ -3160,6 +3182,10 @@ static int32_t polymer_bindmaterial(_prmaterial material, char* lights, int
// PR_BIT_DIFFUSE_MODULATION
programbits |= prprogrambits[PR_BIT_DIFFUSE_MODULATION].bit;
// PR_BIT_SPECULAR_MATERIAL
if ((material.specmaterial[0] != 1.0) || (material.specmaterial[1] != 1.0))
programbits |= prprogrambits[PR_BIT_SPECULAR_MATERIAL].bit;
// PR_BIT_MIRROR_MAP
if (!curlight && material.mirrormap)
programbits |= prprogrambits[PR_BIT_MIRROR_MAP].bit;
@ -3264,6 +3290,12 @@ static int32_t polymer_bindmaterial(_prmaterial material, char* lights, int
material.diffusemodulation[3]);
}
// PR_BIT_SPECULAR_MATERIAL
if (programbits & prprogrambits[PR_BIT_SPECULAR_MATERIAL].bit)
{
bglUniform2fvARB(prprograms[programbits].uniform_specMaterial, 1, material.specmaterial);
}
// PR_BIT_MIRROR_MAP
if (programbits & prprogrambits[PR_BIT_MIRROR_MAP].bit)
{
@ -3496,6 +3528,12 @@ static void polymer_compileprogram(int32_t programbits)
prprograms[programbits].uniform_detailScale = bglGetUniformLocationARB(program, "detailScale");
}
// PR_BIT_SPECULAR_MATERIAL
if (programbits & prprogrambits[PR_BIT_SPECULAR_MATERIAL].bit)
{
prprograms[programbits].uniform_specMaterial = bglGetUniformLocationARB(program, "specMaterial");
}
// PR_BIT_MIRROR_MAP
if (programbits & prprogrambits[PR_BIT_MIRROR_MAP].bit)
{