Advertisement
Guest User

Untitled

a guest
Aug 21st, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. inline half calculateBRDF(in SurfaceData data, in half NdotH, in half LdotH)
  2. {
  3.     half d = NdotH * NdotH * data.roughness2MinusOne + 1.00001h;
  4.  
  5.     half LdotH2 = LdotH * LdotH;
  6.     half specularTerm = data.roughness2 / ((d * d) * max(0.1h, LdotH2) * data.normalizationTerm);
  7.  
  8.     return specularTerm;
  9. }
  10.  
  11. inline half3 applyBRDF(in SurfaceData data, in half3 lightPos, in half3 lightColor)
  12. {
  13.     half3 L = normalize(lightPos);
  14.     half3 H = normalize(data.view + L);
  15.     
  16.     half NdotH = saturate(dot(data.normal, H));
  17.     half LdotH = saturate(dot(L, H));
  18.  
  19.     half3 radiance = lightColor * diffuse(L, data.normal);
  20.     half brdf = calculateBRDF(data, NdotH, LdotH);
  21.  
  22.     return (brdf * data.specular + data.diffuse) * radiance;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement