MCPcopy Create free account
hub / github.com/TheRealMJP/DeferredTexturing / CalcLighting

Function CalcLighting

SampleFramework12/v1.00/Graphics/BRDF.h:68–87  ·  view source on GitHub ↗

Computes the radiance reflected off a surface towards the eye given the differential irradiance from a given direction

Source from the content-addressed store, hash-verified

66// Computes the radiance reflected off a surface towards the eye given
67// the differential irradiance from a given direction
68inline Float3 CalcLighting(const Float3& normal, const Float3& lightIrradiance,
69 const Float3& lightDir, const Float3& diffuseAlbedo, const Float3& position,
70 const Float3& cameraPos, float roughness, bool includeSpecular, Float3 specAlbedo)
71{
72 Float3 lighting = diffuseAlbedo * InvPi;
73
74 if(includeSpecular && Float3::Dot(normal, lightDir) > 0.0f)
75 {
76 Float3 view = Float3::Normalize(cameraPos - position);
77 const float nDotV = Saturate(Float3::Dot(normal, view));
78 Float3 h = Float3::Normalize(view + lightDir);
79
80 Float3 fresnel = Fresnel(specAlbedo, h, lightDir);
81
82 float specular = GGX_Specular(roughness, normal, h, view, lightDir);
83 lighting += specular * fresnel;
84 }
85
86 return lighting * lightIrradiance;
87}
88
89}

Callers

nothing calls this directly

Calls 3

SaturateFunction · 0.85
FresnelFunction · 0.85
GGX_SpecularFunction · 0.85

Tested by

no test coverage detected