Merge branch 'master' (early part) into sdl2
This commit is contained in:
commit
73aa7ef2c7
28 changed files with 96 additions and 79 deletions
|
@ -44,6 +44,12 @@ uniform vec4 u_NormalScale;
|
|||
uniform vec4 u_SpecularScale;
|
||||
#endif
|
||||
|
||||
#if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT)
|
||||
#if defined(USE_CUBEMAP)
|
||||
uniform vec4 u_CubeMapInfo;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
varying vec4 var_TexCoords;
|
||||
|
||||
varying vec4 var_Color;
|
||||
|
@ -323,19 +329,20 @@ mat3 cotangent_frame( vec3 N, vec3 p, vec2 uv )
|
|||
|
||||
void main()
|
||||
{
|
||||
vec3 viewDir;
|
||||
vec3 L, N, E, H;
|
||||
float NL, NH, NE, EH;
|
||||
|
||||
#if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT)
|
||||
#if defined(USE_VERT_TANGENT_SPACE)
|
||||
mat3 tangentToWorld = mat3(var_Tangent.xyz, var_Bitangent.xyz, var_Normal.xyz);
|
||||
E = vec3(var_Normal.w, var_Tangent.w, var_Bitangent.w);
|
||||
viewDir = vec3(var_Normal.w, var_Tangent.w, var_Bitangent.w);
|
||||
#else
|
||||
mat3 tangentToWorld = cotangent_frame(var_Normal, -var_ViewDir, var_TexCoords.xy);
|
||||
E = var_ViewDir;
|
||||
viewDir = var_ViewDir;
|
||||
#endif
|
||||
|
||||
E = normalize(E);
|
||||
E = normalize(viewDir);
|
||||
|
||||
L = var_LightDir.xyz;
|
||||
#if defined(USE_DELUXEMAP)
|
||||
|
@ -497,6 +504,10 @@ void main()
|
|||
|
||||
vec3 R = reflect(E, N);
|
||||
|
||||
// parallax corrected cubemap (cheaper trick)
|
||||
// from http://seblagarde.wordpress.com/2012/09/29/image-based-lighting-approaches-and-parallax-corrected-cubemap/
|
||||
R += u_CubeMapInfo.xyz + u_CubeMapInfo.w * viewDir;
|
||||
|
||||
vec3 cubeLightColor = textureCubeLod(u_CubeMap, R, 7.0 - gloss * 7.0).rgb * u_EnableTextures.w;
|
||||
|
||||
#if defined(USE_LIGHTMAP)
|
||||
|
|
|
@ -600,8 +600,6 @@ static void R_LoadVisibility( lump_t *l ) {
|
|||
byte *buf;
|
||||
|
||||
len = ( s_worldData.numClusters + 63 ) & ~63;
|
||||
s_worldData.novis = ri.Hunk_Alloc( len, h_low );
|
||||
Com_Memset( s_worldData.novis, 0xff, len );
|
||||
|
||||
len = l->filelen;
|
||||
if ( !len ) {
|
||||
|
@ -2722,7 +2720,7 @@ qboolean R_GetEntityToken( char *buffer, int size ) {
|
|||
|
||||
s = COM_Parse( &s_worldData.entityParsePoint );
|
||||
Q_strncpyz( buffer, s, size );
|
||||
if ( !s_worldData.entityParsePoint || !s[0] ) {
|
||||
if ( !s_worldData.entityParsePoint && !s[0] ) {
|
||||
s_worldData.entityParsePoint = s_worldData.entityString;
|
||||
return qfalse;
|
||||
} else {
|
||||
|
@ -2749,7 +2747,8 @@ qboolean R_ParseSpawnVars( char *spawnVarChars, int maxSpawnVarChars, int *numSp
|
|||
return qfalse;
|
||||
}
|
||||
if ( com_token[0] != '{' ) {
|
||||
ri.Printf( PRINT_ALL, "R_ParseSpawnVars: found %s when expecting {",com_token );
|
||||
ri.Printf( PRINT_ALL, "R_ParseSpawnVars: found %s when expecting {\n",com_token );
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
// go through all the key / value pairs
|
||||
|
@ -2758,7 +2757,8 @@ qboolean R_ParseSpawnVars( char *spawnVarChars, int maxSpawnVarChars, int *numSp
|
|||
|
||||
// parse key
|
||||
if ( !R_GetEntityToken( keyname, sizeof( keyname ) ) ) {
|
||||
ri.Printf( PRINT_ALL, "R_ParseSpawnVars: EOF without closing brace" );
|
||||
ri.Printf( PRINT_ALL, "R_ParseSpawnVars: EOF without closing brace\n" );
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
if ( keyname[0] == '}' ) {
|
||||
|
@ -2767,18 +2767,18 @@ qboolean R_ParseSpawnVars( char *spawnVarChars, int maxSpawnVarChars, int *numSp
|
|||
|
||||
// parse value
|
||||
if ( !R_GetEntityToken( com_token, sizeof( com_token ) ) ) {
|
||||
ri.Printf( PRINT_ALL, "R_ParseSpawnVars: EOF without closing brace" );
|
||||
break;
|
||||
ri.Printf( PRINT_ALL, "R_ParseSpawnVars: EOF without closing brace\n" );
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
if ( com_token[0] == '}' ) {
|
||||
ri.Printf( PRINT_ALL, "R_ParseSpawnVars: closing brace without data" );
|
||||
break;
|
||||
ri.Printf( PRINT_ALL, "R_ParseSpawnVars: closing brace without data\n" );
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
if ( *numSpawnVars == MAX_SPAWN_VARS ) {
|
||||
ri.Printf( PRINT_ALL, "R_ParseSpawnVars: MAX_SPAWN_VARS" );
|
||||
break;
|
||||
ri.Printf( PRINT_ALL, "R_ParseSpawnVars: MAX_SPAWN_VARS\n" );
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
keyLength = strlen(keyname) + 1;
|
||||
|
@ -2786,8 +2786,8 @@ qboolean R_ParseSpawnVars( char *spawnVarChars, int maxSpawnVarChars, int *numSp
|
|||
|
||||
if (numSpawnVarChars + keyLength + tokenLength > maxSpawnVarChars)
|
||||
{
|
||||
ri.Printf( PRINT_ALL, "R_ParseSpawnVars: MAX_SPAWN_VAR_CHARS" );
|
||||
break;
|
||||
ri.Printf( PRINT_ALL, "R_ParseSpawnVars: MAX_SPAWN_VAR_CHARS\n" );
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
strcpy(spawnVarChars + numSpawnVarChars, keyname);
|
||||
|
|
|
@ -142,7 +142,9 @@ static uniformInfo_t uniformsInfo[] =
|
|||
{ "u_PrimaryLightOrigin", GLSL_VEC4 },
|
||||
{ "u_PrimaryLightColor", GLSL_VEC3 },
|
||||
{ "u_PrimaryLightAmbient", GLSL_VEC3 },
|
||||
{ "u_PrimaryLightRadius", GLSL_FLOAT }
|
||||
{ "u_PrimaryLightRadius", GLSL_FLOAT },
|
||||
|
||||
{ "u_CubeMapInfo", GLSL_VEC4 },
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -698,6 +698,8 @@ typedef enum
|
|||
UNIFORM_PRIMARYLIGHTAMBIENT,
|
||||
UNIFORM_PRIMARYLIGHTRADIUS,
|
||||
|
||||
UNIFORM_CUBEMAPINFO,
|
||||
|
||||
UNIFORM_COUNT
|
||||
} uniform_t;
|
||||
|
||||
|
@ -1179,8 +1181,6 @@ typedef struct {
|
|||
int clusterBytes;
|
||||
const byte *vis; // may be passed in by CM_LoadMap to save space
|
||||
|
||||
byte *novis; // clusterBytes of 0xff
|
||||
|
||||
char *entityString;
|
||||
char *entityParsePoint;
|
||||
} world_t;
|
||||
|
|
|
@ -2863,7 +2863,8 @@ void R_RenderCubemapSide( int cubemapIndex, int cubemapSide, qboolean subscene )
|
|||
vec3_t ambient, directed, lightDir;
|
||||
R_LightForPoint(tr.refdef.vieworg, ambient, directed, lightDir);
|
||||
tr.refdef.colorScale = 766.0f / (directed[0] + directed[1] + directed[2] + 1.0f);
|
||||
if (directed[0] + directed[1] + directed[2] == 0)
|
||||
// only print message for first side
|
||||
if (directed[0] + directed[1] + directed[2] == 0 && cubemapSide == 0)
|
||||
{
|
||||
ri.Printf(PRINT_ALL, "cubemap %d (%f, %f, %f) is outside the lightgrid!\n", cubemapIndex, tr.refdef.vieworg[0], tr.refdef.vieworg[1], tr.refdef.vieworg[2]);
|
||||
}
|
||||
|
@ -2910,4 +2911,4 @@ void R_RenderCubemapSide( int cubemapIndex, int cubemapSide, qboolean subscene )
|
|||
{
|
||||
RE_EndScene();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1378,8 +1378,21 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input )
|
|||
// testing cube map
|
||||
//
|
||||
if (!(tr.viewParms.flags & VPF_NOCUBEMAPS) && input->cubemapIndex && r_cubeMapping->integer)
|
||||
{
|
||||
vec4_t vec;
|
||||
|
||||
GL_BindToTMU( tr.cubemaps[input->cubemapIndex - 1], TB_CUBEMAP);
|
||||
|
||||
vec[0] = tr.cubemapOrigins[input->cubemapIndex - 1][0] - backEnd.viewParms.or.origin[0];
|
||||
vec[1] = tr.cubemapOrigins[input->cubemapIndex - 1][1] - backEnd.viewParms.or.origin[1];
|
||||
vec[2] = tr.cubemapOrigins[input->cubemapIndex - 1][2] - backEnd.viewParms.or.origin[2];
|
||||
vec[3] = 1.0f;
|
||||
|
||||
VectorScale4(vec, 1.0f / 1000.0f, vec);
|
||||
|
||||
GLSL_SetUniformVec4(sp, UNIFORM_CUBEMAPINFO, vec);
|
||||
}
|
||||
|
||||
//
|
||||
// draw
|
||||
//
|
||||
|
|
|
@ -753,7 +753,7 @@ static qboolean ParseStage( shaderStage_t *stage, char **text )
|
|||
token = COM_ParseExt( text, qfalse );
|
||||
if ( !token[0] )
|
||||
{
|
||||
ri.Printf( PRINT_WARNING, "WARNING: missing parameter for 'animMmap' keyword in shader '%s'\n", shader.name );
|
||||
ri.Printf( PRINT_WARNING, "WARNING: missing parameter for 'animMap' keyword in shader '%s'\n", shader.name );
|
||||
return qfalse;
|
||||
}
|
||||
stage->bundle[0].imageAnimationSpeed = atof( token );
|
||||
|
@ -794,7 +794,7 @@ static qboolean ParseStage( shaderStage_t *stage, char **text )
|
|||
token = COM_ParseExt( text, qfalse );
|
||||
if ( !token[0] )
|
||||
{
|
||||
ri.Printf( PRINT_WARNING, "WARNING: missing parameter for 'videoMmap' keyword in shader '%s'\n", shader.name );
|
||||
ri.Printf( PRINT_WARNING, "WARNING: missing parameter for 'videoMap' keyword in shader '%s'\n", shader.name );
|
||||
return qfalse;
|
||||
}
|
||||
stage->bundle[0].videoMapHandle = ri.CIN_PlayCinematic( token, 0, 0, 256, 256, (CIN_loop | CIN_silent | CIN_shader));
|
||||
|
|
|
@ -644,7 +644,7 @@ R_ClusterPVS
|
|||
*/
|
||||
static const byte *R_ClusterPVS (int cluster) {
|
||||
if (!tr.world->vis || cluster < 0 || cluster >= tr.world->numClusters ) {
|
||||
return tr.world->novis;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return tr.world->vis + cluster * tr.world->clusterBytes;
|
||||
|
@ -698,29 +698,21 @@ static void R_MarkLeaves (void) {
|
|||
|
||||
for(i = 0; i < MAX_VISCOUNTS; i++)
|
||||
{
|
||||
if(tr.visClusters[i] == cluster)
|
||||
// if the areamask or r_showcluster was modified, invalidate all visclusters
|
||||
// this caused doors to open into undrawn areas
|
||||
if (tr.refdef.areamaskModified || r_showcluster->modified)
|
||||
{
|
||||
//tr.visIndex = i;
|
||||
break;
|
||||
tr.visClusters[i] = -2;
|
||||
}
|
||||
}
|
||||
|
||||
// if r_showcluster was just turned on, remark everything
|
||||
if(i != MAX_VISCOUNTS && !tr.refdef.areamaskModified && !r_showcluster->modified)// && !r_dynamicBspOcclusionCulling->modified)
|
||||
{
|
||||
if(tr.visClusters[i] != tr.visClusters[tr.visIndex] && r_showcluster->integer)
|
||||
else if(tr.visClusters[i] == cluster)
|
||||
{
|
||||
ri.Printf(PRINT_ALL, "found cluster:%i area:%i index:%i\n", cluster, leaf->area, i);
|
||||
if(tr.visClusters[i] != tr.visClusters[tr.visIndex] && r_showcluster->integer)
|
||||
{
|
||||
ri.Printf(PRINT_ALL, "found cluster:%i area:%i index:%i\n", cluster, leaf->area, i);
|
||||
}
|
||||
tr.visIndex = i;
|
||||
return;
|
||||
}
|
||||
tr.visIndex = i;
|
||||
return;
|
||||
}
|
||||
|
||||
// if the areamask was modified, invalidate all visclusters
|
||||
// this caused doors to open into undrawn areas
|
||||
if (tr.refdef.areamaskModified)
|
||||
{
|
||||
memset(tr.visClusters, -2, sizeof(tr.visClusters));
|
||||
}
|
||||
|
||||
tr.visIndex = (tr.visIndex + 1) % MAX_VISCOUNTS;
|
||||
|
@ -734,17 +726,6 @@ static void R_MarkLeaves (void) {
|
|||
}
|
||||
}
|
||||
|
||||
// set all nodes to visible if there is no vis
|
||||
// this caused some levels to simply not render
|
||||
if (r_novis->integer || !tr.world->vis || tr.visClusters[tr.visIndex] == -1) {
|
||||
for (i=0 ; i<tr.world->numnodes ; i++) {
|
||||
if (tr.world->nodes[i].contents != CONTENTS_SOLID) {
|
||||
tr.world->nodes[i].visCounts[tr.visIndex] = tr.visCounts[tr.visIndex];
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
vis = R_ClusterPVS(tr.visClusters[tr.visIndex]);
|
||||
|
||||
for (i=0,leaf=tr.world->nodes ; i<tr.world->numnodes ; i++, leaf++) {
|
||||
|
@ -754,7 +735,7 @@ static void R_MarkLeaves (void) {
|
|||
}
|
||||
|
||||
// check general pvs
|
||||
if ( !(vis[cluster>>3] & (1<<(cluster&7))) ) {
|
||||
if ( vis && !(vis[cluster>>3] & (1<<(cluster&7))) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue