microsoft / DirectXTK

The DirectX Tool Kit (aka DirectXTK) is a collection of helper classes for writing DirectX 11.x code in C++
https://walbourn.github.io/directxtk/
MIT License
2.57k stars 511 forks source link

ComputeLights specular falloff improvement #51

Closed justinsaunders closed 8 years ago

justinsaunders commented 8 years ago

In Lighting.fxh::ComputeLights(), the specular intensity currently falls of only as a term of dotH and a step() of dotL (diffuse "angle"). While correct, this results in sudden drop when dotL > 90. image

A solution is to modulate the specular term further by dotL so we don't see the sharp edge

    float3 zeroL = step(0, dotL);
    float3 diffuse  = zeroL * dotL;
    float3 specular = pow(max(dotH, 0) * zeroL, SpecularPower) * dotL;
                                                              ^^^^^^^^

Output: image

walbourn commented 8 years ago

Fix submitted to DirectXTK and DirectXTK12