mirror of
https://github.com/ReactionQuake3/reaction.git
synced 2024-11-28 15:02:32 +00:00
Updated to ioquake3 git dated 17 sept 2013
This commit is contained in:
parent
488a91a0cd
commit
45e82a1618
6 changed files with 77 additions and 73 deletions
|
@ -85,16 +85,13 @@ float CalcFog(vec4 position)
|
||||||
float s = dot(position, u_FogDistance) * 8.0;
|
float s = dot(position, u_FogDistance) * 8.0;
|
||||||
float t = dot(position, u_FogDepth);
|
float t = dot(position, u_FogDepth);
|
||||||
|
|
||||||
if (t < 1.0)
|
bool eyeOutside = u_FogEyeT < 0.0;
|
||||||
{
|
float t2 = float(t >= float(eyeOutside));
|
||||||
t = step(step(0.0, -u_FogEyeT), t);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
t /= t - min(u_FogEyeT, 0.0);
|
|
||||||
}
|
|
||||||
|
|
||||||
return s * t;
|
if (eyeOutside)
|
||||||
|
t2 *= t / (t - u_FogEyeT);
|
||||||
|
|
||||||
|
return s * t2;
|
||||||
}
|
}
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
|
|
|
@ -194,16 +194,13 @@ float CalcFog(vec4 position)
|
||||||
float s = dot(position, u_FogDistance) * 8.0;
|
float s = dot(position, u_FogDistance) * 8.0;
|
||||||
float t = dot(position, u_FogDepth);
|
float t = dot(position, u_FogDepth);
|
||||||
|
|
||||||
if (t < 1.0)
|
bool eyeOutside = u_FogEyeT < 0.0;
|
||||||
{
|
float t2 = float(t >= float(eyeOutside));
|
||||||
t = step(step(0.0, -u_FogEyeT), t);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
t /= t - min(u_FogEyeT, 0.0);
|
|
||||||
}
|
|
||||||
|
|
||||||
return s * t;
|
if (eyeOutside)
|
||||||
|
t2 *= t / (t - u_FogEyeT);
|
||||||
|
|
||||||
|
return s * t2;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -261,6 +261,30 @@ vec3 CalcSpecular(vec3 specular, float NH, float NL, float NE, float EH, float s
|
||||||
return vec3(0.0);
|
return vec3(0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
float CalcLightAttenuation(vec3 dir, float sqrRadius)
|
||||||
|
{
|
||||||
|
// point light at >0 radius, directional otherwise
|
||||||
|
float point = float(sqrRadius > 0.0);
|
||||||
|
|
||||||
|
// inverse square light
|
||||||
|
float attenuation = sqrRadius / dot(dir, dir);
|
||||||
|
|
||||||
|
// zero light at radius, approximating q3 style
|
||||||
|
// also don't attenuate directional light
|
||||||
|
attenuation = (0.5 * attenuation - 1.5) * point + 1.0;
|
||||||
|
|
||||||
|
// clamp attenuation
|
||||||
|
#if defined(NO_LIGHT_CLAMP)
|
||||||
|
attenuation *= float(attenuation > 0.0);
|
||||||
|
#else
|
||||||
|
attenuation = clamp(attenuation, 0.0, 1.0);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return attenuation;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
vec3 L, N, E, H;
|
vec3 L, N, E, H;
|
||||||
|
@ -290,25 +314,7 @@ void main()
|
||||||
#endif
|
#endif
|
||||||
vec3 lightColor = lightSample.rgb;
|
vec3 lightColor = lightSample.rgb;
|
||||||
#elif defined(USE_LIGHT_VECTOR) && !defined(USE_FAST_LIGHT)
|
#elif defined(USE_LIGHT_VECTOR) && !defined(USE_FAST_LIGHT)
|
||||||
// inverse square light
|
vec3 lightColor = u_DirectedLight * CalcLightAttenuation(L, u_LightRadius * u_LightRadius);
|
||||||
float attenuation = u_LightRadius * u_LightRadius / dot(L, L);
|
|
||||||
|
|
||||||
// zero light at radius, approximating q3 style
|
|
||||||
attenuation = 0.5 * attenuation - 0.5;
|
|
||||||
//attenuation = 0.0697168 * attenuation;
|
|
||||||
//attenuation *= step(0.294117, attenuation);
|
|
||||||
|
|
||||||
// clamp attenuation
|
|
||||||
#if defined(NO_LIGHT_CLAMP)
|
|
||||||
attenuation *= step(0.0, attenuation);
|
|
||||||
#else
|
|
||||||
attenuation = clamp(attenuation, 0.0, 1.0);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// don't attenuate directional light
|
|
||||||
attenuation = (attenuation - 1.0) * var_LightDir.w + 1.0;
|
|
||||||
|
|
||||||
vec3 lightColor = u_DirectedLight * attenuation;
|
|
||||||
vec3 ambientColor = u_AmbientLight;
|
vec3 ambientColor = u_AmbientLight;
|
||||||
#elif defined(USE_LIGHT_VERTEX) && !defined(USE_FAST_LIGHT)
|
#elif defined(USE_LIGHT_VERTEX) && !defined(USE_FAST_LIGHT)
|
||||||
vec3 lightColor = var_lightColor;
|
vec3 lightColor = var_lightColor;
|
||||||
|
@ -360,9 +366,9 @@ void main()
|
||||||
|
|
||||||
// surfaces not facing the light are always shadowed
|
// surfaces not facing the light are always shadowed
|
||||||
#if defined(USE_TANGENT_SPACE_LIGHT)
|
#if defined(USE_TANGENT_SPACE_LIGHT)
|
||||||
shadowValue *= step(0.0, var_PrimaryLightDir.z);
|
shadowValue *= float(var_PrimaryLightDir.z > 0.0);
|
||||||
#else
|
#else
|
||||||
shadowValue *= step(0.0, dot(var_Normal, var_PrimaryLightDir));
|
shadowValue *= float(dot(var_Normal, var_PrimaryLightDir) > 0.0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(SHADOWMAP_MODULATE)
|
#if defined(SHADOWMAP_MODULATE)
|
||||||
|
@ -488,11 +494,13 @@ void main()
|
||||||
reflectance = CalcDiffuse(diffuse.rgb, N, L, E, NE, NL, shininess);
|
reflectance = CalcDiffuse(diffuse.rgb, N, L, E, NE, NL, shininess);
|
||||||
reflectance += CalcSpecular(specular.rgb, NH, NL, NE, EH, shininess);
|
reflectance += CalcSpecular(specular.rgb, NH, NL, NE, EH, shininess);
|
||||||
|
|
||||||
|
lightColor = u_PrimaryLightColor; // * CalcLightAttenuation(L, u_PrimaryLightRadius * u_PrimaryLightRadius);
|
||||||
|
|
||||||
#if defined(USE_SHADOWMAP)
|
#if defined(USE_SHADOWMAP)
|
||||||
reflectance *= shadowValue;
|
lightColor *= shadowValue;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
gl_FragColor.rgb += u_PrimaryLightColor * reflectance * NL;
|
gl_FragColor.rgb += lightColor * reflectance * NL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(USE_LINEAR_LIGHT)
|
#if defined(USE_LINEAR_LIGHT)
|
||||||
|
|
|
@ -130,6 +130,29 @@ vec2 ModTexCoords(vec2 st, vec3 position, vec4 texMatrix, vec4 offTurb)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
float CalcLightAttenuation(vec3 dir, float sqrRadius)
|
||||||
|
{
|
||||||
|
// point light at >0 radius, directional otherwise
|
||||||
|
float point = float(sqrRadius > 0.0);
|
||||||
|
|
||||||
|
// inverse square light
|
||||||
|
float attenuation = sqrRadius / dot(dir, dir);
|
||||||
|
|
||||||
|
// zero light at radius, approximating q3 style
|
||||||
|
// also don't attenuate directional light
|
||||||
|
attenuation = (0.5 * attenuation - 1.5) * point + 1.0;
|
||||||
|
|
||||||
|
// clamp attenuation
|
||||||
|
#if defined(NO_LIGHT_CLAMP)
|
||||||
|
attenuation *= float(attenuation > 0.0);
|
||||||
|
#else
|
||||||
|
attenuation = clamp(attenuation, 0.0, 1.0);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return attenuation;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
#if defined(USE_VERTEX_ANIMATION)
|
#if defined(USE_VERTEX_ANIMATION)
|
||||||
|
@ -187,24 +210,7 @@ void main()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(USE_LIGHT_VECTOR) && defined(USE_FAST_LIGHT)
|
#if defined(USE_LIGHT_VECTOR) && defined(USE_FAST_LIGHT)
|
||||||
// inverse square light
|
float attenuation = CalcLightAttenuation(L, u_LightRadius * u_LightRadius);
|
||||||
float attenuation = u_LightRadius * u_LightRadius / dot(L, L);
|
|
||||||
|
|
||||||
// zero light at radius, approximating q3 style
|
|
||||||
attenuation = 0.5 * attenuation - 0.5;
|
|
||||||
//attenuation = 0.0697168 * attenuation;
|
|
||||||
//attenuation *= step(0.294117, attenuation);
|
|
||||||
|
|
||||||
// clamp attenuation
|
|
||||||
#if defined(NO_LIGHT_CLAMP)
|
|
||||||
attenuation *= step(0.0, attenuation);
|
|
||||||
#else
|
|
||||||
attenuation = clamp(attenuation, 0.0, 1.0);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// don't attenuate directional light
|
|
||||||
attenuation = (attenuation - 1.0) * u_LightOrigin.w + 1.0;
|
|
||||||
|
|
||||||
float NL = clamp(dot(normal, normalize(L)), 0.0, 1.0);
|
float NL = clamp(dot(normal, normalize(L)), 0.0, 1.0);
|
||||||
|
|
||||||
var_Color.rgb *= u_DirectedLight * attenuation * NL + u_AmbientLight;
|
var_Color.rgb *= u_DirectedLight * attenuation * NL + u_AmbientLight;
|
||||||
|
|
|
@ -150,22 +150,18 @@ void ColorToRGBM(const vec3_t color, unsigned char rgbm[4])
|
||||||
|
|
||||||
VectorScale(color, 1.0f / 32.0f, sample);
|
VectorScale(color, 1.0f / 32.0f, sample);
|
||||||
|
|
||||||
maxComponent = sample[0];
|
maxComponent = MAX(sample[0], sample[1]);
|
||||||
if(sample[1] > maxComponent)
|
maxComponent = MAX(maxComponent, sample[2]);
|
||||||
maxComponent = sample[1];
|
maxComponent = CLAMP(maxComponent, 1.0f/255.0f, 1.0f);
|
||||||
if(sample[2] > maxComponent)
|
|
||||||
maxComponent = sample[2];
|
|
||||||
if(0.000001f > maxComponent)
|
|
||||||
maxComponent = 0.000001f;
|
|
||||||
if(maxComponent > 1.0f)
|
|
||||||
maxComponent = 1.0f;
|
|
||||||
|
|
||||||
VectorScale(sample, 1.0f / maxComponent, sample);
|
rgbm[3] = (unsigned char) ceil(maxComponent * 255.0f);
|
||||||
|
maxComponent = 255.0f / rgbm[3];
|
||||||
|
|
||||||
|
VectorScale(sample, maxComponent, sample);
|
||||||
|
|
||||||
rgbm[0] = (unsigned char) (sample[0] * 255);
|
rgbm[0] = (unsigned char) (sample[0] * 255);
|
||||||
rgbm[1] = (unsigned char) (sample[1] * 255);
|
rgbm[1] = (unsigned char) (sample[1] * 255);
|
||||||
rgbm[2] = (unsigned char) (sample[2] * 255);
|
rgbm[2] = (unsigned char) (sample[2] * 255);
|
||||||
rgbm[3] = (unsigned char) (maxComponent * 255);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ColorToRGBA16F(const vec3_t color, unsigned short rgba16f[4])
|
void ColorToRGBA16F(const vec3_t color, unsigned short rgba16f[4])
|
||||||
|
|
|
@ -1211,7 +1211,7 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input )
|
||||||
vec[3] = 0.0f;
|
vec[3] = 0.0f;
|
||||||
GLSL_SetUniformVec4(sp, UNIFORM_LIGHTORIGIN, vec);
|
GLSL_SetUniformVec4(sp, UNIFORM_LIGHTORIGIN, vec);
|
||||||
|
|
||||||
GLSL_SetUniformFloat(sp, UNIFORM_LIGHTRADIUS, 999999.0f);
|
GLSL_SetUniformFloat(sp, UNIFORM_LIGHTRADIUS, 0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pStage->alphaGen == AGEN_PORTAL)
|
if (pStage->alphaGen == AGEN_PORTAL)
|
||||||
|
|
Loading…
Reference in a new issue