mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-11-11 07:11:39 +00:00
Specular maps (pal 101).
git-svn-id: https://svn.eduke32.com/eduke32@1281 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
fe8775cb21
commit
33d75c0cc7
2 changed files with 54 additions and 2 deletions
|
@ -52,6 +52,7 @@ typedef enum {
|
|||
PR_BIT_DIFFUSE_MAP,
|
||||
PR_BIT_DIFFUSE_DETAIL_MAP,
|
||||
PR_BIT_DIFFUSE_MODULATION,
|
||||
PR_BIT_SPECULAR_MAP,
|
||||
PR_BIT_SPECULAR_MATERIAL,
|
||||
PR_BIT_MIRROR_MAP,
|
||||
PR_BIT_GLOW_MAP,
|
||||
|
@ -77,6 +78,8 @@ typedef struct s_prmaterial {
|
|||
GLfloat detailscale[2];
|
||||
// PR_BIT_DIFFUSE_MODULATION
|
||||
GLfloat diffusemodulation[4];
|
||||
// PR_BIT_SPECULAR_MAP
|
||||
GLuint specmap;
|
||||
// PR_BIT_SPECULAR_MATERIAL
|
||||
GLfloat specmaterial[2];
|
||||
// PR_BIT_MIRROR_MAP
|
||||
|
@ -104,6 +107,8 @@ typedef struct s_prrograminfo {
|
|||
// PR_BIT_DIFFUSE_DETAIL_MAP
|
||||
GLint uniform_detailMap;
|
||||
GLint uniform_detailScale;
|
||||
// PR_BIT_SPECULAR_MAP
|
||||
GLint uniform_specMap;
|
||||
// PR_BIT_SPECULAR_MATERIAL
|
||||
GLint uniform_specMaterial;
|
||||
// PR_BIT_MIRROR_MAP
|
||||
|
|
|
@ -257,6 +257,19 @@ _prprogrambit prprogrambits[PR_BIT_COUNT] = {
|
|||
" result *= vec4(gl_Color);\n"
|
||||
"\n",
|
||||
},
|
||||
{
|
||||
1 << PR_BIT_SPECULAR_MAP,
|
||||
// vert_def
|
||||
"",
|
||||
// vert_prog
|
||||
"",
|
||||
// frag_def
|
||||
"uniform sampler2D specMap;\n"
|
||||
"\n",
|
||||
// frag_prog
|
||||
" specTexel = texture2D(specMap, gl_TexCoord[0].st);\n"
|
||||
"\n",
|
||||
},
|
||||
{
|
||||
1 << PR_BIT_SPECULAR_MATERIAL,
|
||||
// vert_def
|
||||
|
@ -405,8 +418,8 @@ _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), specularMaterial.x) * specularMaterial.y;\n"
|
||||
" result += vec4(lightDiffuse * lightSpecular, 0.0);\n"
|
||||
" lightSpecular = pow( max(dot(R, E), 0.0), specularMaterial.x * specTexel.a) * specularMaterial.y;\n"
|
||||
" result += vec4(lightDiffuse * specTexel.rgb * lightSpecular, 0.0);\n"
|
||||
"\n",
|
||||
},
|
||||
{
|
||||
|
@ -431,6 +444,7 @@ _prprogrambit prprogrambits[PR_BIT_COUNT] = {
|
|||
" int texCoord = 1;\n"
|
||||
" vec4 result = vec4(1.0, 1.0, 1.0, 1.0);\n"
|
||||
" vec4 diffuseTexel = vec4(1.0, 1.0, 1.0, 1.0);\n"
|
||||
" vec4 specTexel = vec4(1.0, 1.0, 1.0, 1.0);\n"
|
||||
" vec4 normalTexel;\n"
|
||||
" int isLightingPass = 0;\n"
|
||||
" int isNormalMapped = 0;\n"
|
||||
|
@ -3059,6 +3073,8 @@ static void polymer_getscratchmaterial(_prmaterial* material)
|
|||
material->diffusemodulation[1] =
|
||||
material->diffusemodulation[2] =
|
||||
material->diffusemodulation[3] = 1.0f;
|
||||
// PR_BIT_SPECULAR_MAP
|
||||
material->specmap = 0;
|
||||
// PR_BIT_SPECULAR_MATERIAL
|
||||
material->specmaterial[0] = material->specmaterial[1] = 1.0f;
|
||||
// PR_BIT_MIRROR_MAP
|
||||
|
@ -3138,6 +3154,16 @@ static void polymer_getbuildmaterial(_prmaterial* material, int16_t tile
|
|||
material->diffusemodulation[2] *= (float)hictinting[pal].b / 255.0;
|
||||
}
|
||||
|
||||
// PR_BIT_SPECULAR_MAP
|
||||
if (hicfindsubst(tilenum, 101, 0))
|
||||
{
|
||||
glowpth = NULL;
|
||||
glowpth = gltexcache(tilenum, 101, 0);
|
||||
|
||||
if (glowpth && glowpth->hicr && (glowpth->hicr->palnum == 101))
|
||||
material->specmap = glowpth->glpic;
|
||||
}
|
||||
|
||||
// PR_BIT_SPECULAR_MATERIAL
|
||||
if (pth->hicr)
|
||||
{
|
||||
|
@ -3191,6 +3217,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_MAP
|
||||
if (material.specmap)
|
||||
programbits |= prprogrambits[PR_BIT_SPECULAR_MAP].bit;
|
||||
|
||||
// PR_BIT_SPECULAR_MATERIAL
|
||||
if ((material.specmaterial[0] != 1.0) || (material.specmaterial[1] != 1.0))
|
||||
programbits |= prprogrambits[PR_BIT_SPECULAR_MATERIAL].bit;
|
||||
|
@ -3299,6 +3329,17 @@ static int32_t polymer_bindmaterial(_prmaterial material, char* lights, int
|
|||
material.diffusemodulation[3]);
|
||||
}
|
||||
|
||||
// PR_BIT_SPECULAR_MAP
|
||||
if (programbits & prprogrambits[PR_BIT_SPECULAR_MAP].bit)
|
||||
{
|
||||
bglActiveTextureARB(texunit + GL_TEXTURE0_ARB);
|
||||
bglBindTexture(GL_TEXTURE_2D, material.specmap);
|
||||
|
||||
bglUniform1iARB(prprograms[programbits].uniform_specMap, texunit);
|
||||
|
||||
texunit++;
|
||||
}
|
||||
|
||||
// PR_BIT_SPECULAR_MATERIAL
|
||||
if (programbits & prprogrambits[PR_BIT_SPECULAR_MATERIAL].bit)
|
||||
{
|
||||
|
@ -3537,6 +3578,12 @@ static void polymer_compileprogram(int32_t programbits)
|
|||
prprograms[programbits].uniform_detailScale = bglGetUniformLocationARB(program, "detailScale");
|
||||
}
|
||||
|
||||
// PR_BIT_SPECULAR_MAP
|
||||
if (programbits & prprogrambits[PR_BIT_SPECULAR_MAP].bit)
|
||||
{
|
||||
prprograms[programbits].uniform_specMap = bglGetUniformLocationARB(program, "specMap");
|
||||
}
|
||||
|
||||
// PR_BIT_SPECULAR_MATERIAL
|
||||
if (programbits & prprogrambits[PR_BIT_SPECULAR_MATERIAL].bit)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue