mirror of
https://github.com/UberGames/lilium-voyager.git
synced 2024-11-10 06:31:47 +00:00
OpenGL2: Add r_glossType.
This commit is contained in:
parent
90d6f941f8
commit
5738d09969
4 changed files with 32 additions and 2 deletions
|
@ -332,19 +332,29 @@ void main()
|
|||
// diffuse rgb is base color
|
||||
// specular red is smoothness
|
||||
// specular green is metallicness
|
||||
float roughness = 1.0 - specular.r;
|
||||
float gloss = specular.r;
|
||||
specular.rgb = specular.g * diffuse.rgb + vec3(0.04 - 0.04 * specular.g);
|
||||
diffuse.rgb *= 1.0 - specular.g;
|
||||
#else
|
||||
// diffuse rgb is diffuse
|
||||
// specular rgb is specular reflectance at normal incidence
|
||||
// specular alpha is gloss
|
||||
float roughness = exp2(-3.0 * specular.a);
|
||||
float gloss = specular.a;
|
||||
|
||||
// adjust diffuse by specular reflectance, to maintain energy conservation
|
||||
diffuse.rgb *= vec3(1.0) - specular.rgb;
|
||||
#endif
|
||||
|
||||
#if defined(GLOSS_IS_GLOSS)
|
||||
float roughness = exp2(-3.0 * gloss);
|
||||
#elif defined(GLOSS_IS_SMOOTHNESS)
|
||||
float roughness = 1.0 - gloss;
|
||||
#elif defined(GLOSS_IS_ROUGHNESS)
|
||||
float roughness = gloss;
|
||||
#elif defined(GLOSS_IS_SHININESS)
|
||||
float roughness = pow(2.0 / (8190.0 * gloss + 2.0), 0.25);
|
||||
#endif
|
||||
|
||||
reflectance = CalcDiffuse(diffuse.rgb, NH, EH, roughness);
|
||||
|
||||
gl_FragColor.rgb = lightColor * reflectance * (attenuation * NL);
|
||||
|
|
|
@ -1057,6 +1057,23 @@ void GLSL_InitGPUShaders(void)
|
|||
|
||||
if (r_cubeMapping->integer)
|
||||
Q_strcat(extradefines, 1024, "#define USE_CUBEMAP\n");
|
||||
|
||||
switch (r_glossType->integer)
|
||||
{
|
||||
case 0:
|
||||
default:
|
||||
Q_strcat(extradefines, 1024, "#define GLOSS_IS_GLOSS\n");
|
||||
break;
|
||||
case 1:
|
||||
Q_strcat(extradefines, 1024, "#define GLOSS_IS_SMOOTHNESS\n");
|
||||
break;
|
||||
case 2:
|
||||
Q_strcat(extradefines, 1024, "#define GLOSS_IS_ROUGHNESS\n");
|
||||
break;
|
||||
case 3:
|
||||
Q_strcat(extradefines, 1024, "#define GLOSS_IS_SHININESS\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (i & LIGHTDEF_USE_SHADOWMAP)
|
||||
|
|
|
@ -147,6 +147,7 @@ cvar_t *r_baseNormalY;
|
|||
cvar_t *r_baseParallax;
|
||||
cvar_t *r_baseSpecular;
|
||||
cvar_t *r_baseGloss;
|
||||
cvar_t *r_glossType;
|
||||
cvar_t *r_mergeLightmaps;
|
||||
cvar_t *r_dlightMode;
|
||||
cvar_t *r_pshadowDist;
|
||||
|
@ -1236,6 +1237,7 @@ void R_Register( void )
|
|||
r_baseParallax = ri.Cvar_Get( "r_baseParallax", "0.05", CVAR_ARCHIVE | CVAR_LATCH );
|
||||
r_baseSpecular = ri.Cvar_Get( "r_baseSpecular", "0.04", CVAR_ARCHIVE | CVAR_LATCH );
|
||||
r_baseGloss = ri.Cvar_Get( "r_baseGloss", "0.3", CVAR_ARCHIVE | CVAR_LATCH );
|
||||
r_glossType = ri.Cvar_Get("r_glossType", "1", CVAR_ARCHIVE | CVAR_LATCH);
|
||||
r_dlightMode = ri.Cvar_Get( "r_dlightMode", "0", CVAR_ARCHIVE | CVAR_LATCH );
|
||||
r_pshadowDist = ri.Cvar_Get( "r_pshadowDist", "128", CVAR_ARCHIVE );
|
||||
r_mergeLightmaps = ri.Cvar_Get( "r_mergeLightmaps", "1", CVAR_ARCHIVE | CVAR_LATCH );
|
||||
|
|
|
@ -1794,6 +1794,7 @@ extern cvar_t *r_baseNormalY;
|
|||
extern cvar_t *r_baseParallax;
|
||||
extern cvar_t *r_baseSpecular;
|
||||
extern cvar_t *r_baseGloss;
|
||||
extern cvar_t *r_glossType;
|
||||
extern cvar_t *r_dlightMode;
|
||||
extern cvar_t *r_pshadowDist;
|
||||
extern cvar_t *r_mergeLightmaps;
|
||||
|
|
Loading…
Reference in a new issue