Skip to content
This repository has been archived by the owner on Dec 16, 2021. It is now read-only.

Add docs on lighting #269

Merged
merged 3 commits into from
May 19, 2020
Merged

Add docs on lighting #269

merged 3 commits into from
May 19, 2020

Conversation

asinghvi17
Copy link
Member

CC @ffreyer - I'm not sure what shininess and specular do exactly, so I put some placeholder text in there for now.

@ffreyer
Copy link
Contributor

ffreyer commented May 17, 2020

To me specular kinda has a double meaning. The intended meaning is that it is a prefactor for the specular reflection (the bright reflection that sits between the light direction and the camera direction). The secondary meaning is that of a light color. If you were to set specular = Vec3f0(0.2, 0, 0) the specular reflection would be red.

Maybe it would make sense to have specular and light_color and convert this to one Vec3f0 in GLMakie.

shininess controls the exponent used in the calculation of the specular reflection. If shininess is large, the reflection will be sharp and local. If it's small, then the reflection is spans a wider area.

The relevant code for this is:

    vec3 H = normalize(L + V);
    float spec_coeff = pow(max(dot(H, N), 0.0), shininess);

    // final lighting model
    return vec3(
        ambient * color +
        diffuse * diff_coeff * color +
        specular * spec_coeff
    );

N is the normal vector. H = normalize(L + V) is the half vector between the light direction (lightposition - pos) and the camera direction (eyeposition - pos).

docs/src/lighting.md Outdated Show resolved Hide resolved
docs/src/lighting.md Outdated Show resolved Hide resolved
@SimonDanisch
Copy link
Member

Awesome :)

@asinghvi17 asinghvi17 merged commit 6ac95a4 into master May 19, 2020
@asinghvi17 asinghvi17 deleted the as/lighting branch May 19, 2020 10:18
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants