#ifndef SLOAD_H #define SLOAD_H #include "common.h" ////////////////////////////////////////////////////////////////////////////////////////// // Bumped surface loader // ////////////////////////////////////////////////////////////////////////////////////////// struct surface_bumped { half4 base; half3 normal; half gloss; half height; }; float4 tbase( float2 tc ) { return tex2D( s_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