diff options
Diffstat (limited to 'shaders/main/frag.glsl')
-rw-r--r-- | shaders/main/frag.glsl | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/shaders/main/frag.glsl b/shaders/main/frag.glsl new file mode 100644 index 0000000..c57598c --- /dev/null +++ b/shaders/main/frag.glsl @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2018 Tomasz Kramkowski <tk@the-tk.com> + * SPDX-License-Identifier: MIT + */ +in vec3 fnorm; +in vec3 fpos; +in vec2 fuv; +in vec3 lipos; + +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); +} |