LYGIA Shader Library

perceptual2linearRoughness (lygia/lighting/common/perceptual2linearRoughness)

Classic Disney reparametrisation of roughness from Burley's paper "Physically Based Shading At Disney". Sébastien Lagarde's recommends clamping perceptual roughness to 0.045 in his paper "Moving Frostbite to PBR".

Use:

<float> perceptual2linearRoughness(<float> perceptualRoughness)

Check it on Github


#ifndef MIN_PERCEPTUAL_ROUGHNESS
#define MIN_PERCEPTUAL_ROUGHNESS 0.045
#endif

#ifndef FNC_PERCEPTUAL_LINEAR_ROUGHNESS
#define FNC_PERCEPTUAL_LINEAR_ROUGHNESS

float perceptual2linearRoughness(float perceptualRoughness) {
    perceptualRoughness = clamp(perceptualRoughness, MIN_PERCEPTUAL_ROUGHNESS, 1.0);
    return perceptualRoughness * perceptualRoughness;
}

#endif

Use:

<float> perceptual2linearRoughness(<float> perceptualRoughness)

Check it on Github


#ifndef MIN_PERCEPTUAL_ROUGHNESS
#define MIN_PERCEPTUAL_ROUGHNESS 0.045
#endif

#ifndef FNC_PERCEPTUAL_LINEAR_ROUGHNESS
#define FNC_PERCEPTUAL_LINEAR_ROUGHNESS

float perceptual2linearRoughness(float perceptualRoughness) {
    perceptualRoughness = clamp(perceptualRoughness, MIN_PERCEPTUAL_ROUGHNESS, 1.0);
    return perceptualRoughness * perceptualRoughness;
}

#endif

License

MIT License (MIT) Copyright (c) 2024 Shadi EL Hajj

LYGIA is dual-licensed under the Prosperity License and the Patron License for sponsors and contributors.

Sponsors and contributors are automatically added to the Patron License and they can ignore the any non-commercial rule of the Prosperity Licensed software (please take a look to the exception).

It's also possible to get a permanent comercial license hook to a single and specific version of LYGIA.

Get the latest news and releases

Sign up for the news letter bellow, joing the LYGIA's channel on Discord or follow the Github repository