Welcome to mirror list, hosted at ThFree Co, Russian Federation.

toolpaths_lines.fs « shaders « resources - github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 31151cdc170994e58ba8e79f4124fb18d08d411a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#version 110

// normalized values for (-0.6/1.31, 0.6/1.31, 1./1.31)
const vec3 LIGHT_TOP_DIR = vec3(-0.4574957, 0.4574957, 0.7624929);
const vec3 LIGHT_FRONT_DIR = vec3(0.0, 0.0, 1.0);

// x = ambient, y = top diffuse, z = front diffuse, w = global
uniform vec4 light_intensity;
uniform vec4 uniform_color;

varying vec3 eye_normal;

void main()
{
    vec3 normal = normalize(eye_normal);

    // Compute the cos of the angle between the normal and lights direction. The light is directional so the direction is constant for every vertex.
    // Since these two are normalized the cosine is the dot product. Take the abs value to light the lines no matter in which direction the normal points.
    float NdotL = abs(dot(normal, LIGHT_TOP_DIR));

    float intensity = light_intensity.x + NdotL * light_intensity.y;

    // Perform the same lighting calculation for the 2nd light source.
    NdotL = abs(dot(normal, LIGHT_FRONT_DIR));
    intensity += NdotL * light_intensity.z;    

    gl_FragColor = vec4(uniform_color.rgb * light_intensity.w * intensity, uniform_color.a);
}