{"id":421,"date":"2011-04-27T12:59:18","date_gmt":"2011-04-27T11:59:18","guid":{"rendered":"http:\/\/www.ozone3d.net\/blogs\/lab\/?p=421"},"modified":"2011-09-07T20:41:11","modified_gmt":"2011-09-07T19:41:11","slug":"glsl-random-generator","status":"publish","type":"post","link":"https:\/\/www.ozone3d.net\/blogs\/lab\/20110427\/glsl-random-generator\/","title":{"rendered":"GLSL Random Generator"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" alt=\"GLSL random \/ noise\" src=\"http:\/\/www.ozone3d.net\/public\/jegx\/201104\/geexlab_glsl_random_20110427-02.jpg\" title=\"GLSL random \/ noise\" class=\"aligncenter\" width=\"400\" height=\"286\" \/><\/p>\n<p><!--more--><\/p>\n<p>Small noise \/ random function in GLSL:<\/p>\n<pre>\r\nvarying vec3 v;\r\n<b>float rand(vec2 n)<\/b>\r\n{\r\n  return 0.5 + 0.5 * \r\n     fract(sin(dot(n.xy, vec2(12.9898, 78.233)))* 43758.5453);\r\n}\r\nvoid main(void)\r\n{\r\n  float x = rand(v.xz);\r\n  gl_FragColor = vec4(x, x, x, 1.0);\r\n}\r\n<\/pre>\n<p>Noise function tested in <a href=\"http:\/\/www.geeks3d.com\/geexlab\/\">GeeXLab<\/a> (OpenGL 2):<br \/>\n<img decoding=\"async\" src=\"http:\/\/www.ozone3d.net\/public\/jegx\/201104\/geexlab_glsl_random_20110427.jpg\" alt=\"GLSL random function\" class=\"aligncenter\"  \/><\/p>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[208,18,428,638,427,130],"class_list":["post-421","post","type-post","status-publish","format-standard","hentry","category-opengl","tag-generator","tag-glsl","tag-noise","tag-opengl","tag-random","tag-shader"],"aioseo_notices":[],"views":17804,"_links":{"self":[{"href":"https:\/\/www.ozone3d.net\/blogs\/lab\/wp-json\/wp\/v2\/posts\/421","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ozone3d.net\/blogs\/lab\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ozone3d.net\/blogs\/lab\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ozone3d.net\/blogs\/lab\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ozone3d.net\/blogs\/lab\/wp-json\/wp\/v2\/comments?post=421"}],"version-history":[{"count":0,"href":"https:\/\/www.ozone3d.net\/blogs\/lab\/wp-json\/wp\/v2\/posts\/421\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.ozone3d.net\/blogs\/lab\/wp-json\/wp\/v2\/media?parent=421"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ozone3d.net\/blogs\/lab\/wp-json\/wp\/v2\/categories?post=421"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ozone3d.net\/blogs\/lab\/wp-json\/wp\/v2\/tags?post=421"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}