#ifndef SLOAD_H #define SLOAD_H #include "common.h" #ifdef MSAA_ALPHATEST_DX10_1 #if MSAA_SAMPLES == 2 static const float2 MSAAOffsets[2] = { float2(4,4), float2(-4,-4) }; #endif #if MSAA_SAMPLES == 4 static const float2 MSAAOffsets[4] = { float2(-2,-6), float2(6,-2), float2(-6,2), float2(2,6) }; #endif #if MSAA_SAMPLES == 8 static const float2 MSAAOffsets[8] = { float2(1,-3), float2(-1,3), float2(5,1), float2(-3,-5), float2(-5,5), float2(-7,-1), float2(3,7), float2(7,-7) }; #endif #endif // MSAA_ALPHATEST_DX10_1 ////////////////////////////////////////////////////////////////////////////////////////// // Bumped surface loader // ////////////////////////////////////////////////////////////////////////////////////////// struct surface_bumped { float4 base; float3 normal; float gloss; float height; }; float4 tbase( float2 tc ) { return s_base.Sample( smp_base, tc); } #if defined(ALLOW_STEEPPARALLAX) && defined(USE_STEEPPARALLAX) static const float fParallaxStartFade = 8.0f; static const float fParallaxStopFade = 12.0f; void UpdateTC( inout p_bumped I) { if (I.position.z < fParallaxStopFade) { const float maxSamples = 25; const float minSamples = 5; const float fParallaxOffset = -0.013; float3 eye = mul (float3x3(I.M1.x, I.M2.x, I.M3.x, I.M1.y, I.M2.y, I.M3.y, I.M1.z, I.M2.z, I.M3.z), -I.position.xyz); eye = normalize(eye); // Calculate number of steps float nNumSteps = lerp( maxSamples, minSamples, eye.z ); float fStepSize = 1.0 / nNumSteps; float2 vDelta = eye.xy * fParallaxOffset*1.2; float2 vTexOffsetPerStep = fStepSize * vDelta; // Prepare start data for cycle float2 vTexCurrentOffset = I.tcdh; float fCurrHeight = 0.0; float fCurrentBound = 1.0; for( int i=0; i