Skip to content

Commit

Permalink
Merge branch 'master' into game/eliteforce
Browse files Browse the repository at this point in the history
  • Loading branch information
zturtleman committed May 23, 2018
2 parents 586b284 + 4fa93fb commit 939020f
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 11 deletions.
11 changes: 11 additions & 0 deletions code/renderergl2/glsl/lightall_fp.glsl
Expand Up @@ -309,6 +309,9 @@ void main()

NL = clamp(dot(N, L), 0.0, 1.0);
NE = clamp(dot(N, E), 0.0, 1.0);
H = normalize(L + E);
EH = clamp(dot(E, H), 0.0, 1.0);
NH = clamp(dot(N, H), 0.0, 1.0);

#if defined(USE_SPECULARMAP)
vec4 specular = texture2D(u_SpecularMap, texCoords);
Expand Down Expand Up @@ -351,6 +354,14 @@ void main()

reflectance = CalcDiffuse(diffuse.rgb, NH, EH, roughness);

#if defined(r_deluxeSpecular)
#if defined(USE_LIGHT_VECTOR)
reflectance += CalcSpecular(specular.rgb, NH, EH, roughness) * r_deluxeSpecular;
#else
reflectance += CalcSpecular(specular.rgb, NH, EH, pow(roughness, r_deluxeSpecular));
#endif
#endif

gl_FragColor.rgb = lightColor * reflectance * (attenuation * NL);
gl_FragColor.rgb += ambientColor * diffuse.rgb;

Expand Down
2 changes: 2 additions & 0 deletions code/renderergl2/tr_glsl.c
Expand Up @@ -1067,6 +1067,8 @@ void GLSL_InitGPUShaders(void)

if (r_cubeMapping->integer)
Q_strcat(extradefines, 1024, "#define USE_CUBEMAP\n");
else if (r_deluxeSpecular->value > 0.000001f)
Q_strcat(extradefines, 1024, va("#define r_deluxeSpecular %f\n", r_deluxeSpecular->value));

switch (r_glossType->integer)
{
Expand Down
2 changes: 2 additions & 0 deletions code/renderergl2/tr_init.c
Expand Up @@ -136,6 +136,7 @@ cvar_t *r_deluxeMapping;
cvar_t *r_parallaxMapping;
cvar_t *r_cubeMapping;
cvar_t *r_cubemapSize;
cvar_t *r_deluxeSpecular;
cvar_t *r_pbr;
cvar_t *r_baseNormalX;
cvar_t *r_baseNormalY;
Expand Down Expand Up @@ -1240,6 +1241,7 @@ void R_Register( void )
r_parallaxMapping = ri.Cvar_Get( "r_parallaxMapping", "0", CVAR_ARCHIVE | CVAR_LATCH );
r_cubeMapping = ri.Cvar_Get( "r_cubeMapping", "0", CVAR_ARCHIVE | CVAR_LATCH );
r_cubemapSize = ri.Cvar_Get( "r_cubemapSize", "128", CVAR_ARCHIVE | CVAR_LATCH );
r_deluxeSpecular = ri.Cvar_Get("r_deluxeSpecular", "0.3", CVAR_ARCHIVE | CVAR_LATCH);
r_pbr = ri.Cvar_Get("r_pbr", "0", CVAR_ARCHIVE | CVAR_LATCH);
r_baseNormalX = ri.Cvar_Get( "r_baseNormalX", "1.0", CVAR_ARCHIVE | CVAR_LATCH );
r_baseNormalY = ri.Cvar_Get( "r_baseNormalY", "1.0", CVAR_ARCHIVE | CVAR_LATCH );
Expand Down
1 change: 1 addition & 0 deletions code/renderergl2/tr_local.h
Expand Up @@ -1718,6 +1718,7 @@ extern cvar_t *r_deluxeMapping;
extern cvar_t *r_parallaxMapping;
extern cvar_t *r_cubeMapping;
extern cvar_t *r_cubemapSize;
extern cvar_t *r_deluxeSpecular;
extern cvar_t *r_pbr;
extern cvar_t *r_baseNormalX;
extern cvar_t *r_baseNormalY;
Expand Down
18 changes: 7 additions & 11 deletions code/server/sv_init.c
Expand Up @@ -374,16 +374,12 @@ static void SV_ClearServer(void) {

/*
================
SV_TouchCGame
touch the cgame.vm so that a pure client can load it if it's in a separate pk3
SV_TouchFile
================
*/
static void SV_TouchCGame(void) {
static void SV_TouchFile( const char *filename ) {
fileHandle_t f;
char filename[MAX_QPATH];

Com_sprintf( filename, sizeof(filename), "vm/%s.qvm", "cgame" );
FS_FOpenFileRead( filename, &f, qfalse );
if ( f ) {
FS_FCloseFile( f );
Expand Down Expand Up @@ -574,11 +570,11 @@ void SV_SpawnServer( char *server, qboolean killBots ) {
p = FS_LoadedPakNames();
Cvar_Set( "sv_pakNames", p );

// if a dedicated pure server we need to touch the cgame because it could be in a
// separate pk3 file and the client will need to load the latest cgame.qvm
if ( com_dedicated->integer ) {
SV_TouchCGame();
}
// we need to touch the cgame and ui qvm because they could be in
// separate pk3 files and the client will need to download the pk3
// files with the latest cgame and ui qvm to pass the pure check
SV_TouchFile( "vm/cgame.qvm" );
SV_TouchFile( "vm/ui.qvm" );
}
else {
Cvar_Set( "sv_paks", "" );
Expand Down

0 comments on commit 939020f

Please sign in to comment.