{"id":638,"date":"2010-08-03T11:19:40","date_gmt":"2010-08-03T03:19:40","guid":{"rendered":"http:\/\/www.cgdev.net\/blog\/?p=638"},"modified":"2018-07-28T21:21:37","modified_gmt":"2018-07-28T13:21:37","slug":"lit","status":"publish","type":"post","link":"https:\/\/www.cgdev.net\/blog\/638.html","title":{"rendered":"lit"},"content":{"rendered":"<p>In HLSL the lit function use dotDiffuse, dotSpecular and shininess as parameters and returns a lighting coefficient vector (ambient, diffuse, specular, 1) where:<\/p>\n<ul>\n<li>ambient = 1<\/li>\n<li>diffuse = ((n \u2022 l) &lt; 0) ? 0 : n \u2022 l<\/li>\n<li>specular = ((n \u2022 l) &lt; 0) || ((n \u2022 h) &lt; 0) ? 0 : ((n \u2022 h) * m)<\/li>\n<\/ul>\n<p>In GLSL it would be:<\/p>\n<pre lang=\"a_c\" escaped=\"true\">\r\nvec4 lit(float NdotL, float NdotH, float m) \r\n{ \r\n  float ambient = 1.0;\r\n  float diffuse = max(NdotL, 0.0);\r\n  float specular = step(0.0, NdotL) * max(NdotH * m, 0.0); \r\n  return vec4(ambient, diffuse, specular, 1.0);\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>In HLSL the lit function use dotDiffuse, dotSpecular and shininess as parameters and returns a lighting coefficient vector (ambient, diffuse, specular, 1) where: ambient = 1 diffuse = ((n \u2022 l) &lt; 0) ? 0 : n \u2022 l specular = ((n \u2022 l) &lt; 0) || ((n \u2022 h) &lt; 0) ? 0 : [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-638","post","type-post","status-publish","format-standard","hentry","category-shader"],"_links":{"self":[{"href":"https:\/\/www.cgdev.net\/blog\/wp-json\/wp\/v2\/posts\/638","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.cgdev.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.cgdev.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.cgdev.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.cgdev.net\/blog\/wp-json\/wp\/v2\/comments?post=638"}],"version-history":[{"count":0,"href":"https:\/\/www.cgdev.net\/blog\/wp-json\/wp\/v2\/posts\/638\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.cgdev.net\/blog\/wp-json\/wp\/v2\/media?parent=638"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.cgdev.net\/blog\/wp-json\/wp\/v2\/categories?post=638"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.cgdev.net\/blog\/wp-json\/wp\/v2\/tags?post=638"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}