| /*============================================================================= | |
| BasePassPixelShader.usf: Base pass pixel shader | |
| Copyright 1998-2008 Epic Games, Inc. All Rights Reserved. | |
| =============================================================================*/ | |
| /* If simple lighting is enabled then the base pass shader will just be Diffuse * LightMap + Emissive */ | |
| half3 UpperSkyColor; | |
| half3 LowerSkyColor; | |
| // SkyFactor and AmbientColor are constants if we assume SHOW_Lighting to be always set. We make the assumption that on console | |
| // performance is more important than being able to toggle this flag and therefore use special shortcut. | |
| static const half3 AmbientColor = 0; | |
| static const half SkyFactor = 1; | |
| half4 AmbientColorAndSkyFactor; | |
| static const half3 AmbientColor = AmbientColorAndSkyFactor.rgb; | |
| static const half SkyFactor = AmbientColorAndSkyFactor.a; | |
| //Directional lightmaps use 3 samplers here so the most a material can use is 13 | |
| //This is enforced by the material compiler through MAX_ME_PIXELSHADER_SAMPLERS | |
| sampler2D LightMapTextures[NUM_LIGHTMAP_COEFFICIENTS]; | |
| // The light-map scale array is a set of float4s so it can be set as a contiguous chunk regardless of platform shader constant alignment. | |
| float4 LightMapScale[NUM_LIGHTMAP_COEFFICIENTS]; | |
| //NV-begin | |
| float4 LightMapResolution[NUM_LIGHTMAP_COEFFICIENTS]; | |
| sampler2D BSplineTexture; | |
| float3 tex2DBicubic(sampler2D tex, float4 Res, float2 uv) | |
| { | |
| float x = uv.x * Res.x; | |
| float y = uv.y * Res.y; | |
| // Assuming d3d9. | |
| x -= 0.5f; | |
| y -= 0.5f; | |
| float px = floor(x); | |
| float py = floor(y); | |
| float fx = x - px; | |
| float fy = y - py; | |
| float4 vX = tex2D( BSplineTexture, float2(fx, 0.0f) ); | |
| float4 vY = tex2D( BSplineTexture, float2(fy, 0.0f) ); | |
| float2 hX = vX.xy; | |
| float2 gX = vX.zw; | |
| float2 hY = vY.xy; | |
| float2 gY = vY.zw; | |
| float2 InvRes = Res.zw; | |
| float3 r = gY.x * ( gX.x * tex2D(tex, float2(px + hX.x, py + hY.x) * InvRes) + | |
| gX.y * tex2D(tex, float2(px + hX.y, py + hY.x) * InvRes) ) + | |
| gY.y * ( gX.x * tex2D(tex, float2(px + hX.x, py + hY.y) * InvRes) + | |
| gX.y * tex2D(tex, float2(px + hX.y, py + hY.y) * InvRes) ); | |
| return r; | |
| } | |
| //NV-end | |
| void Main( | |
| FVertexFactoryInterpolants Interpolants, | |
| #if VERTEX_LIGHTMAP | |
| //for vertex-lightmapped translucency we are out of interpolators to pass in the vertex fog | |
| //so it must be packed in the w of other interpolators | |
| float4 LightMapA_FogR : TEXCOORD2, | |
| float4 LightMapB_FogG : TEXCOORD3, | |
| float4 LightMapC_FogB : TEXCOORD4, | |
| #else | |
| #if SIMPLE_VERTEX_LIGHTMAP | |
| float3 LightMapA : TEXCOORD2, | |
| #endif | |
| //for texture-lightmapped translucency we can pass the vertex fog in its own interpolator | |
| #if NEEDS_BASEPASS_FOGGING | |
| float4 VertexFog : TEXCOORD4, | |
| #endif | |
| #endif | |
| float4 PixelPosition : TEXCOORD5, | |
| float4 CameraVector_FogA: TEXCOORD6, | |
| #if !MATERIAL_LIGHTINGMODEL_UNLIT | |
| float3 SkyVector : TEXCOORD7, | |
| #endif | |
| OPTIONAL_FacingSign | |
| out float4 OutColor : COLOR0 | |
| ) | |
| { | |
| FMaterialParameters MaterialParameters = GetMaterialParameters(Interpolants); | |
| //Don't flip the normal for backfaces of two-sided materials used with this shader. | |
| //As a result, the backfaces will have the same lighting as the frontfaces, instead of being mostly black. | |
| CalcMaterialParameters(MaterialParameters,FacingSign,CameraVector_FogA.xyz,PixelPosition,half3(0,0,1),false); | |
| //Clip if the blend mode requires it. | |
| GetMaterialClipping(MaterialParameters); | |
| half3 Color = GetMaterialEmissive(MaterialParameters); | |
| static const half3x3 LightMapBasis = half3x3( | |
| half3( 0.0f, -1.0f / sqrt(2.0f), +1.0f / sqrt(2.0f)), | |
| half3( sqrt(6.0f) / 3.0f, -1.0f / sqrt(6.0f), -1.0f / sqrt(6.0f)), | |
| half3( 1.0f / sqrt(3.0f), 1.0f / sqrt(3.0f), 1.0f / sqrt(3.0f)) | |
| ); | |
| half3 LightMapNormal = mul(MaterialParameters.TangentNormal,LightMapBasis); | |
| half3 LightMapReflectionVector = mul(MaterialParameters.TangentReflectionVector,LightMapBasis); | |
| half3 TwoSidedLightingMask = GetMaterialTwoSidedLightingMask(MaterialParameters); | |
| TwoSidedLightingMask = 1; | |
| half3 DiffuseTransferCoefficients = | |
| pow( | |
| saturate(LightMapNormal) * saturate(LightMapNormal), | |
| GetMaterialDiffusePower(MaterialParameters) | |
| ) * (1 - TwoSidedLightingMask) + TwoSidedLightingMask; | |
| half3 SpecularTransferCoefficients = | |
| pow( | |
| saturate(LightMapReflectionVector), | |
| GetMaterialSpecularPower(MaterialParameters) + 1 | |
| ) * (1 - TwoSidedLightingMask); | |
| half3 VertexLightMap[3] = { LightMapA_FogR.xyz, LightMapB_FogG.xyz, LightMapC_FogB.xyz }; | |
| half3 VertexLightMap[1] = { LightMapA }; | |
| half3 LightTransfer = 0; | |
| UNROLL | |
| for(int CoefficientIndex = 0;CoefficientIndex < NUM_LIGHTMAP_COEFFICIENTS;CoefficientIndex++) | |
| { | |
| // Dice-begin: Henrik - doing better sRGB here for lightmaps than the xenon hardware (removed the hardware sRGB lookup on lightmaps) | |
| // note that this is beeing done AFTER hardware interpolation, since the conversion is a power, doing this here is not equivalent (but probably visually OK) | |
| half3 LightMap = tex2D(LightMapTextures[CoefficientIndex],GetLightMapCoordinate(Interpolants)).rgb; | |
| LightMap = pow((LightMap+0.055)/(1.055),2.4); | |
| LightMap = LightMap * LightMapScale[CoefficientIndex].rgb; | |
| //NV-begin | |
| half3 LightMap = tex2DBicubic(LightMapTextures[CoefficientIndex], LightMapResolution[CoefficientIndex], GetLightMapCoordinate(Interpolants)).rgb * LightMapScale[CoefficientIndex].rgb; | |
| half3 LightMap = tex2D(LightMapTextures[CoefficientIndex],GetLightMapCoordinate(Interpolants)).rgb * LightMapScale[CoefficientIndex].rgb; | |
| //NV-end | |
| // Dice-end | |
| half3 LightMap = VertexLightMap[CoefficientIndex]; | |
| half3 LightMap = 0; | |
| MaterialParameters.TangentLightVector = LightMapBasis[CoefficientIndex]; | |
| LightTransfer += LightMap * GetMaterialCustomLighting(MaterialParameters); | |
| LightTransfer += pow(LightMap,GetMaterialDiffusePower(MaterialParameters)) * | |
| GetMaterialDiffuseColorNormalized(MaterialParameters); | |
| LightTransfer += LightMap * DiffuseTransferCoefficients[CoefficientIndex] * GetMaterialDiffuseColorNormalized(MaterialParameters); | |
| LightTransfer += LightMap * SpecularTransferCoefficients[CoefficientIndex] * GetMaterialSpecularColor(MaterialParameters); | |
| } | |
| Color += LightTransfer; | |
| Color += GetMaterialHemisphereLightTransferFull(MaterialParameters,normalize(SkyVector),UpperSkyColor,LowerSkyColor) * SkyFactor; | |
| Color += GetMaterialDiffuseColor(MaterialParameters) * AmbientColor; | |
| half4 Fog; | |
| //fog was stored in the .w of each interpolator | |
| Fog = half4(LightMapA_FogR.w, LightMapB_FogG.w, LightMapC_FogB.w, CameraVector_FogA.w); | |
| Fog = VertexFog; | |
| half Opacity = GetMaterialOpacity(MaterialParameters); | |
| OutColor = MaterialGammaCorrect(half4(Color * Fog.a + Fog.rgb, Opacity)); | |
| OutColor = RETURN_COLOR(OutColor); | |
| OutColor = MaterialGammaCorrect(half4(Color * Fog.a * Opacity, 0.0f)); | |
| OutColor = RETURN_COLOR(AccumulateSceneColor(OutColor)); | |
| // RETURN_COLOR not needed with modulative blending | |
| OutColor = MaterialGammaCorrect(half4(Color, Opacity)); | |
| // Output clip space w in scene color alpha | |
| OutColor = RETURN_COLOR(MaterialGammaCorrect(float4(Color,MaterialParameters.ScreenPosition.w))); | |
| } | |
Xet Storage Details
- Size:
- 8.92 kB
- Xet hash:
- 9ec1875d89ff7c8b3c75cb705666003a5b3691f8815d6266624ac625634b934a
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.