diff options
author | Tomasz Kramkowski <tk@the-tk.com> | 2018-05-03 22:56:17 +0100 |
---|---|---|
committer | Tomasz Kramkowski <tk@the-tk.com> | 2018-05-04 20:04:30 +0100 |
commit | bc01efbb0c2f01871cbfdf8bfd779c6262e34c17 (patch) | |
tree | 1d3f22687b5a0659321f2cbd6ef8a22b93828140 | |
parent | 232035b7e24d2a49a472c28b326f2227af11963d (diff) | |
download | faqe-bc01efbb0c2f01871cbfdf8bfd779c6262e34c17.tar.gz faqe-bc01efbb0c2f01871cbfdf8bfd779c6262e34c17.tar.xz faqe-bc01efbb0c2f01871cbfdf8bfd779c6262e34c17.zip |
fragment shader: implement blinn-phong
-rw-r--r-- | frag.glsl | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -22,11 +22,11 @@ void main() vec3 lidir = normalize(lipos - fpos); float dif = max(dot(norm, lidir), 0.0); - float spestr = 0.5; + float speen = max(sign(dot(lidir, norm)), 0.0); vec3 vwdir = normalize(-fpos); - vec3 redir = reflect(-lidir, norm); + vec3 mid = normalize(lidir + vwdir); - float spe = spestr * pow(max(dot(vwdir, redir), 0.0), 32); + float spe = pow(max(dot(norm, mid), 0.0), 256) * speen; color = vec4((amb + dif + spe) * lico * objco, 1.0); } |