blob: 2f0a367d23f410e2ec7f7022849e7ed7fdffc9c4 (
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
29
30
31
32
|
/*
* Copyright (C) 2018 Tomasz Kramkowski <tk@the-tk.com>
* SPDX-License-Identifier: MIT
*/
#version 330 core
out vec4 color;
in vec3 fnorm;
in vec3 fpos;
in vec2 fuv;
in vec3 lipos;
uniform sampler2D tex;
void main()
{
vec3 objco = vec3(texture(tex, fuv));
vec3 lico = vec3(1.0, 1.0, 1.0);
float amb = 0.1;
vec3 norm = normalize(fnorm);
vec3 lidir = normalize(lipos - fpos);
float dif = max(dot(norm, lidir), 0.0);
float speen = max(sign(dot(lidir, norm)), 0.0);
vec3 vwdir = normalize(-fpos);
vec3 mid = normalize(lidir + vwdir);
float spe = pow(max(dot(norm, mid), 0.0), 256) * speen;
color = vec4((amb + dif + spe) * lico * objco, 1.0);
}
|