Files
filament/shaders/src/common_lighting.fs
Romain Guy 0a5c068cb6 Switch specular AA to Tokuyoshi and Kaplanyan (#1218)
This replaces the previous "curvature to roughness" method. Both are related
and rely on the screen space variance of geometric normals but this new
solution offers more control (the screen space variance and the clamping
threshold can be controlled).
2019-05-23 12:56:26 -07:00

45 lines
1.0 KiB
GLSL

struct Light {
vec4 colorIntensity; // rgb, pre-exposed intensity
vec3 l;
float attenuation;
float NoL;
};
struct PixelParams {
vec3 diffuseColor;
float perceptualRoughness;
vec3 f0;
float roughness;
vec3 dfg;
vec3 energyCompensation;
#if defined(MATERIAL_HAS_CLEAR_COAT)
float clearCoat;
float clearCoatPerceptualRoughness;
float clearCoatRoughness;
#endif
#if defined(MATERIAL_HAS_ANISOTROPY)
vec3 anisotropicT;
vec3 anisotropicB;
float anisotropy;
#endif
#if defined(SHADING_MODEL_SUBSURFACE)
float thickness;
vec3 subsurfaceColor;
float subsurfacePower;
#endif
#if defined(SHADING_MODEL_CLOTH) && defined(MATERIAL_HAS_SUBSURFACE_COLOR)
vec3 subsurfaceColor;
#endif
};
float computeMicroShadowing(float NoL, float visibility) {
// Chan 2018, "Material Advances in Call of Duty: WWII"
float aperture = inversesqrt(1.0 - visibility);
float microShadow = saturate(NoL * aperture);
return microShadow * microShadow;
}