/*============================================================================= SFXShadowedPointLightVertexShader.hlsl: Point light vertex shader. Copyright 1998-2007 Epic Games, Inc. All Rights Reserved. =============================================================================*/ #define NEEDS_LIGHTMAP_COORDINATE STATICLIGHTING_TEXTUREMASK #include "Common.usf" #include "Material.usf" #include "VertexFactory.usf" float4x4 ShadowViewProjection; float4 LightPositionAndInvRadius; // w = 1.0 / Radius void Main( FVertexFactoryInput Input, #if STATICLIGHTING_VERTEXMASK float LightMask : BLENDWEIGHT0, #endif out FVertexFactoryInterpolants OutFactoryInterpolants, out half3 OutTangentLightVector : TEXCOORD4, out half4 OutWorldLightVector : TEXCOORD5, out half4 OutCameraVectorOrVertexColor : TEXCOORD6, out float4 OutPixelPosition : TEXCOORD7, out float4 OutShadowPos : TEXCOORD8, out float4 OutPosition : SV_Position ) { FVertexFactoryIntermediates VFIntermediates = GetVertexFactoryIntermediates(Input); float4 WorldPosition = VertexFactoryGetWorldPosition(Input, VFIntermediates); float3x3 TangentBasis = VertexFactoryGetTangentBasis(Input, VFIntermediates); FMaterialVertexParameters VertexParameters = GetMaterialVertexParameters(Input, VFIntermediates, WorldPosition.xyz, TangentBasis); // Isolate instructions used for world position offset on xbox 360, // As these cause the optimizer to generate different position calculating instructions in each pass, resulting in self-z-fighting. // This is only necessary for shaders used in passes that have depth testing enabled. ISOLATE { WorldPosition.xyz += GetMaterialWorldPositionOffset(VertexParameters); } OutPosition = MulMatrix(ViewProjectionMatrix,WorldPosition); OutFactoryInterpolants = VertexFactoryGetInterpolants(Input, VFIntermediates); #if WORLD_POS OutPixelPosition = WorldPosition; #else OutPixelPosition = OutPosition; #endif // Compute the position in light space for the shadow map OutShadowPos = MulMatrix( ShadowViewProjection, WorldPosition ); OutCameraVectorOrVertexColor = 1; #if PER_PIXEL_CAMERA_VECTOR OutCameraVectorOrVertexColor = VertexFactoryGetVertexColor( Input, VFIntermediates ); #else OutCameraVectorOrVertexColor.xyz = VertexFactoryWorldToTangentSpace(Input,VFIntermediates,TangentBasis,CameraPosition.xyz - WorldPosition.xyz * CameraPosition.w); #endif OutTangentLightVector = VertexFactoryWorldToTangentSpace(Input,VFIntermediates,TangentBasis,LightPositionAndInvRadius.xyz - WorldPosition.xyz); OutWorldLightVector = half4((LightPositionAndInvRadius.xyz - WorldPosition.xyz) * LightPositionAndInvRadius.w,0); #if STATICLIGHTING_VERTEXMASK OutWorldLightVector.w = LightMask; #endif }