{"id":1077,"date":"2015-03-17T10:47:36","date_gmt":"2015-03-17T17:47:36","guid":{"rendered":"http:\/\/otherthings.com\/blog\/?p=1077"},"modified":"2025-12-17T14:21:30","modified_gmt":"2025-12-17T22:21:30","slug":"fun-with-pseudocolor","status":"publish","type":"post","link":"https:\/\/otherthings.com\/blog\/2015\/03\/fun-with-pseudocolor\/","title":{"rendered":"Fun with Pseudocolor"},"content":{"rendered":"<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><a href=\"https:\/\/otherthings.com\/blog\/wp-content\/uploads\/2015\/03\/Screen-Shot-2015-03-17-at-10.14.36-AM.png\"><img loading=\"lazy\" decoding=\"async\" width=\"401\" height=\"398\" src=\"https:\/\/otherthings.com\/blog\/wp-content\/uploads\/2015\/03\/Screen-Shot-2015-03-17-at-10.14.36-AM.png\" alt=\"Screen Shot 2015-03-17 at 10.14.36 AM\" class=\"wp-image-1081\" srcset=\"https:\/\/otherthings.com\/blog\/wp-content\/uploads\/2015\/03\/Screen-Shot-2015-03-17-at-10.14.36-AM.png 401w, https:\/\/otherthings.com\/blog\/wp-content\/uploads\/2015\/03\/Screen-Shot-2015-03-17-at-10.14.36-AM-150x150.png 150w, https:\/\/otherthings.com\/blog\/wp-content\/uploads\/2015\/03\/Screen-Shot-2015-03-17-at-10.14.36-AM-300x298.png 300w, https:\/\/otherthings.com\/blog\/wp-content\/uploads\/2015\/03\/Screen-Shot-2015-03-17-at-10.14.36-AM-144x144.png 144w\" sizes=\"auto, (max-width: 401px) 100vw, 401px\" \/><\/a><figcaption class=\"wp-element-caption\"><br \/><center>A shader experiment gone horribly, beautifully wrong.<\/center><\/figcaption><\/figure>\n<\/div>\n\n\n<p>&nbsp;<\/p>\n\n\n\n<p>I was tinkering with some GLSL shaders in Processing, and I needed a way to visualize a value that smoothly changes from 0 to 1, showing a lot more than the 256 levels of gray that you&#8217;d normally see. So I wrote a little pseudocolor function that spirals through colorspace from black to white, hitting various hues along the way. It&#8217;s fun, and pretty, and very <a href=\"https:\/\/otherthings.com\/blog\/2006\/02\/renaming-this-blog\/\">rungy-chungy<\/a>, so I thought I&#8217;d post it here.<\/p>\n\n\n\n<p><code>vec4 pseudo3(float val) {<\/code>float reps = 20.0;<br \/>float pi = 3.14159256;<br \/>float bright = val;<br \/>float con = 0.25 &#8211; 0.20 * cos(val * pi * 2.0);<br \/>float sat = 0.66 &#8211; 0.25 * cos(val * pi * 2.0);<\/p>\n\n\n\n<p>return vec4(sin(val*pi*reps)*con+bright,<br \/>sin(val*pi*reps &#8211; pi*0.663 * sat)*con+bright,<br \/>sin(val*pi*reps &#8211; pi*1.333 * sat)*con+bright,<br \/>1.0);<br \/>}<br \/><br \/><\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter is-resized\"><a href=\"https:\/\/otherthings.com\/blog\/wp-content\/uploads\/2015\/03\/pseudo_spirals.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"600\" height=\"320\" src=\"https:\/\/otherthings.com\/blog\/wp-content\/uploads\/2015\/03\/pseudo_spirals.jpg\" alt=\"Here's the path the above function traces through the RGB cube of colorspace.\" class=\"wp-image-1087\" style=\"width:600px;height:auto\" srcset=\"https:\/\/otherthings.com\/blog\/wp-content\/uploads\/2015\/03\/pseudo_spirals.jpg 600w, https:\/\/otherthings.com\/blog\/wp-content\/uploads\/2015\/03\/pseudo_spirals-300x160.jpg 300w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><figcaption class=\"wp-element-caption\"><center>Here&#8217;s the path the above function traces through the RGB cube of colorspace.<\/center><\/figcaption><\/figure>\n<\/div>","protected":false},"excerpt":{"rendered":"<p>&nbsp; I was tinkering with some GLSL shaders in Processing, and I needed a way to visualize a value that smoothly changes from 0 to 1, showing a lot more than the 256 levels of gray that you&#8217;d normally see. So I wrote a little pseudocolor function that spirals through colorspace from black to white, &hellip; <a href=\"https:\/\/otherthings.com\/blog\/2015\/03\/fun-with-pseudocolor\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Fun with Pseudocolor<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9,123,27],"tags":[],"class_list":["post-1077","post","type-post","status-publish","format-standard","hentry","category-fun","category-graphics","category-visualization"],"_links":{"self":[{"href":"https:\/\/otherthings.com\/blog\/wp-json\/wp\/v2\/posts\/1077","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/otherthings.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/otherthings.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/otherthings.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/otherthings.com\/blog\/wp-json\/wp\/v2\/comments?post=1077"}],"version-history":[{"count":10,"href":"https:\/\/otherthings.com\/blog\/wp-json\/wp\/v2\/posts\/1077\/revisions"}],"predecessor-version":[{"id":1866,"href":"https:\/\/otherthings.com\/blog\/wp-json\/wp\/v2\/posts\/1077\/revisions\/1866"}],"wp:attachment":[{"href":"https:\/\/otherthings.com\/blog\/wp-json\/wp\/v2\/media?parent=1077"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/otherthings.com\/blog\/wp-json\/wp\/v2\/categories?post=1077"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/otherthings.com\/blog\/wp-json\/wp\/v2\/tags?post=1077"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}