| /*============================================================================= | |
| ModShadowCommon.usf: modulated shadow helper functions. | |
| Copyright 1998-2008 Epic Games, Inc. All Rights Reserved. | |
| =============================================================================*/ | |
| /** color to modulate shadowed areas on screen */ | |
| float4 ShadowModulateColor; | |
| /** world position of light casting a shadow. Note: w = 1.0 / Radius */ | |
| float4 LightPosition; | |
| /** needed to get world positions from deferred scene depth values */ | |
| float4x4 ScreenToWorld; | |
| /** 1.0 if attenuation is needed, 0.0 otherwise */ | |
| float bAllowAttenuation; | |
| /** attenuation exponent for light casting a shadow */ | |
| float FalloffExponent; | |
| /** spot light direction vector in world space */ | |
| float3 SpotDirection; | |
| /** spot light cone cut-off angles */ | |
| float2 SpotAngles; | |
| float ShadowAttenuation(float4 ScreenPositionVec,float SceneDepth) | |
| { | |
| // derive world position from scene depth | |
| float4 WorldPosition = MulMatrix(ScreenToWorld,float4((ScreenPositionVec.xy/ScreenPositionVec.w)*SceneDepth,SceneDepth,1)); | |
| // vector from world position to light | |
| float4 WorldLightVector = float4((LightPosition.xyz - WorldPosition.xyz),0) * LightPosition.w; | |
| // mul world vector by 1/radius to get distance attenuation | |
| float Attenuation = pow( | |
| saturate(1.0f - dot(WorldLightVector,WorldLightVector)), | |
| FalloffExponent | |
| ); | |
| // radial attenuation based on inner/outer cone angles for spot lights | |
| Attenuation *= Square(clamp((dot(normalize((float3)WorldLightVector.xyz), -SpotDirection) - SpotAngles.x) * SpotAngles.y,0,1)); | |
| // attenuation result as a percentage of world light vector length to light radius | |
| return Attenuation; | |
| } | |
Xet Storage Details
- Size:
- 2.02 kB
- Xet hash:
- 820d7efccb7dde8e8d97f8f4325472e8d3776285aba75b5ba2a4a669b0904925
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.