| 1 |
struct Light { |
| 2 |
vec4 colorIntensity; // rgb, pre-exposed intensity |
| 3 |
vec3 l; |
| 4 |
float attenuation; |
| 5 |
float NoL; |
| 6 |
vec3 worldPosition; |
| 7 |
bool castsShadows; |
| 8 |
bool contactShadows; |
| 9 |
uint shadowIndex; |
| 10 |
uint shadowLayer; |
| 11 |
}; |
| 12 |
|
| 13 |
struct PixelParams { |
| 14 |
vec3 diffuseColor; |
| 15 |
float perceptualRoughness; |
| 16 |
float perceptualRoughnessUnclamped; |
| 17 |
vec3 f0; |
| 18 |
float roughness; |
| 19 |
vec3 dfg; |
| 20 |
vec3 energyCompensation; |
| 21 |
|
| 22 |
#if defined(MATERIAL_HAS_CLEAR_COAT) |
| 23 |
float clearCoat; |
| 24 |
float clearCoatPerceptualRoughness; |
| 25 |
float clearCoatRoughness; |
| 26 |
#endif |
| 27 |
|
| 28 |
#if defined(MATERIAL_HAS_SHEEN_COLOR) |
| 29 |
vec3 sheenColor; |
| 30 |
#if !defined(SHADING_MODEL_CLOTH) |
| 31 |
float sheenRoughness; |
| 32 |
float sheenPerceptualRoughness; |
| 33 |
float sheenScaling; |
| 34 |
float sheenDFG; |
| 35 |
#endif |
| 36 |
#endif |
| 37 |
|
| 38 |
#if defined(MATERIAL_HAS_ANISOTROPY) |
| 39 |
vec3 anisotropicT; |
| 40 |
vec3 anisotropicB; |
| 41 |
float anisotropy; |
| 42 |
#endif |
| 43 |
|
| 44 |
#if defined(SHADING_MODEL_SUBSURFACE) || defined(HAS_REFRACTION) |
| 45 |
float thickness; |
| 46 |
#endif |
| 47 |
#if defined(SHADING_MODEL_SUBSURFACE) |
| 48 |
vec3 subsurfaceColor; |
| 49 |
float subsurfacePower; |
| 50 |
#endif |
| 51 |
|
| 52 |
#if defined(SHADING_MODEL_CLOTH) && defined(MATERIAL_HAS_SUBSURFACE_COLOR) |
| 53 |
vec3 subsurfaceColor; |
| 54 |
#endif |
| 55 |
|
| 56 |
#if defined(HAS_REFRACTION) |
| 57 |
float etaRI; |
| 58 |
float etaIR; |
| 59 |
float transmission; |
| 60 |
float uThickness; |
| 61 |
vec3 absorption; |
| 62 |
#endif |
| 63 |
}; |
| 64 |
|
| 65 |
float computeMicroShadowing(float NoL, float visibility) { |
| 66 |
// Chan 2018, "Material Advances in Call of Duty: WWII" |
| 67 |
float aperture = inversesqrt(1.0 - visibility); |
| 68 |
float microShadow = saturate(NoL * aperture); |
| 69 |
return microShadow * microShadow; |
| 70 |
} |