{"id":707,"date":"2012-02-10T20:00:00","date_gmt":"2012-02-10T19:00:00","guid":{"rendered":"http:\/\/shadowcovenant.com\/blog\/2012\/02\/10\/damn-work\/"},"modified":"2012-02-10T20:00:00","modified_gmt":"2012-02-10T19:00:00","slug":"damn-work","status":"publish","type":"post","link":"http:\/\/shadowcovenant.com\/blog\/2012\/02\/10\/damn-work\/","title":{"rendered":"Damn work! :)"},"content":{"rendered":"<p align=\"justify\">Not much has gone on lately, except for the bad week start and then work has gone crazy, so I haven\u2019t done much lately on my hobbies\u2026 Haven\u2019t played SWTOR in ages, so I still haven\u2019t had the time to finish all the questing so I can do an \u201cearly impressions\u201d review\u2026<\/p>\n<p align=\"justify\">Anyway, I took the opportunity to read up a lot on shading systems, specially multi-materials on a deferred rendering context, and I decided that when I have the chance, I\u2019ll implement something like this: <a href=\"http:\/\/developer.download.nvidia.com\/SDK\/9.5\/Samples\/DEMOS\/Direct3D9\/src\/HLSL_Aniso\/docs\/HLSL_Aniso.pdf\">Anisotropic Lighting<\/a>, combining a 3d texture to store the maps and a material id lookup (since I still have component free on the G-Buffer). Still not an ideal solution (since I can\u2019t parameterized that much the materials, beyond the lookup\u2026 for example, I can\u2019t parameterize rim-lighting with a falloff parameter, I have to fix that so I can generate the lighting lookup table). Anyway, it should give me some more flexibility in having different materials, specially on <em>Grey<\/em>\u2026<\/p>\n<p align=\"justify\"><a href=\"http:\/\/shadowcovenant.com\/blog\/wp-content\/uploads\/2012\/02\/grey_anim03.jpg\"><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px\" title=\"grey_anim03\" border=\"0\" alt=\"grey_anim03\" src=\"http:\/\/shadowcovenant.com\/blog\/wp-content\/uploads\/2012\/02\/grey_anim03_thumb.jpg\" width=\"539\" height=\"434\" \/><\/a><\/p>\n<p align=\"justify\">The hair and fur shading seem \u201cincorrect\u201d, and this hopefully will allow me to fix it (with double-sided lighting for the hair and some anisotropy on the fur).<\/p>\n<p align=\"justify\">There\u2019s a new blog post on <a href=\"www.spellcasterstudios.com\">Spellcaster Studios<\/a>, showing some props and base textures for the terrain tiles, besides some explanation on how we\u2019re going to make the terrain in the first episode.<\/p>\n<p align=\"justify\">Another thing that I\u2019ve been working was with some SQL queries for work: I had a query that basically inserted some rows into a database, but it could only do that if there wasn\u2019t some other rows there yet. Basically, I need to queue some reset commands, but could only do that if there wasn\u2019t any pending reset commands\u2026 <\/p>\n<p align=\"justify\">First version just iterated and checked in PHP, and took about 15 seconds\u2026<\/p>\n<p align=\"justify\">Then we built a query that did all that in one SQL query, and it took about 9 seconds (because it had to do a SELECT query for every hit in 1400+ rows)\u2026 Still too slow\u2026 <\/p>\n<p align=\"justify\">Finally, we just designed a series of statements with a different point of view\u2026 Instead of adding the new data and before adding it check if it was already present in a specific table (a query), we created a temporary table that had all the pending requests, and we just checked if the data we wanted to insert was in that table or not (a \u201cstatic\u201d structure)\u2026 Boom, down to 0.005 ms per query\u2026 <\/p>\n<p align=\"justify\">For fun, here\u2019s the code:<\/p>\n<pre>CREATE TEMPORARY TABLE TempTable(\n   key VARCHAR(50) NOT NULL\n) ENGINE=MEMORY;\n\nINSERT INTO TempTable(mac)\nSELECT data FROM MainTable WHERE ((type=5) OR ((type=7) AND (error LIKE <\/pre>\n<pre>'processing%')));\n\nINSERT INTO MainTable(id,user,status,type,data,error,comment,time) SELECT <\/pre>\n<pre>NULL,1,1,5,OtherTable.key,'','Device reset request (type=5)',NOW() <\/pre>\n<pre>FROM Services\nINNER JOIN Addresses\nON Services.address=Addresses.id\nINNER JOIN Devices\nON Services.device=Devices.id\nINNER JOIN OtherTable<\/pre>\n<pre>ON Devices.parameters=OtherTable.key\nWHERE (Addresses.location=40) AND (Services.type=1) AND OtherTable.key <\/pre>\n<pre>NOT IN(SELECT key FROM TempTable);\n\nDROP TABLE TempTable;<\/pre>\n<p align=\"justify\">So, even something like SQL can be optimized! <img decoding=\"async\" style=\"border-bottom-style: none; border-left-style: none; border-top-style: none; border-right-style: none\" class=\"wlEmoticon wlEmoticon-smile\" alt=\"Smile\" src=\"http:\/\/shadowcovenant.com\/blog\/wp-content\/uploads\/2012\/02\/wlEmoticon-smile1.png\" \/> (I really hate SQL and database programming, but this kind of things are quite neat!)<\/p>\n<div id=\"tweetbutton707\" class=\"tw_button\" style=\"\"><a href=\"http:\/\/twitter.com\/share?url=http%3A%2F%2Fshadowcovenant.com%2Fblog%2F2012%2F02%2F10%2Fdamn-work%2F&amp;text=Damn%20work%21%20%3A%29&amp;related=&amp;lang=en&amp;count=horizontal&amp;counturl=http%3A%2F%2Fshadowcovenant.com%2Fblog%2F2012%2F02%2F10%2Fdamn-work%2F\" class=\"twitter-share-button\"  style=\"width:55px;height:22px;background:transparent url('http:\/\/shadowcovenant.com\/blog\/wp-content\/plugins\/wp-tweet-button\/tweetn.png') no-repeat  0 0;text-align:left;text-indent:-9999px;display:block;\">Tweet<\/a><\/div>","protected":false},"excerpt":{"rendered":"<p>Not much has gone on lately, except for the bad week start and then work has gone crazy, so I haven\u2019t done much lately on my hobbies\u2026 Haven\u2019t played SWTOR in ages, so I still haven\u2019t had the time to finish all the questing so I can do an \u201cearly impressions\u201d review\u2026 Anyway, I took [&hellip;]<\/p>\n<div id=\"tweetbutton707\" class=\"tw_button\" style=\"\"><a href=\"http:\/\/twitter.com\/share?url=http%3A%2F%2Fshadowcovenant.com%2Fblog%2F2012%2F02%2F10%2Fdamn-work%2F&amp;text=Damn%20work%21%20%3A%29&amp;related=&amp;lang=en&amp;count=horizontal&amp;counturl=http%3A%2F%2Fshadowcovenant.com%2Fblog%2F2012%2F02%2F10%2Fdamn-work%2F\" class=\"twitter-share-button\"  style=\"width:55px;height:22px;background:transparent url('http:\/\/shadowcovenant.com\/blog\/wp-content\/plugins\/wp-tweet-button\/tweetn.png') no-repeat  0 0;text-align:left;text-indent:-9999px;display:block;\">Tweet<\/a><\/div>","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23,88],"tags":[109,110,111],"class_list":["post-707","post","type-post","status-publish","format-standard","hentry","category-development","category-grey","tag-anisotropic","tag-lighting","tag-sql"],"_links":{"self":[{"href":"http:\/\/shadowcovenant.com\/blog\/wp-json\/wp\/v2\/posts\/707","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/shadowcovenant.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/shadowcovenant.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/shadowcovenant.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/shadowcovenant.com\/blog\/wp-json\/wp\/v2\/comments?post=707"}],"version-history":[{"count":0,"href":"http:\/\/shadowcovenant.com\/blog\/wp-json\/wp\/v2\/posts\/707\/revisions"}],"wp:attachment":[{"href":"http:\/\/shadowcovenant.com\/blog\/wp-json\/wp\/v2\/media?parent=707"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/shadowcovenant.com\/blog\/wp-json\/wp\/v2\/categories?post=707"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/shadowcovenant.com\/blog\/wp-json\/wp\/v2\/tags?post=707"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}