More efficient and smoother lighting than cubemap.
-
SkyLight.h > enum class Modes
(after CustomTexture = 1,)
add
HemisphereApproximate = 2, -
Config.h > ShaderLightData
(after float RadiusInv;)
change
float Dummy0;
to
uint32 Flags; -
RenderList.cpp > RenderSkyLightData::SetShaderData
(after data.RadiusInv = 1.0f / Radius;)
add
uint32 flags = 0;
if (nullptr==Image) flags |= 1; //Hemisphere Approximate
data.Flags = flags; -
LightingCommon.hlsl > struct LightData
(after float RadiusInv;)
change
float Dummy0;
to
uint Flags; -
Lighting.hlsl > GetSkyLightLighting
change
float3 diffuseLookup = ibl.SampleLevel(SamplerLinearClamp, uvw, mip).rgb * lightData.Color.rgb;
tofloat3 diffuseLookup;
BRANCH
if ((lightData.Flags & 0x1) != 0) //Hemisphere Approximate
diffuseLookup = lightData.Color.rgb * saturate(gBuffer.Normal.y * 0.7 + 0.3);
else
diffuseLookup = ibl.SampleLevel(SamplerLinearClamp, uvw, mip).rgb * lightData.Color.rgb;
// saturate(gBuffer.Normal.y * 0.7 + 0.3) map [-1,1] to [0,1]
// Coefficients( 0.7, 0.3 ) can be modified to adjust the lighting curve.
