OpenGL2: Add r_glossIsRoughness.
This commit is contained in:
parent
92d4b20129
commit
b52ede0445
6 changed files with 76 additions and 26 deletions
|
@ -954,17 +954,23 @@ static qboolean ParseStage( shaderStage_t *stage, char **text )
|
|||
|
||||
exponent = atof( token );
|
||||
|
||||
// Change shininess to gloss
|
||||
// FIXME: assumes max exponent of 8192 and min of 1, must change here if altered in lightall_fp.glsl
|
||||
exponent = CLAMP(exponent, 1.0, 8192.0);
|
||||
|
||||
stage->specularScale[3] = log(exponent) / log(8192.0);
|
||||
if (r_glossIsRoughness->integer)
|
||||
stage->specularScale[3] = powf(2.0f / (exponent + 2.0), 0.25);
|
||||
else
|
||||
{
|
||||
// Change shininess to gloss
|
||||
// Assumes max exponent of 8190 and min of 0, must change here if altered in lightall_fp.glsl
|
||||
exponent = CLAMP(exponent, 0.0f, 8190.0f);
|
||||
stage->specularScale[3] = (log2f(exponent + 2.0f) - 1.0f) / 12.0f;
|
||||
}
|
||||
}
|
||||
//
|
||||
// gloss <value>
|
||||
//
|
||||
else if (!Q_stricmp(token, "gloss"))
|
||||
{
|
||||
float gloss;
|
||||
|
||||
token = COM_ParseExt(text, qfalse);
|
||||
if ( token[0] == 0 )
|
||||
{
|
||||
|
@ -972,7 +978,38 @@ static qboolean ParseStage( shaderStage_t *stage, char **text )
|
|||
continue;
|
||||
}
|
||||
|
||||
stage->specularScale[3] = atof( token );
|
||||
gloss = atof(token);
|
||||
|
||||
if (r_glossIsRoughness->integer)
|
||||
stage->specularScale[3] = exp2f(-3.0f * gloss);
|
||||
else
|
||||
stage->specularScale[3] = gloss;
|
||||
}
|
||||
//
|
||||
// roughness <value>
|
||||
//
|
||||
else if (!Q_stricmp(token, "roughness"))
|
||||
{
|
||||
float roughness;
|
||||
|
||||
token = COM_ParseExt(text, qfalse);
|
||||
if (token[0] == 0)
|
||||
{
|
||||
ri.Printf(PRINT_WARNING, "WARNING: missing parameter for roughness in shader '%s'\n", shader.name);
|
||||
continue;
|
||||
}
|
||||
|
||||
roughness = atof(token);
|
||||
|
||||
if (r_glossIsRoughness->integer)
|
||||
stage->specularScale[3] = roughness;
|
||||
else
|
||||
{
|
||||
if (roughness >= 0.125)
|
||||
stage->specularScale[3] = log2f(1.0f / roughness) / 3.0f;
|
||||
else
|
||||
stage->specularScale[3] = 1.0f;
|
||||
}
|
||||
}
|
||||
//
|
||||
// parallaxDepth <value>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue