1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-01 17:36:21 +03:00
occt/resources/Shaders/PBRIllumination.glsl
Pasukhin Dmitry df4b931988
Configuration - Resource structure reorganization #429
Reorganized resources to keep source part in src and real-time scripts in resource folder.
For the installation result no changes, still installed to src for windows.
2025-03-18 22:54:43 +00:00

29 lines
1.3 KiB
GLSL

//! Calculates direct illumination using Cook-Torrance BRDF.
vec3 occPBRIllumination (in vec3 theView,
in vec3 theLight,
in vec3 theNormal,
in vec4 theBaseColor,
in float theMetallic,
in float theRoughness,
in float theIOR,
in vec3 theLightColor,
in float theLightIntensity)
{
vec3 aHalf = normalize (theView + theLight);
float aCosVH = max(dot(theView, aHalf), 0.0);
vec3 aFresnel = occPBRFresnel (theBaseColor.rgb, theMetallic, theIOR, aCosVH);
vec3 aSpecular = occPBRCookTorrance (theView,
theLight,
theNormal,
theBaseColor.rgb,
theMetallic,
theRoughness,
theIOR);
vec3 aDiffuse = vec3(1.0) - aFresnel;
aDiffuse *= 1.0 - theMetallic;
aDiffuse *= INV_PI;
aDiffuse *= theBaseColor.rgb;
aDiffuse = mix (vec3(0.0), aDiffuse, theBaseColor.a);
return (aDiffuse + aSpecular) * theLightColor * theLightIntensity * max(0.0, dot(theLight, theNormal));
}