# Content from 2013-07-08 10:33:06

posted on 2013-07-08 10:33:06

Anyone who has bothered reading here will have some idea that I've been learning about making games lately.  I haven't written in a bit, because it's a lot of learning and I have very little that's finished enough to show off.  Yesterday, I got bored of working on my networking code, and decided to learn what these things called shaders were.  Luckily, I already knew about the CLinch framework, which had some shader support built in, so I could dive in without having to worry about linking and compiling them myself.

I played around a bit and made a spinning cube with some shading working, but man, having to work with C syntax again was frustrating.  Even more so was having to define the variables for the shader programs both in their explicit code and twice in the lisp that managed them as well.  That sort of work duplication is the sort of thing I think Lisp is well-suited to avoid, so I decided there needed to be yet another library for parsing lisp syntax into a lower-level language, so I started cl-glsl.

It's 5:30 am now, and it can already turn this:
(cl-glsl:translate  (defun main ()    (let ((intensity :float)	  (color     :vec4)	  (tex-color :vec4 (texture2D texture01 v-texture-coord)))      (setf intensity (dot light-dir (normalize normal)))      (cond	((> intensity 0.95)	 (setf color (* tex-color (vec4 1.0 1.0 1.0 1.0))))	((> intensity 0.5)	 (setf color (* tex-color (vec4 0.6 0.6 0.6 0.6))))	((> intensity 0.25)	 (setf color (* tex-color (vec4 0.4 0.4 0.4 0.4))))	(t	 (setf color (* tex-color (vec4 0.2 0.2 0.2 0.2)))))      (setf gl_frag-color color))))

into this:
void main () {    float intensity;    vec4 color;    vec4 texColor = texture2d(texture01, vTextureCoord);      intensity = dot(lightDir, normalize(normal));      if (intensity > 0.95) {        color = (texColor * vec4(1.0, 1.0, 1.0, 1.0));      } else if (intensity > 0.5) {        color = (texColor * vec4(0.6, 0.6, 0.6, 0.6));      } else if (intensity > 0.25) {        color = (texColor * vec4(0.4, 0.4, 0.4, 0.4));      } else {        color = (texColor * vec4(0.2, 0.2, 0.2, 0.2));      }      gl_FragColor = color;}

Which I'm going to call a resounding success and maybe go lie down now. Links to cl-glsl will appear here when and if it proves useful at all.

Good night!