mirror of
https://github.com/UberGames/ioef.git
synced 2024-11-24 05:01:40 +00:00
Merge branch 'master' into sdl2
This commit is contained in:
commit
9ec7931c54
16 changed files with 271 additions and 104 deletions
|
@ -83,7 +83,7 @@ LPALBUFFERDATA qalBufferData;
|
|||
LPALGETBUFFERF qalGetBufferf;
|
||||
LPALGETBUFFERI qalGetBufferi;
|
||||
LPALDOPPLERFACTOR qalDopplerFactor;
|
||||
LPALDOPPLERVELOCITY qalDopplerVelocity;
|
||||
LPALSPEEDOFSOUND qalSpeedOfSound;
|
||||
LPALDISTANCEMODEL qalDistanceModel;
|
||||
|
||||
LPALCCREATECONTEXT qalcCreateContext;
|
||||
|
@ -201,7 +201,7 @@ qboolean QAL_Init(const char *libname)
|
|||
qalGetBufferf = GPA("alGetBufferf");
|
||||
qalGetBufferi = GPA("alGetBufferi");
|
||||
qalDopplerFactor = GPA("alDopplerFactor");
|
||||
qalDopplerVelocity = GPA("alDopplerVelocity");
|
||||
qalSpeedOfSound = GPA("alSpeedOfSound");
|
||||
qalDistanceModel = GPA("alDistanceModel");
|
||||
|
||||
qalcCreateContext = GPA("alcCreateContext");
|
||||
|
@ -300,7 +300,7 @@ void QAL_Shutdown( void )
|
|||
qalGetBufferf = NULL;
|
||||
qalGetBufferi = NULL;
|
||||
qalDopplerFactor = NULL;
|
||||
qalDopplerVelocity = NULL;
|
||||
qalSpeedOfSound = NULL;
|
||||
qalDistanceModel = NULL;
|
||||
|
||||
qalcCreateContext = NULL;
|
||||
|
|
|
@ -125,7 +125,6 @@ extern LPALGETBUFFERI qalGetBufferi;
|
|||
extern LPALGETBUFFER3I qalGetBuffer3i;
|
||||
extern LPALGETBUFFERIV qalGetBufferiv;
|
||||
extern LPALDOPPLERFACTOR qalDopplerFactor;
|
||||
extern LPALDOPPLERVELOCITY qalDopplerVelocity;
|
||||
extern LPALSPEEDOFSOUND qalSpeedOfSound;
|
||||
extern LPALDISTANCEMODEL qalDistanceModel;
|
||||
|
||||
|
@ -220,7 +219,6 @@ extern LPALCCAPTURESAMPLES qalcCaptureSamples;
|
|||
#define qalGetBuffer3i alGetBuffer3i
|
||||
#define qalGetBufferiv alGetBufferiv
|
||||
#define qalDopplerFactor alDopplerFactor
|
||||
#define qalDopplerVelocity alDopplerVelocity
|
||||
#define qalSpeedOfSound alSpeedOfSound
|
||||
#define qalDistanceModel alDistanceModel
|
||||
|
||||
|
|
|
@ -2309,7 +2309,7 @@ void S_AL_Update( void )
|
|||
}
|
||||
if(s_alDopplerSpeed->modified)
|
||||
{
|
||||
qalDopplerVelocity(s_alDopplerSpeed->value);
|
||||
qalSpeedOfSound(s_alDopplerSpeed->value);
|
||||
s_alDopplerSpeed->modified = qfalse;
|
||||
}
|
||||
|
||||
|
@ -2506,7 +2506,7 @@ qboolean S_AL_Init( soundInterface_t *si )
|
|||
s_alGain = Cvar_Get( "s_alGain", "1.0", CVAR_ARCHIVE );
|
||||
s_alSources = Cvar_Get( "s_alSources", "96", CVAR_ARCHIVE );
|
||||
s_alDopplerFactor = Cvar_Get( "s_alDopplerFactor", "1.0", CVAR_ARCHIVE );
|
||||
s_alDopplerSpeed = Cvar_Get( "s_alDopplerSpeed", "2200", CVAR_ARCHIVE );
|
||||
s_alDopplerSpeed = Cvar_Get( "s_alDopplerSpeed", "13512", CVAR_ARCHIVE );
|
||||
s_alMinDistance = Cvar_Get( "s_alMinDistance", "120", CVAR_CHEAT );
|
||||
s_alMaxDistance = Cvar_Get("s_alMaxDistance", "1024", CVAR_CHEAT);
|
||||
s_alRolloff = Cvar_Get( "s_alRolloff", "2", CVAR_CHEAT);
|
||||
|
@ -2623,7 +2623,7 @@ qboolean S_AL_Init( soundInterface_t *si )
|
|||
// Set up OpenAL parameters (doppler, etc)
|
||||
qalDistanceModel(AL_INVERSE_DISTANCE_CLAMPED);
|
||||
qalDopplerFactor( s_alDopplerFactor->value );
|
||||
qalDopplerVelocity( s_alDopplerSpeed->value );
|
||||
qalSpeedOfSound( s_alDopplerSpeed->value );
|
||||
|
||||
#ifdef USE_VOIP
|
||||
// !!! FIXME: some of these alcCaptureOpenDevice() values should be cvars.
|
||||
|
|
|
@ -688,7 +688,7 @@ void trap_BotSaveGoalFuzzyLogic(int goalstate, char *filename) {
|
|||
}
|
||||
|
||||
void trap_BotMutateGoalFuzzyLogic(int goalstate, float range) {
|
||||
syscall( BOTLIB_AI_MUTATE_GOAL_FUZZY_LOGIC, goalstate, range );
|
||||
syscall( BOTLIB_AI_MUTATE_GOAL_FUZZY_LOGIC, goalstate, PASSFLOAT(range) );
|
||||
}
|
||||
|
||||
int trap_BotAllocGoalState(int state) {
|
||||
|
|
|
@ -25,7 +25,8 @@ uniform samplerCube u_CubeMap;
|
|||
#endif
|
||||
|
||||
#if defined(USE_NORMALMAP) || defined(USE_DELUXEMAP) || defined(USE_SPECULARMAP) || defined(USE_CUBEMAP)
|
||||
uniform vec4 u_EnableTextures; // x = normal, y = deluxe, z = specular, w = cube
|
||||
// y = deluxe, w = cube
|
||||
uniform vec4 u_EnableTextures;
|
||||
#endif
|
||||
|
||||
#if defined(USE_LIGHT_VECTOR) && !defined(USE_FAST_LIGHT)
|
||||
|
@ -39,7 +40,8 @@ uniform vec3 u_PrimaryLightAmbient;
|
|||
#endif
|
||||
|
||||
#if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT)
|
||||
uniform vec2 u_MaterialInfo;
|
||||
uniform vec4 u_NormalScale;
|
||||
uniform vec4 u_SpecularScale;
|
||||
#endif
|
||||
|
||||
varying vec4 var_TexCoords;
|
||||
|
@ -167,7 +169,7 @@ vec3 EnvironmentBRDF(float gloss, float NE, vec3 specular)
|
|||
return clamp( a0 + specular * ( a1 - a0 ), 0.0, 1.0 );
|
||||
#elif 0
|
||||
// from http://seblagarde.wordpress.com/2011/08/17/hello-world/
|
||||
return mix(specular.rgb, max(specular.rgb, vec3(gloss)), CalcFresnel(NE));
|
||||
return specular + CalcFresnel(NE) * clamp(vec3(gloss) - specular, 0.0, 1.0);
|
||||
#else
|
||||
// from http://advances.realtimerendering.com/s2011/Lazarov-Physically-Based-Lighting-in-Black-Ops%20%28Siggraph%202011%20Advances%20in%20Real-Time%20Rendering%20Course%29.pptx
|
||||
return mix(specular.rgb, vec3(1.0), CalcFresnel(NE) / (4.0 - 3.0 * gloss));
|
||||
|
@ -360,7 +362,7 @@ void main()
|
|||
#if defined(USE_PARALLAXMAP)
|
||||
vec3 offsetDir = normalize(E * tangentToWorld);
|
||||
|
||||
offsetDir.xy *= -0.05 / offsetDir.z;
|
||||
offsetDir.xy *= -u_NormalScale.a / offsetDir.z;
|
||||
|
||||
texCoords += offsetDir.xy * RayIntersectDisplaceMap(texCoords, offsetDir.xy, u_NormalMap);
|
||||
#endif
|
||||
|
@ -378,8 +380,8 @@ void main()
|
|||
#else
|
||||
N.xy = texture2D(u_NormalMap, texCoords).rg - vec2(0.5);
|
||||
#endif
|
||||
N.xy *= u_EnableTextures.x;
|
||||
N.z = sqrt((0.25 - N.x * N.x) - N.y * N.y);
|
||||
N.xy *= u_NormalScale.xy;
|
||||
N.z = sqrt(clamp((0.25 - N.x * N.x) - N.y * N.y, 0.0, 1.0));
|
||||
N = tangentToWorld * N;
|
||||
#else
|
||||
N = var_Normal.xyz;
|
||||
|
@ -425,15 +427,16 @@ void main()
|
|||
NL = clamp(dot(N, L), 0.0, 1.0);
|
||||
NE = clamp(dot(N, E), 0.0, 1.0);
|
||||
|
||||
vec4 specular = vec4(1.0);
|
||||
#if defined(USE_SPECULARMAP)
|
||||
specular += texture2D(u_SpecularMap, texCoords) * u_EnableTextures.z - u_EnableTextures.zzzz;
|
||||
vec4 specular = texture2D(u_SpecularMap, texCoords);
|
||||
#if defined(USE_GAMMA2_TEXTURES)
|
||||
specular.rgb *= specular.rgb;
|
||||
#endif
|
||||
#else
|
||||
vec4 specular = vec4(1.0);
|
||||
#endif
|
||||
|
||||
specular *= u_MaterialInfo.xxxy;
|
||||
specular *= u_SpecularScale;
|
||||
|
||||
float gloss = specular.a;
|
||||
float shininess = exp2(gloss * 13.0);
|
||||
|
@ -473,7 +476,21 @@ void main()
|
|||
#endif
|
||||
|
||||
gl_FragColor.rgb = lightColor * reflectance * NL;
|
||||
|
||||
#if 0
|
||||
vec3 aSpecular = EnvironmentBRDF(gloss, NE, specular.rgb);
|
||||
|
||||
// do ambient as two hemisphere lights, one straight up one straight down
|
||||
float hemiDiffuseUp = N.z * 0.5 + 0.5;
|
||||
float hemiDiffuseDown = 1.0 - hemiDiffuseUp;
|
||||
float hemiSpecularUp = mix(hemiDiffuseUp, float(N.z >= 0.0), gloss);
|
||||
float hemiSpecularDown = 1.0 - hemiSpecularUp;
|
||||
|
||||
gl_FragColor.rgb += ambientColor * 0.75 * (diffuse.rgb * hemiDiffuseUp + aSpecular * hemiSpecularUp);
|
||||
gl_FragColor.rgb += ambientColor * 0.25 * (diffuse.rgb * hemiDiffuseDown + aSpecular * hemiSpecularDown);
|
||||
#else
|
||||
gl_FragColor.rgb += ambientColor * (diffuse.rgb + specular.rgb);
|
||||
#endif
|
||||
|
||||
#if defined(USE_CUBEMAP)
|
||||
reflectance = EnvironmentBRDF(gloss, NE, specular.rgb);
|
||||
|
|
|
@ -18,6 +18,10 @@ uniform vec4 u_ViewInfo; // zfar / znear, zfar
|
|||
varying vec2 var_DepthTex;
|
||||
varying vec3 var_ViewDir;
|
||||
|
||||
// depth is GL_DEPTH_COMPONENT24
|
||||
// so the maximum error is 1.0 / 2^24
|
||||
#define DEPTH_MAX_ERROR 0.000000059604644775390625
|
||||
|
||||
// Input: It uses texture coords as the random number seed.
|
||||
// Output: Random number: [0,1), that is between 0.0 and 0.999999... inclusive.
|
||||
// Author: Michael Pohoreski
|
||||
|
@ -71,6 +75,7 @@ float PCF(const sampler2D shadowmap, const vec2 st, const float dist)
|
|||
float getLinearDepth(sampler2D depthMap, vec2 tex, float zFarDivZNear)
|
||||
{
|
||||
float sampleZDivW = texture2D(depthMap, tex).r;
|
||||
sampleZDivW -= DEPTH_MAX_ERROR;
|
||||
return 1.0 / mix(zFarDivZNear, 1.0, sampleZDivW);
|
||||
}
|
||||
|
||||
|
@ -81,7 +86,7 @@ void main()
|
|||
float depth = getLinearDepth(u_ScreenDepthMap, var_DepthTex, u_ViewInfo.x);
|
||||
float sampleZ = u_ViewInfo.y * depth;
|
||||
|
||||
vec4 biasPos = vec4(u_ViewOrigin + var_ViewDir * depth * 0.99, 1.0);
|
||||
vec4 biasPos = vec4(u_ViewOrigin + var_ViewDir * (depth - 0.5 / u_ViewInfo.x), 1.0);
|
||||
|
||||
vec4 shadowpos = u_ShadowMvp * biasPos;
|
||||
|
||||
|
|
|
@ -193,7 +193,8 @@ void R_MDRAddAnimSurfaces( trRefEntity_t *ent ) {
|
|||
|
||||
header = (mdrHeader_t *) tr.currentModel->modelData;
|
||||
|
||||
personalModel = (ent->e.renderfx & RF_THIRD_PERSON) && !tr.viewParms.isPortal;
|
||||
personalModel = (ent->e.renderfx & RF_THIRD_PERSON) && !(tr.viewParms.isPortal
|
||||
|| (tr.viewParms.flags & (VPF_SHADOWMAP | VPF_DEPTHSHADOW)));
|
||||
|
||||
if ( ent->e.renderfx & RF_WRAP_FRAMES )
|
||||
{
|
||||
|
|
|
@ -143,7 +143,7 @@ static void R_ColorShiftLightingFloats(float in[4], float out[4], float scale )
|
|||
b = in[2] * scale;
|
||||
|
||||
// normalize by color instead of saturating to white
|
||||
if ( !r_hdr->integer && ( r > 1 || g > 1 || b > 1 ) ) {
|
||||
if ( r > 1 || g > 1 || b > 1 ) {
|
||||
float max;
|
||||
|
||||
max = r > g ? r : g;
|
||||
|
|
|
@ -125,7 +125,8 @@ static uniformInfo_t uniformsInfo[] =
|
|||
|
||||
{ "u_Time", GLSL_FLOAT },
|
||||
{ "u_VertexLerp" , GLSL_FLOAT },
|
||||
{ "u_MaterialInfo", GLSL_VEC2 },
|
||||
{ "u_NormalScale", GLSL_VEC4 },
|
||||
{ "u_SpecularScale", GLSL_VEC4 },
|
||||
|
||||
{ "u_ViewInfo", GLSL_VEC4 },
|
||||
{ "u_ViewOrigin", GLSL_VEC3 },
|
||||
|
|
|
@ -3013,37 +3013,14 @@ void R_SetColorMappings( void ) {
|
|||
int i, j;
|
||||
float g;
|
||||
int inf;
|
||||
int shift;
|
||||
|
||||
// setup the overbright lighting
|
||||
tr.overbrightBits = r_overBrightBits->integer;
|
||||
if ( !glConfig.deviceSupportsGamma ) {
|
||||
tr.overbrightBits = 0; // need hardware gamma for overbright
|
||||
}
|
||||
|
||||
// never overbright in windowed mode without soft overbright
|
||||
if ( !glConfig.isFullscreen && !r_softOverbright->integer )
|
||||
{
|
||||
tr.overbrightBits = 0;
|
||||
}
|
||||
|
||||
// never overbright with tonemapping
|
||||
if ( r_toneMap->integer && r_hdr->integer )
|
||||
{
|
||||
tr.overbrightBits = 0;
|
||||
}
|
||||
|
||||
// allow 2 overbright bits in 24 bit, but only 1 in 16 bit
|
||||
if ( glConfig.colorBits > 16 ) {
|
||||
// allow 2 overbright bits
|
||||
if ( tr.overbrightBits > 2 ) {
|
||||
tr.overbrightBits = 2;
|
||||
}
|
||||
} else {
|
||||
if ( tr.overbrightBits > 1 ) {
|
||||
tr.overbrightBits = 1;
|
||||
}
|
||||
}
|
||||
if ( tr.overbrightBits < 0 ) {
|
||||
} else if ( tr.overbrightBits < 0 ) {
|
||||
tr.overbrightBits = 0;
|
||||
}
|
||||
|
||||
|
@ -3063,14 +3040,6 @@ void R_SetColorMappings( void ) {
|
|||
|
||||
g = r_gamma->value;
|
||||
|
||||
shift = tr.overbrightBits;
|
||||
|
||||
// no shift with soft overbright
|
||||
if (r_softOverbright->integer)
|
||||
{
|
||||
shift = 0;
|
||||
}
|
||||
|
||||
for ( i = 0; i < 256; i++ ) {
|
||||
int i2;
|
||||
|
||||
|
@ -3088,7 +3057,7 @@ void R_SetColorMappings( void ) {
|
|||
} else {
|
||||
inf = 255 * pow ( i2/255.0f, 1.0f / g ) + 0.5f;
|
||||
}
|
||||
inf <<= shift;
|
||||
|
||||
if (inf < 0) {
|
||||
inf = 0;
|
||||
}
|
||||
|
|
|
@ -110,8 +110,6 @@ cvar_t *r_mergeLeafSurfaces;
|
|||
|
||||
cvar_t *r_cameraExposure;
|
||||
|
||||
cvar_t *r_softOverbright;
|
||||
|
||||
cvar_t *r_hdr;
|
||||
cvar_t *r_floatLightmap;
|
||||
cvar_t *r_postProcess;
|
||||
|
@ -139,6 +137,9 @@ cvar_t *r_parallaxMapping;
|
|||
cvar_t *r_cubeMapping;
|
||||
cvar_t *r_deluxeSpecular;
|
||||
cvar_t *r_specularIsMetallic;
|
||||
cvar_t *r_baseNormalX;
|
||||
cvar_t *r_baseNormalY;
|
||||
cvar_t *r_baseParallax;
|
||||
cvar_t *r_baseSpecular;
|
||||
cvar_t *r_baseGloss;
|
||||
cvar_t *r_recalcMD3Normals;
|
||||
|
@ -1163,8 +1164,6 @@ void R_Register( void )
|
|||
r_greyscale = ri.Cvar_Get("r_greyscale", "0", CVAR_ARCHIVE | CVAR_LATCH);
|
||||
ri.Cvar_CheckRange(r_greyscale, 0, 1, qfalse);
|
||||
|
||||
r_softOverbright = ri.Cvar_Get( "r_softOverbright", "1", CVAR_ARCHIVE | CVAR_LATCH );
|
||||
|
||||
r_hdr = ri.Cvar_Get( "r_hdr", "1", CVAR_ARCHIVE | CVAR_LATCH );
|
||||
r_floatLightmap = ri.Cvar_Get( "r_floatLightmap", "0", CVAR_ARCHIVE | CVAR_LATCH );
|
||||
r_postProcess = ri.Cvar_Get( "r_postProcess", "1", CVAR_ARCHIVE );
|
||||
|
@ -1194,6 +1193,9 @@ void R_Register( void )
|
|||
r_cubeMapping = ri.Cvar_Get( "r_cubeMapping", "0", CVAR_ARCHIVE | CVAR_LATCH );
|
||||
r_deluxeSpecular = ri.Cvar_Get( "r_deluxeSpecular", "0.3", CVAR_ARCHIVE | CVAR_LATCH );
|
||||
r_specularIsMetallic = ri.Cvar_Get( "r_specularIsMetallic", "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 );
|
||||
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_dlightMode = ri.Cvar_Get( "r_dlightMode", "0", CVAR_ARCHIVE | CVAR_LATCH );
|
||||
|
|
|
@ -400,7 +400,10 @@ typedef struct {
|
|||
stageType_t type;
|
||||
struct shaderProgram_s *glslShaderGroup;
|
||||
int glslShaderIndex;
|
||||
vec2_t materialInfo;
|
||||
|
||||
vec4_t normalScale;
|
||||
vec4_t specularScale;
|
||||
|
||||
} shaderStage_t;
|
||||
|
||||
struct shaderCommands_s;
|
||||
|
@ -676,7 +679,8 @@ typedef enum
|
|||
|
||||
UNIFORM_TIME,
|
||||
UNIFORM_VERTEXLERP,
|
||||
UNIFORM_MATERIALINFO,
|
||||
UNIFORM_NORMALSCALE,
|
||||
UNIFORM_SPECULARSCALE,
|
||||
|
||||
UNIFORM_VIEWINFO, // znear, zfar, width/2, height/2
|
||||
UNIFORM_VIEWORIGIN,
|
||||
|
@ -1766,8 +1770,6 @@ extern cvar_t *r_anaglyphMode;
|
|||
extern cvar_t *r_mergeMultidraws;
|
||||
extern cvar_t *r_mergeLeafSurfaces;
|
||||
|
||||
extern cvar_t *r_softOverbright;
|
||||
|
||||
extern cvar_t *r_hdr;
|
||||
extern cvar_t *r_floatLightmap;
|
||||
extern cvar_t *r_postProcess;
|
||||
|
@ -1797,6 +1799,9 @@ extern cvar_t *r_parallaxMapping;
|
|||
extern cvar_t *r_cubeMapping;
|
||||
extern cvar_t *r_deluxeSpecular;
|
||||
extern cvar_t *r_specularIsMetallic;
|
||||
extern cvar_t *r_baseNormalX;
|
||||
extern cvar_t *r_baseNormalY;
|
||||
extern cvar_t *r_baseParallax;
|
||||
extern cvar_t *r_baseSpecular;
|
||||
extern cvar_t *r_baseGloss;
|
||||
extern cvar_t *r_dlightMode;
|
||||
|
|
|
@ -602,7 +602,7 @@ static void ComputeShaderColors( shaderStage_t *pStage, vec4_t baseColor, vec4_t
|
|||
}
|
||||
|
||||
// multiply color by overbrightbits if this isn't a blend
|
||||
if (r_softOverbright->integer && tr.overbrightBits
|
||||
if (tr.overbrightBits
|
||||
&& !((blend & GLS_SRCBLEND_BITS) == GLS_SRCBLEND_DST_COLOR)
|
||||
&& !((blend & GLS_SRCBLEND_BITS) == GLS_SRCBLEND_ONE_MINUS_DST_COLOR)
|
||||
&& !((blend & GLS_DSTBLEND_BITS) == GLS_DSTBLEND_SRC_COLOR)
|
||||
|
@ -811,7 +811,8 @@ static void ForwardDlight( void ) {
|
|||
|
||||
GLSL_SetUniformFloat(sp, UNIFORM_LIGHTRADIUS, radius);
|
||||
|
||||
GLSL_SetUniformVec2(sp, UNIFORM_MATERIALINFO, pStage->materialInfo);
|
||||
GLSL_SetUniformVec4(sp, UNIFORM_NORMALSCALE, pStage->normalScale);
|
||||
GLSL_SetUniformVec4(sp, UNIFORM_SPECULARSCALE, pStage->specularScale);
|
||||
|
||||
// include GLS_DEPTHFUNC_EQUAL so alpha tested surfaces don't add light
|
||||
// where they aren't rendered
|
||||
|
@ -822,11 +823,36 @@ static void ForwardDlight( void ) {
|
|||
if (pStage->bundle[TB_DIFFUSEMAP].image[0])
|
||||
R_BindAnimatedImageToTMU( &pStage->bundle[TB_DIFFUSEMAP], TB_DIFFUSEMAP);
|
||||
|
||||
// bind textures that are sampled and used in the glsl shader, and
|
||||
// bind whiteImage to textures that are sampled but zeroed in the glsl shader
|
||||
//
|
||||
// alternatives:
|
||||
// - use the last bound texture
|
||||
// -> costs more to sample a higher res texture then throw out the result
|
||||
// - disable texture sampling in glsl shader with #ifdefs, as before
|
||||
// -> increases the number of shaders that must be compiled
|
||||
//
|
||||
|
||||
if (pStage->bundle[TB_NORMALMAP].image[0])
|
||||
{
|
||||
R_BindAnimatedImageToTMU( &pStage->bundle[TB_NORMALMAP], TB_NORMALMAP);
|
||||
}
|
||||
else if (r_normalMapping->integer)
|
||||
GL_BindToTMU( tr.whiteImage, TB_NORMALMAP );
|
||||
|
||||
if (pStage->bundle[TB_SPECULARMAP].image[0])
|
||||
{
|
||||
R_BindAnimatedImageToTMU( &pStage->bundle[TB_SPECULARMAP], TB_SPECULARMAP);
|
||||
}
|
||||
else if (r_specularMapping->integer)
|
||||
GL_BindToTMU( tr.whiteImage, TB_SPECULARMAP );
|
||||
|
||||
{
|
||||
vec4_t enableTextures;
|
||||
|
||||
VectorSet4(enableTextures, 0.0f, 0.0f, 0.0f, 0.0f);
|
||||
GLSL_SetUniformVec4(sp, UNIFORM_ENABLETEXTURES, enableTextures);
|
||||
}
|
||||
|
||||
if (r_dlightMode->integer >= 2)
|
||||
{
|
||||
|
@ -1222,7 +1248,8 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input )
|
|||
|
||||
GLSL_SetUniformMat4(sp, UNIFORM_MODELMATRIX, backEnd.or.transformMatrix);
|
||||
|
||||
GLSL_SetUniformVec2(sp, UNIFORM_MATERIALINFO, pStage->materialInfo);
|
||||
GLSL_SetUniformVec4(sp, UNIFORM_NORMALSCALE, pStage->normalScale);
|
||||
GLSL_SetUniformVec4(sp, UNIFORM_SPECULARSCALE, pStage->specularScale);
|
||||
|
||||
//GLSL_SetUniformFloat(sp, UNIFORM_MAPLIGHTSCALE, backEnd.refdef.mapLightScale);
|
||||
|
||||
|
|
|
@ -911,6 +911,7 @@ static qboolean ParseStage( shaderStage_t *stage, char **text )
|
|||
else if(!Q_stricmp(token, "normalMap") || !Q_stricmp(token, "bumpMap"))
|
||||
{
|
||||
stage->type = ST_NORMALMAP;
|
||||
VectorSet4(stage->normalScale, r_baseNormalX->value, r_baseNormalY->value, 1.0f, r_baseParallax->value);
|
||||
}
|
||||
else if(!Q_stricmp(token, "normalParallaxMap") || !Q_stricmp(token, "bumpParallaxMap"))
|
||||
{
|
||||
|
@ -918,12 +919,12 @@ static qboolean ParseStage( shaderStage_t *stage, char **text )
|
|||
stage->type = ST_NORMALPARALLAXMAP;
|
||||
else
|
||||
stage->type = ST_NORMALMAP;
|
||||
VectorSet4(stage->normalScale, r_baseNormalX->value, r_baseNormalY->value, 1.0f, r_baseParallax->value);
|
||||
}
|
||||
else if(!Q_stricmp(token, "specularMap"))
|
||||
{
|
||||
stage->type = ST_SPECULARMAP;
|
||||
stage->materialInfo[0] = 1.0f;
|
||||
stage->materialInfo[1] = 1.0f;
|
||||
VectorSet4(stage->specularScale, 1.0f, 1.0f, 1.0f, 1.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -942,7 +943,9 @@ 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->materialInfo[0] = atof( token );
|
||||
stage->specularScale[0] =
|
||||
stage->specularScale[1] =
|
||||
stage->specularScale[2] = atof( token );
|
||||
}
|
||||
//
|
||||
// specularExponent <value>
|
||||
|
@ -964,7 +967,7 @@ static qboolean ParseStage( shaderStage_t *stage, char **text )
|
|||
// FIXME: assumes max exponent of 8192 and min of 1, must change here if altered in lightall_fp.glsl
|
||||
exponent = CLAMP(exponent, 1.0, 8192.0);
|
||||
|
||||
stage->materialInfo[1] = log(exponent) / log(8192.0);
|
||||
stage->specularScale[3] = log(exponent) / log(8192.0);
|
||||
}
|
||||
//
|
||||
// gloss <value>
|
||||
|
@ -978,7 +981,103 @@ static qboolean ParseStage( shaderStage_t *stage, char **text )
|
|||
continue;
|
||||
}
|
||||
|
||||
stage->materialInfo[1] = atof( token );
|
||||
stage->specularScale[3] = atof( token );
|
||||
}
|
||||
//
|
||||
// parallaxDepth <value>
|
||||
//
|
||||
else if (!Q_stricmp(token, "parallaxdepth"))
|
||||
{
|
||||
token = COM_ParseExt(text, qfalse);
|
||||
if ( token[0] == 0 )
|
||||
{
|
||||
ri.Printf( PRINT_WARNING, "WARNING: missing parameter for parallaxDepth in shader '%s'\n", shader.name );
|
||||
continue;
|
||||
}
|
||||
|
||||
stage->normalScale[3] = atof( token );
|
||||
}
|
||||
//
|
||||
// normalScale <xy>
|
||||
// or normalScale <x> <y>
|
||||
// or normalScale <x> <y> <height>
|
||||
//
|
||||
else if (!Q_stricmp(token, "normalscale"))
|
||||
{
|
||||
token = COM_ParseExt(text, qfalse);
|
||||
if ( token[0] == 0 )
|
||||
{
|
||||
ri.Printf( PRINT_WARNING, "WARNING: missing parameter for normalScale in shader '%s'\n", shader.name );
|
||||
continue;
|
||||
}
|
||||
|
||||
stage->normalScale[0] = atof( token );
|
||||
|
||||
token = COM_ParseExt(text, qfalse);
|
||||
if ( token[0] == 0 )
|
||||
{
|
||||
// one value, applies to X/Y
|
||||
stage->normalScale[1] = stage->normalScale[0];
|
||||
continue;
|
||||
}
|
||||
|
||||
stage->normalScale[1] = atof( token );
|
||||
|
||||
token = COM_ParseExt(text, qfalse);
|
||||
if ( token[0] == 0 )
|
||||
{
|
||||
// two values, no height
|
||||
continue;
|
||||
}
|
||||
|
||||
stage->normalScale[3] = atof( token );
|
||||
}
|
||||
//
|
||||
// specularScale <rgb> <gloss>
|
||||
// or specularScale <r> <g> <b>
|
||||
// or specularScale <r> <g> <b> <gloss>
|
||||
//
|
||||
else if (!Q_stricmp(token, "specularscale"))
|
||||
{
|
||||
token = COM_ParseExt(text, qfalse);
|
||||
if ( token[0] == 0 )
|
||||
{
|
||||
ri.Printf( PRINT_WARNING, "WARNING: missing parameter for specularScale in shader '%s'\n", shader.name );
|
||||
continue;
|
||||
}
|
||||
|
||||
stage->specularScale[0] = atof( token );
|
||||
|
||||
token = COM_ParseExt(text, qfalse);
|
||||
if ( token[0] == 0 )
|
||||
{
|
||||
ri.Printf( PRINT_WARNING, "WARNING: missing parameter for specularScale in shader '%s'\n", shader.name );
|
||||
continue;
|
||||
}
|
||||
|
||||
stage->specularScale[1] = atof( token );
|
||||
|
||||
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];
|
||||
continue;
|
||||
}
|
||||
|
||||
stage->specularScale[2] = atof( token );
|
||||
|
||||
token = COM_ParseExt(text, qfalse);
|
||||
if ( token[0] == 0 )
|
||||
{
|
||||
// three values, rgb
|
||||
continue;
|
||||
}
|
||||
|
||||
stage->specularScale[2] = atof( token );
|
||||
|
||||
}
|
||||
//
|
||||
// rgbGen
|
||||
|
@ -2231,6 +2330,8 @@ static void CollapseStagesToLightall(shaderStage_t *diffuse,
|
|||
diffuse->bundle[TB_NORMALMAP] = normal->bundle[0];
|
||||
if (parallax && r_parallaxMapping->integer)
|
||||
defs |= LIGHTDEF_USE_PARALLAXMAP;
|
||||
|
||||
VectorCopy4(normal->normalScale, diffuse->normalScale);
|
||||
}
|
||||
else if ((lightmap || useLightVector || useLightVertex) && (diffuseImg = diffuse->bundle[TB_DIFFUSEMAP].image[0]))
|
||||
{
|
||||
|
@ -2251,6 +2352,8 @@ static void CollapseStagesToLightall(shaderStage_t *diffuse,
|
|||
|
||||
if (parallax && r_parallaxMapping->integer)
|
||||
defs |= LIGHTDEF_USE_PARALLAXMAP;
|
||||
|
||||
VectorSet4(diffuse->normalScale, r_baseNormalX->value, r_baseNormalY->value, 1.0f, r_baseParallax->value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2261,8 +2364,7 @@ static void CollapseStagesToLightall(shaderStage_t *diffuse,
|
|||
{
|
||||
//ri.Printf(PRINT_ALL, ", specularmap %s", specular->bundle[0].image[0]->imgName);
|
||||
diffuse->bundle[TB_SPECULARMAP] = specular->bundle[0];
|
||||
diffuse->materialInfo[0] = specular->materialInfo[0];
|
||||
diffuse->materialInfo[1] = specular->materialInfo[1];
|
||||
VectorCopy4(specular->specularScale, diffuse->specularScale);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2568,29 +2670,6 @@ static qboolean CollapseStagesToGLSL(void)
|
|||
}
|
||||
}
|
||||
|
||||
// insert default material info if needed
|
||||
for (i = 0; i < MAX_SHADER_STAGES; i++)
|
||||
{
|
||||
shaderStage_t *pStage = &stages[i];
|
||||
|
||||
if (!pStage->active)
|
||||
continue;
|
||||
|
||||
if (pStage->glslShaderGroup != tr.lightallShader)
|
||||
continue;
|
||||
|
||||
if ((pStage->glslShaderIndex & LIGHTDEF_LIGHTTYPE_MASK) == 0)
|
||||
continue;
|
||||
|
||||
if (!pStage->bundle[TB_SPECULARMAP].image[0] && r_specularMapping->integer)
|
||||
{
|
||||
if (!pStage->materialInfo[0])
|
||||
pStage->materialInfo[0] = r_baseSpecular->value;
|
||||
if (!pStage->materialInfo[1])
|
||||
pStage->materialInfo[1] = r_baseGloss->value;
|
||||
}
|
||||
}
|
||||
|
||||
return numStages;
|
||||
}
|
||||
|
||||
|
@ -3216,6 +3295,13 @@ shader_t *R_FindShader( const char *name, int lightmapIndex, qboolean mipRawImag
|
|||
shader.lightmapIndex = lightmapIndex;
|
||||
for ( i = 0 ; i < MAX_SHADER_STAGES ; i++ ) {
|
||||
stages[i].bundle[0].texMods = texMods[i];
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -3361,6 +3447,13 @@ qhandle_t RE_RegisterShaderFromImage(const char *name, int lightmapIndex, image_
|
|||
shader.lightmapIndex = lightmapIndex;
|
||||
for ( i = 0 ; i < MAX_SHADER_STAGES ; i++ ) {
|
||||
stages[i].bundle[0].texMods = texMods[i];
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
@ -449,7 +449,7 @@ static void DrawSkySide( struct image_s *image, const int mins[2], const int max
|
|||
|
||||
color[0] =
|
||||
color[1] =
|
||||
color[2] = (r_softOverbright->integer ? 1.0 : tr.identityLight) * backEnd.refdef.colorScale;
|
||||
color[2] = backEnd.refdef.colorScale;
|
||||
color[3] = 1.0f;
|
||||
GLSL_SetUniformVec4(sp, UNIFORM_BASECOLOR, color);
|
||||
|
||||
|
|
|
@ -203,6 +203,44 @@ Cvars for advanced material usage:
|
|||
0 - No. (default)
|
||||
1 - Yes.
|
||||
|
||||
r_baseSpecular - Set the specular reflectance of materials
|
||||
which don't include a specular map or
|
||||
use the specularReflectance keyword.
|
||||
0 - No.
|
||||
0.04 - Realistic. (default)
|
||||
1.0 - Ack.
|
||||
|
||||
r_baseGloss - Set the glossiness of materials which don't
|
||||
include a specular map or use the
|
||||
specularExponent keyword.
|
||||
0 - Rough.
|
||||
0.3 - Default.
|
||||
1.0 - Shiny.
|
||||
|
||||
r_baseNormalX - Set the scale of the X values from normal
|
||||
maps when the normalScale keyword is not
|
||||
used.
|
||||
-1 - Flip X.
|
||||
0 - Ignore X.
|
||||
1 - Normal X. (default)
|
||||
2 - Double X.
|
||||
|
||||
r_baseNormalY - Set the scale of the Y values from normal
|
||||
maps when the normalScale keyword is not
|
||||
used.
|
||||
-1 - Flip Y.
|
||||
0 - Ignore Y.
|
||||
1 - Normal Y. (default)
|
||||
2 - Double Y.
|
||||
|
||||
r_baseParallax - Sets the scale of the parallax effect for
|
||||
materials when the parallaxDepth keyword
|
||||
is not used.
|
||||
0 - No depth.
|
||||
0.01 - Pretty smooth.
|
||||
0.05 - Standard depth. (default)
|
||||
0.1 - Looks broken.
|
||||
|
||||
Cvars for image interpolation and generation:
|
||||
r_imageUpsample - Use interpolation to artifically increase
|
||||
the resolution of all textures. Looks good
|
||||
|
@ -362,6 +400,8 @@ Here's an example of a material stored in one, showing off some new features:
|
|||
{
|
||||
stage normalparallaxmap
|
||||
map textures/abandon/grass3_1024_n.png
|
||||
normalScale 1 1
|
||||
parallaxDepth 0.05
|
||||
}
|
||||
{
|
||||
stage specularmap
|
||||
|
@ -402,6 +442,15 @@ they mean:
|
|||
channel of the specular map was set to 0.5, then the shininess would be
|
||||
set to 8. Default 256.
|
||||
|
||||
normalScale <x> <y>
|
||||
- State the X and Y scales of the normal map. This is useful for increasing
|
||||
or decreasing the "strength" of the normal map, or entering negative values
|
||||
to flip the X and/or Y values. Default 1 1.
|
||||
|
||||
parallaxDepth <value>
|
||||
- State the maximum depth of the parallax map. This is a fairly sensitive
|
||||
value, and I recommend the default or lower. Default 0.05.
|
||||
|
||||
An important note is that normal and specular maps influence the diffuse map
|
||||
declared before them, so materials like this are possible:
|
||||
|
||||
|
|
Loading…
Reference in a new issue