/*============================================================================= PointLightVertexShader.hlsl: Point light vertex shader. Copyright 1998-2010 Epic Games, Inc. All Rights Reserved. =============================================================================*/ #define NEEDS_LIGHTMAP_COORDINATE STATICLIGHTING_TEXTUREMASK #include "Common.usf" #include "Material.usf" #include "VertexFactory.usf" float4 LightPositionAndInvRadius; // w = 1.0 / Radius void Main( FVertexFactoryInput Input, #if STATICLIGHTING_VERTEXMASK float LightMask : BLENDWEIGHT0, #endif out FVertexFactoryInterpolants OutFactoryInterpolants, // BIOSTART - September 15, 2010 - Wihlidal, Graham - PS3 Fragment and Vertex Shader Optimizations out half3 OutTangentLightVector : TEXCOORD4, out half4 OutWorldLightVector : TEXCOORD5, out half4 OutCameraVectorOrVertexColor : TEXCOORD6, // BIOEND out float4 OutPixelPosition : TEXCOORD7, 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 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); // BIOSTART - September 15, 2010 - Wihlidal, Graham - PS3 Fragment and Vertex Shader Optimizations OutWorldLightVector = half4((LightPositionAndInvRadius.xyz - WorldPosition.xyz) * LightPositionAndInvRadius.w,0); // BIOEND #if STATICLIGHTING_VERTEXMASK OutWorldLightVector.w = LightMask; #endif }