{"id":23286,"date":"2021-05-08T09:44:38","date_gmt":"2021-05-08T14:44:38","guid":{"rendered":"http:\/\/blog.kenperlin.com\/?p=23286"},"modified":"2022-05-15T07:24:25","modified_gmt":"2022-05-15T12:24:25","slug":"bump-textures","status":"publish","type":"post","link":"http:\/\/blog.kenperlin.com\/?p=23286","title":{"rendered":"Bump textures"},"content":{"rendered":"<p>John Davis asked how to make bumpy textures using the Noise function. I figure that this is as good a place as any to answer his question.<\/p>\n<p>Because the Noise function is a continuous function, you can always take a derivative of it, without having to dive inside the Noise function to figure out how it works. You can get a good approximation of a derivative by taking finite differences, using nearby samples.<\/p>\n<p>First choose small distance \u03b5, which is small enough that it is smaller than any feature in our scene. I usually use a value for \u03b5 of something like 1\/1000. Then instead of using a single evaluation of noise at surface point [x,y,z], do four evaluations: One is f<sub>0<\/sub> = noise(x,y,z), and the other three are f<sub>x<\/sub> = noise(x+\u03b5,y,z), f<sub>y<\/sub> = noise(x,y+\u03b5,z), and f<sub>z<\/sub> = noise(x,y,z+\u03b5), respectively.<\/p>\n<p>Now you can just do finite differences to get an approximate derivative. In particular, you can get a vector in the direction of the derivative, which you can then set to unit length by using the normalize function: B = normalize([f<sub>x<\/sub>-f<sub>0<\/sub>,f<sub>y<\/sub>-f<sub>0<\/sub>,f<sub>z<\/sub>-f<sub>0<\/sub>]).<\/p>\n<p>Then you can just add this into your surface normal. The more you add (say, by varying a constant C), the bumpier the texture: normal = normalize(normal + C * B).<\/p>\n<p>And that&#8217;s it. You now have bumpy textures.<\/p>\n<p>This is all inspired by Jim Blinn&#8217;s Ph.D. dissertation &#8212; as is so much in computer graphics. In 1977 he pointed out that you can fake bumpy surfaces not by changing the surface itself but just by changing the surface normal.<\/p>\n<p>And that&#8217;s just one reason we know Jim Blinn is a genius: His bump textures technique is simple, fast to compute, and produces great looking results.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>John Davis asked how to make bumpy textures using the Noise function. I figure that this is as good a place as any to answer his question. Because the Noise function is a continuous function, you can always take a derivative of it, without having to dive inside the Noise function to figure out how &hellip; <a href=\"http:\/\/blog.kenperlin.com\/?p=23286\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Bump textures&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"http:\/\/blog.kenperlin.com\/index.php?rest_route=\/wp\/v2\/posts\/23286"}],"collection":[{"href":"http:\/\/blog.kenperlin.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/blog.kenperlin.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/blog.kenperlin.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/blog.kenperlin.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=23286"}],"version-history":[{"count":9,"href":"http:\/\/blog.kenperlin.com\/index.php?rest_route=\/wp\/v2\/posts\/23286\/revisions"}],"predecessor-version":[{"id":24364,"href":"http:\/\/blog.kenperlin.com\/index.php?rest_route=\/wp\/v2\/posts\/23286\/revisions\/24364"}],"wp:attachment":[{"href":"http:\/\/blog.kenperlin.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=23286"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/blog.kenperlin.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=23286"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/blog.kenperlin.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=23286"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}