You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
28 lines
966 B
Plaintext
28 lines
966 B
Plaintext
// Copyright 1998-2014 Epic Games, Inc. All Rights Reserved.
|
|
|
|
/*=============================================================================
|
|
IESLightProfiles.usf: Common shader code for IES light profiles
|
|
=============================================================================*/
|
|
|
|
// IES light profiles
|
|
Texture2D IESTexture;
|
|
SamplerState IESTextureSampler;
|
|
|
|
// Apply 1D IES light profile texture
|
|
float ComputeLightProfileMultiplier(float3 WorldPosition, float3 LightPosition, float3 LightDirection)
|
|
{
|
|
#if USE_IES_PROFILE
|
|
float3 NegLightDirection = normalize(WorldPosition - LightPosition);
|
|
|
|
// -1..1
|
|
float DotProd = dot(NegLightDirection, LightDirection);
|
|
// -PI..PI (this distortion could be put into the texture but not without quality loss or more memory)
|
|
float Angle = asin(DotProd);
|
|
// 0..1
|
|
float NormAngle = Angle / PI + 0.5f;
|
|
|
|
return Texture2DSampleLevel(IESTexture, IESTextureSampler, float2(NormAngle, 0), 0).r;
|
|
#else
|
|
return 1.0f;
|
|
#endif
|
|
} |