mirror of
https://github.com/alliedmodders/hl2sdk.git
synced 2025-09-19 12:06:07 +08:00
Fixed conflict between min/max macros and std::min/max when using GCC >= 4.2.
This commit is contained in:
@ -92,7 +92,7 @@ HDR_PS_OUTPUT main( PS_INPUT i ) : COLOR
|
||||
// FIXME: It's unclear that we want to do this for cheap water
|
||||
// but the code did this previously and I didn't want to change it
|
||||
HALF flDotResult = dot( worldSpaceEye, worldSpaceNormal );
|
||||
flDotResult = 1.0f - max( 0.0f, flDotResult );
|
||||
flDotResult = 1.0f - MAX( 0.0f, flDotResult );
|
||||
|
||||
HALF flFresnelFactor = flDotResult * flDotResult;
|
||||
flFresnelFactor *= flFresnelFactor;
|
||||
|
@ -227,8 +227,8 @@ HDR_PS_OUTPUT main( PS_INPUT i ) : COLOR
|
||||
float minb=modt.g-modt.r;
|
||||
float maxb=modt.g+modt.r;
|
||||
#else
|
||||
float minb=max(0,modt.g-modt.r);
|
||||
float maxb=min(1,modt.g+modt.r);
|
||||
float minb=MAX(0,modt.g-modt.r);
|
||||
float maxb=MIN(1,modt.g+modt.r);
|
||||
#endif
|
||||
blendfactor=smoothstep(minb,maxb,blendfactor);
|
||||
#endif
|
||||
|
@ -174,7 +174,7 @@ HDR_PS_OUTPUT main( PS_INPUT i ) : COLOR
|
||||
// 0.125-1.0 = selfillum*(1+alpha-0.125)*8 (over bright glows)
|
||||
HALF3 selfIllumComponent = g_SelfIllumTint * albedo;
|
||||
half Adj_Alpha=8*envmapMaskTexel.a;
|
||||
diffuseComponent=( max( 0, 1-Adj_Alpha ) * diffuseComponent) + Adj_Alpha * selfIllumComponent;
|
||||
diffuseComponent=( MAX( 0, 1-Adj_Alpha ) * diffuseComponent) + Adj_Alpha * selfIllumComponent;
|
||||
#else
|
||||
if( bSelfIllum )
|
||||
{
|
||||
|
@ -61,7 +61,7 @@ HALF3 CalcReflectionVectorUnnormalized( HALF3 normal, HALF3 eyeVector )
|
||||
float3 HuePreservingColorClamp( float3 c )
|
||||
{
|
||||
// Get the max of all of the color components and a specified maximum amount
|
||||
float maximum = max( max( c.x, c.y ), max( c.z, 1.0f ) );
|
||||
float maximum = MAX( MAX( c.x, c.y ), MAX( c.z, 1.0f ) );
|
||||
|
||||
return (c / maximum);
|
||||
}
|
||||
@ -69,7 +69,7 @@ float3 HuePreservingColorClamp( float3 c )
|
||||
HALF3 HuePreservingColorClamp( HALF3 c, HALF maxVal )
|
||||
{
|
||||
// Get the max of all of the color components and a specified maximum amount
|
||||
float maximum = max( max( c.x, c.y ), max( c.z, maxVal ) );
|
||||
float maximum = MAX( MAX( c.x, c.y ), MAX( c.z, maxVal ) );
|
||||
return (c * ( maxVal / maximum ) );
|
||||
}
|
||||
|
||||
@ -134,14 +134,14 @@ float4 CompressHDR( float3 input )
|
||||
{
|
||||
// FIXME: want to use min so that we clamp to white, but what happens if we
|
||||
// have an albedo component that's less than 1/MAX_HDR_OVERBRIGHT?
|
||||
// float fMax = max( max( color.r, color.g ), color.b );
|
||||
// float fMax = MAX( MAX( color.r, color.g ), color.b );
|
||||
float4 output;
|
||||
float fMax = min( min( input.r, input.g ), input.b );
|
||||
float fMax = MIN( MIN( input.r, input.g ), input.b );
|
||||
if( fMax > 1.0f )
|
||||
{
|
||||
float oofMax = 1.0f / fMax;
|
||||
output.rgb = oofMax * input.rgb;
|
||||
output.a = min( fMax / MAX_HDR_OVERBRIGHT, 1.0f );
|
||||
output.a = MIN( fMax / MAX_HDR_OVERBRIGHT, 1.0f );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -182,7 +182,7 @@ float CalcWaterFogAlpha( const float flWaterZ, const float flEyePosZ, const floa
|
||||
// if flDepthFromWater < 0, then set it to 0
|
||||
// This is the equivalent of moving the vert to the water surface if it's above the water surface
|
||||
// We'll do this with the saturate at the end instead.
|
||||
// flDepthFromWater = max( 0.0f, flDepthFromWater );
|
||||
// flDepthFromWater = MAX( 0.0f, flDepthFromWater );
|
||||
|
||||
// Calculate the ratio of water fog to regular fog (ie. how much of the distance from the viewer
|
||||
// to the vert is actually underwater.
|
||||
@ -356,7 +356,7 @@ float2 CalcParallaxedTexCoord( float2 inTexCoord, float2 vParallax, float3 vNorm
|
||||
float sh4 = (tex2D( sNormalMap, texSampleBase + inXY * 0.22 ).w - sh0 - 0.22 ) * 12 * fShadowSoftening;
|
||||
|
||||
// Compute the actual shadow strength:
|
||||
float fShadow = 1 - max( max( max( max( max( max( shA, sh9 ), sh8 ), sh7 ), sh6 ), sh5 ), sh4 );
|
||||
float fShadow = 1 - MAX( MAX( MAX( MAX( MAX( MAX( shA, sh9 ), sh8 ), sh7 ), sh6 ), sh5 ), sh4 );
|
||||
|
||||
cResultColor.rgb *= fShadow * 0.6 + 0.4;
|
||||
}
|
||||
@ -379,8 +379,8 @@ float2 CalcParallaxedTexCoord( float2 inTexCoord, float2 vParallax, float3 vNorm
|
||||
float4 RGBtoHSL( float4 inColor )
|
||||
{
|
||||
float h, s;
|
||||
float flMax = max( inColor.r, max( inColor.g, inColor.b ) );
|
||||
float flMin = min( inColor.r, min( inColor.g, inColor.b ) );
|
||||
float flMax = MAX( inColor.r, MAX( inColor.g, inColor.b ) );
|
||||
float flMin = MIN( inColor.r, MIN( inColor.g, inColor.b ) );
|
||||
|
||||
float l = (flMax + flMin) / 2.0f;
|
||||
|
||||
|
@ -119,7 +119,7 @@ float3 DiffuseTerm( const bool bHalfLambert, const float3 worldNormal, const flo
|
||||
}
|
||||
else
|
||||
{
|
||||
fResult = max( 0.0f, NDotL ); // Saturate pure Lambertian term
|
||||
fResult = MAX( 0.0f, NDotL ); // Saturate pure Lambertian term
|
||||
}
|
||||
|
||||
if ( bDoDirectionalDiffuse )
|
||||
|
@ -185,7 +185,7 @@ float WaterFog( const float3 worldPos, const float3 projPos )
|
||||
// if $tmp.x < 0, then set it to 0
|
||||
// This is the equivalent of moving the vert to the water surface if it's above the water surface
|
||||
|
||||
tmp.x = max( cZero, tmp.x );
|
||||
tmp.x = MAX( cZero, tmp.x );
|
||||
|
||||
// $tmp.w = $tmp.x / $tmp.y
|
||||
tmp.w = tmp.x / tmp.y;
|
||||
@ -392,7 +392,7 @@ float3 SpotLight( const float3 worldPos, const float3 worldNormal, int lightNum,
|
||||
{
|
||||
// compute n dot l
|
||||
nDotL = dot( worldNormal, lightDir );
|
||||
nDotL = max( cZero, nDotL );
|
||||
nDotL = MAX( cZero, nDotL );
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -404,9 +404,9 @@ float3 SpotLight( const float3 worldPos, const float3 worldNormal, int lightNum,
|
||||
// compute angular attenuation
|
||||
float flCosTheta = dot( cLightInfo[lightNum].dir, -lightDir );
|
||||
float flAngularAtten = (flCosTheta - cLightInfo[lightNum].spotParams.z) * cLightInfo[lightNum].spotParams.w;
|
||||
flAngularAtten = max( cZero, flAngularAtten );
|
||||
flAngularAtten = MAX( cZero, flAngularAtten );
|
||||
flAngularAtten = pow( flAngularAtten, cLightInfo[lightNum].spotParams.x );
|
||||
flAngularAtten = min( cOne, flAngularAtten );
|
||||
flAngularAtten = MIN( cOne, flAngularAtten );
|
||||
|
||||
return cLightInfo[lightNum].color * flDistanceAttenuation * flAngularAtten * nDotL;
|
||||
}
|
||||
@ -443,7 +443,7 @@ float3 PointLight( const float3 worldPos, const float3 worldNormal, int lightNum
|
||||
{
|
||||
// compute n dot l
|
||||
NDotL = dot( worldNormal, lightDir );
|
||||
NDotL = max( cZero, NDotL );
|
||||
NDotL = MAX( cZero, NDotL );
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -463,7 +463,7 @@ float3 DirectionalLight( const float3 worldNormal, int lightNum, bool bHalfLambe
|
||||
{
|
||||
// compute n dot l
|
||||
NDotL = dot( worldNormal, -cLightInfo[lightNum].dir );
|
||||
NDotL = max( cZero, NDotL );
|
||||
NDotL = MAX( cZero, NDotL );
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -670,9 +670,9 @@ float3 Compute_SpotLightVertexColor( const float3 worldPos, const float3 worldNo
|
||||
|
||||
float flCosTheta = dot( cLightInfo[lightNum].dir, -lightDir );
|
||||
float flAngularAtten = (flCosTheta - cLightInfo[lightNum].spotParams.z) * cLightInfo[lightNum].spotParams.w;
|
||||
flAngularAtten = max( 0.0f, flAngularAtten );
|
||||
flAngularAtten = MAX( 0.0f, flAngularAtten );
|
||||
flAngularAtten = pow( flAngularAtten, cLightInfo[lightNum].spotParams.x );
|
||||
flAngularAtten = min( 1.0f, flAngularAtten );
|
||||
flAngularAtten = MIN( 1.0f, flAngularAtten );
|
||||
|
||||
return flDistanceAttenuation * flAngularAtten * cLightInfo[lightNum].color;
|
||||
}
|
||||
|
Reference in New Issue
Block a user