// PsCommon.hlsl uniform float4 g_vScreenSpaceOffset[4] : register( c0 ); uniform float4 g_vConstantColor; uniform float4 g_vAmbientColor ; uniform float4 g_vDiffuseColor; uniform float g_fMiscFloat; uniform float g_fContrast; uniform float g_fBrightness; uniform float g_fSaturate; uniform float g_fEdgeSize; uniform float4 g_vContrastThresh; #define g_fDiffuseMapIntensity g_vDiffuseColor.a uniform float g_fDistanceInShadowScale; uniform float4 g_vSpecularColor; uniform float4 g_vForcedColor; uniform float4 g_vBlendColor; // per-pixel lighting only uses directional lights #if (DIR_LIGHT_COUNT > 0) uniform float4 g_avLightColor[DIR_LIGHT_COUNT]; uniform float4 g_avLightSpecularColor[DIR_LIGHT_COUNT]; #endif uniform float4 g_vLightingConstants; #define g_fSpecularShininess g_vLightingConstants.x #define g_fNormalBias g_vLightingConstants.y #define g_fParallaxScale g_vLightingConstants.z #define g_fParallaxBias g_vLightingConstants.w uniform float4 g_vOtherConstants; #define g_fUVDistortionOffset g_vOtherConstants.x #define g_fUVDistortionScale g_vOtherConstants.y #define g_fDarkBorderKonst1 g_vOtherConstants.z #define g_fDarkBorderKonst2 g_vOtherConstants.w uniform float4 g_vDarkBorderColor; uniform float4 g_fAlphaTestThreshold; // Fog uniform float4 g_vFogColor; uniform float4 g_vWParam; // useful functions float SampleSpecularMap( sampler2D _sampler, float2 _texCoord ) { return tex2D(_sampler, _texCoord).a; } // pack a float32 into an interger32 // ref: http://www.gamedev.net/community/forums/topic.asp?topic_id=442138 float4 EncodeFloat(float v) { const float4 bitSh = float4(256*256*256, 256*256, 256, 1); const float4 bitMsk = float4(0, 1.0/256.0, 1.0/256.0, 1.0/256.0); float4 comp; comp = v * bitSh; comp = frac(comp); comp -= comp.xxyz * bitMsk; return comp; } // unpack an integer32 to get a float32 float DecodeFloat(float4 v) { const float4 bitShifts = float4(1.0/(256.0*256.0*256.0), 1.0/(256.0*256.0), 1.0/256.0, 1); return dot(v, bitShifts); }