OpenGL2: Merge several cvars into r_pbr.
r_glossIsRoughness, r_specularIsMetallic, r_framebufferGamma, r_tonemapGamma, r_materialGamma, r_lightGamma
This commit is contained in:
parent
41791c662f
commit
ad952b9537
11 changed files with 88 additions and 108 deletions
|
@ -934,9 +934,18 @@ static qboolean ParseStage( shaderStage_t *stage, char **text )
|
|||
ri.Printf( PRINT_WARNING, "WARNING: missing parameter for specular reflectance in shader '%s'\n", shader.name );
|
||||
continue;
|
||||
}
|
||||
stage->specularScale[0] =
|
||||
stage->specularScale[1] =
|
||||
stage->specularScale[2] = atof( token );
|
||||
|
||||
if (r_pbr->integer)
|
||||
{
|
||||
// interpret specularReflectance < 0.5 as nonmetal
|
||||
stage->specularScale[1] = (atof(token) < 0.5f) ? 0.0f : 1.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
stage->specularScale[0] =
|
||||
stage->specularScale[1] =
|
||||
stage->specularScale[2] = atof( token );
|
||||
}
|
||||
}
|
||||
//
|
||||
// specularExponent <value>
|
||||
|
@ -954,8 +963,8 @@ static qboolean ParseStage( shaderStage_t *stage, char **text )
|
|||
|
||||
exponent = atof( token );
|
||||
|
||||
if (r_glossIsRoughness->integer)
|
||||
stage->specularScale[3] = powf(2.0f / (exponent + 2.0), 0.25);
|
||||
if (r_pbr->integer)
|
||||
stage->specularScale[0] = 1.0f - powf(2.0f / (exponent + 2.0), 0.25);
|
||||
else
|
||||
{
|
||||
// Change shininess to gloss
|
||||
|
@ -980,8 +989,8 @@ static qboolean ParseStage( shaderStage_t *stage, char **text )
|
|||
|
||||
gloss = atof(token);
|
||||
|
||||
if (r_glossIsRoughness->integer)
|
||||
stage->specularScale[3] = exp2f(-3.0f * gloss);
|
||||
if (r_pbr->integer)
|
||||
stage->specularScale[0] = 1.0f - exp2f(-3.0f * gloss);
|
||||
else
|
||||
stage->specularScale[3] = gloss;
|
||||
}
|
||||
|
@ -1001,8 +1010,8 @@ static qboolean ParseStage( shaderStage_t *stage, char **text )
|
|||
|
||||
roughness = atof(token);
|
||||
|
||||
if (r_glossIsRoughness->integer)
|
||||
stage->specularScale[3] = roughness;
|
||||
if (r_pbr->integer)
|
||||
stage->specularScale[0] = 1.0 - roughness;
|
||||
else
|
||||
{
|
||||
if (roughness >= 0.125)
|
||||
|
@ -1062,6 +1071,7 @@ static qboolean ParseStage( shaderStage_t *stage, char **text )
|
|||
}
|
||||
//
|
||||
// specularScale <rgb> <gloss>
|
||||
// or specularScale <metallic> <smoothness> with r_pbr 1
|
||||
// or specularScale <r> <g> <b>
|
||||
// or specularScale <r> <g> <b> <gloss>
|
||||
//
|
||||
|
@ -1088,10 +1098,19 @@ static qboolean ParseStage( shaderStage_t *stage, char **text )
|
|||
token = COM_ParseExt(text, qfalse);
|
||||
if ( token[0] == 0 )
|
||||
{
|
||||
// two values, rgb then gloss
|
||||
stage->specularScale[3] = stage->specularScale[1];
|
||||
stage->specularScale[1] =
|
||||
stage->specularScale[2] = stage->specularScale[0];
|
||||
if (r_pbr->integer)
|
||||
{
|
||||
// two values, metallic then smoothness
|
||||
float smoothness = stage->specularScale[1];
|
||||
stage->specularScale[1] = (stage->specularScale[0] < 0.5f) ? 0.0f : 1.0f;
|
||||
stage->specularScale[0] = smoothness;
|
||||
}
|
||||
{
|
||||
// two values, rgb then gloss
|
||||
stage->specularScale[3] = stage->specularScale[1];
|
||||
stage->specularScale[1] =
|
||||
stage->specularScale[2] = stage->specularScale[0];
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -2857,10 +2876,17 @@ static void InitShader( const char *name, int lightmapIndex ) {
|
|||
|
||||
// default normal/specular
|
||||
VectorSet4(stages[i].normalScale, 0.0f, 0.0f, 0.0f, 0.0f);
|
||||
stages[i].specularScale[0] =
|
||||
stages[i].specularScale[1] =
|
||||
stages[i].specularScale[2] = r_baseSpecular->value;
|
||||
stages[i].specularScale[3] = r_baseGloss->value;
|
||||
if (r_pbr->integer)
|
||||
{
|
||||
stages[i].specularScale[0] = r_baseGloss->value;
|
||||
}
|
||||
else
|
||||
{
|
||||
stages[i].specularScale[0] =
|
||||
stages[i].specularScale[1] =
|
||||
stages[i].specularScale[2] = r_baseSpecular->value;
|
||||
stages[i].specularScale[3] = r_baseGloss->value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue