Quantum Mechanic

Content tagged Games

Cooking with shaders

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:
(defun main ()
(let ((intensity :float)
(color :vec4)
(tex-color :vec4 (texture2D texture01 v-texture-coord)))
(setf intensity (dot light-dir (normalize normal)))

((> 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))))
(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!


posted on 2013-04-30 20:39:31

This past weekend was the Chicago Comics and Entertainment Expo and, having been meaning to try going to a con for a few months now, I decided to get tickets. For my first convention, one-day tickets for Saturday seemed plenty to get me overstimulated and looking for a hole to crawl into by the end of the day.

I met up with my guides around 11, and we made it down to the south side, where the McCormick center is located by a not before 12:30, when we finally made it into the hall.


It was enormous in there.
I have never seen so many little action figures, toys, and comics in one place. Not to mention the art, which was all sorts of styles I don't get to see enough, sporting all permutations of popular game characters and styles. There certainly was no want of things to buy.

Some of it was really creatively done, but I think in retrospect, with the afterimages of star trek medallions faded from my eyes, a lot of it was crap based on popular shows and comics. This is probably just my mental image of the event not lining up with what it actually was supposed to be, but I would have loved to see more original work there - less of the industrially produced story and some of the greater breadth of storytelling that has been gaining fame in comics lately.

Even the panels had a lot of a corporate feel to them. The first one I visited was on role playing and tabletop games, and what was supposed by the three panelists to be new and exciting in them. They did have a few honest suggestions, which I'm hoping to look into, but after the first run through the panel died the death of industry talk and made up business speak that I hated when I worked at SAP.

The second panel, though, was on censorship and comics, and was far and away the most interesting thing I witnessed that day. There, I heard about rulings as recent as the 80's, when an artist was told he was not allowed to draw - complete with random house checks by the police to make sure he hasn't been drawing. The artist was Mike Diana and the comic that landed him in trouble was called boiled angel. An earlier comic battle was back in the 50's, when Bill Gaines testified in downtown NYC that horror comics were not obscene and should be allowed to be sold as they were. Unfortunately, public opinion was against him and led to strict rules on what could be printed in comics for decades. The speaker was from the comic book defense league, and was a great speaker.

Finally, to end on a question, it was exciting to see all of the costumes at the show. People obviously took a lot of time to design and make them, and it was fun to have superheroes and demons walking around, but there is obviously a gap between the genders in skin shown and body parts on display. I certainly have no problem with anyone wearing a revealing costume, I just worry about the double standards that are obviously there somewhere, and I hope that gap will close somehow in the near future. We need more brave men in sexy costumes, I think!

Working on OpenGL in Lisp

posted on 2013-04-15 04:18:48

Recently, I've started working on a 3D game.  Something I've dreamed about for a while, and then saw a glimmer of in Artemis. I'll write more about that if I manage to get anywhere with it.

In support of making the game, I've been using the waveform file format (.obj) for things I'm working on in Blender. I'm not entirely happy with the obj loader, which is currently living on github, but still subject to tremendous revision.  To work with that, I've just begun working on cl-tga, which loads tga images.  It seems that obj files use mtl files to describe surfaces, and they in turn use tga files to hold the textures.  I haven't written anything to read a binary file format before, so it's been interesting.

It only took me a day to get things almost right, but they way in which it's currently wrong is amusing.

cl-tga screenshotYou'll notice that it's the same image repeated three times, but in each one the marbles are different shades.  For some reason, it's drawing the red, green, and blue as separate images.  Here's the file it's loading from:



As much as it's frustrating to write all of this infrastructure, I'm hoping it'll make the barrier lower for other people who want to use lisp for games like this.


Minecraft Mods on Mac Leopard

posted on 2012-11-26 09:40:14

For the last few days, I've been trying out the Better than Wolves mod for Minecraft.  The mod makes a lot of things harder, and most importantly, adds mechanical power to the game alongside the magical redstone power it already had.  With tools like MCPatcher, this sort of thing is pretty easy, but once again minecraft's Java bit us in the butt when it turned out Sarah's computer, which runs the Mac OS version 10.5 is no longer supported and doesn't have a version of Java later than 6.

Apparently, it comes configured to use version 5, though.  For some reason.

Anyway, we spent the last day trying different ways of patching the game so she could use it, including doing it on a GNU/Linux box and emailing the modified jar file to her.  The most coherent thing I could recognize out of the Java backtrace was something about class versions.  I know Java is stored in class files, and so I reasoned it was something about some version of Java not playing well.

Long story short, if you find yourself in the same position, follow the instructions of the fellow here, which I will reproduce below in case the forum they are posted to has ceased to exist.

  1. Right click the Minecraft App and select "Show Package Contents", then select `info.plist`

  2. In `info.plist` look for the lines of "JVMVersion 1.5+" change the 5 to a 6 then save and close the file

  3. Open a finder window and go to /System/Library/Frameworks/JavaVM.framework /Resources/Mac OS

  4. Copy the file named `JavaApplicationStub`

    1. Go back to the `Contents` folder in the Minecraft app

    2. Open the folder `MacOS`

    3. Paste JavaApplicationStub into the folder

  5. Next find and open “Java Preferences” in finder

  6. In the “General” tab there should be a list of the Java versions you have. If “Java SE 6″ isn’t on the top of the list then drag it to the top.

  7. Patch Minecraft at will

That is all.

The Great Hall

posted on 2012-07-13 16:56:55

Just a few minecraft pictures, because we built a cool castle recently that should be shared!

[gallery link="file" columns="2"]

Maxwell's Sheep

posted on 2012-01-31 17:26:17

In the late 1700s, James Maxwell came up with a dilemma that, although just meant as a though experiment, was a troublesome idea to physicists.  He came up with a clever arrangement of systems of matter at different temperatures that might possibly violate the second law of thermodynamics, which would be troubling because, well, it's supposed to be a law, and we don't like nature going around breaking its own laws, since when that happens, it means we got the law wrong in the first place.

The experiment is as follows:

  1. We have two systems of different temperatures that are isolated from each other and any other system they could exchange heat with.  Since the energy has nowhere to go, they will remain at this state. (This is in accordance with the first law)
  2. We bring the two systems into contact and have a small door, guarded by a small demon, which only allows heat to flow one direction. That is, the demon checks if a particle moving from one system to the other is one of the 'hot' particles and allows it to move through in one direction on that condition.

Here we have to stop a minute and realize, as many did after him, that the situation where this demon requires no energy to do its census and rearranging of every molecule in the systems is impossible.  Measuring the particles requires interacting with them, and so the demon itself is part of the large system here and the energy it uses sorting is part of the overall equation.  This is where my experiment today is different!

I am performing this demonstration in Minecraft, which is a made up world that very clearly marches to the beat of a different Grand Unified Theory, and so I can create a zero-entropy demon.  My demon will be played by a fence gate and a pressure plate.

Fig. 1: Most of the sheep start out in section two.

Here we can see a set of two sheep pens with my wonderfully rainbow-colored sheep in them.  All but the red sheep are in pen two (the further pen) representing a system at higher energy than pen one (the nearer), where there is just one sheep.  In the Middle is the gate with a pressure plate which will cause the gate to open located on the side of higher energy (read: more sheep).  This means that energy (sheep) can only flow from the higher energy to the lower energy pen1. This may seem obvious, but it's also the situation Maxwell tried to set up in his famous experiment.

Let's see what happens!

Fig. 2: Here, we see some sheep have entered pen one, a short time after Fig. 1.
Fig. 3: All the sheep are in pen one.

Long story short, it worked! I left the sheep alone for a little while, as the time of day change demonstrates nicely, and when I returned they were all stuck in the near pen. In case it was in any doubt, this says some strange things about the state of entropy in Minecraft. Perhaps things like cheap cold fusion are easy in this world. Maybe I just need to wait for a hydrogen block and a deuterium block...

[1] I have chosen to ignore second-order sheep effects, like a sheep stepping on the plate and allowing another sheep from the lower energy side to pass back into the higher energy side.

View content from 2009-03-16 04:17:00, 2009-03-21 04:36:00, 2009-04-02 02:00:00, 2009-04-04 01:48:00, 2009-06-25 19:43:00, 2009-07-09 19:15:00, 2009-07-09 19:44:00, 2009-07-20 23:25:00, 2009-07-21 16:57:00, 2009-08-05 05:44:00, 2009-08-05 10:28:00, 2009-08-12 07:11:00, 2009-08-23 02:05:00, 2009-08-23 04:30:00, 2009-10-30 08:02:00, 2009-11-08 06:59:00, 2009-12-04 01:17:00, 2010-05-22 18:55:00, 2010-05-28 22:50:00, 2010-06-05 19:55:00, 2010-06-12 02:12:00, 2010-06-20 20:20:00, 2010-07-02 22:57:00, 2010-08-20 22:16:00, 2010-09-02 02:07:00, 2011-01-07 10:35:30, 2011-01-07 11:17:53, 2011-01-13 06:48:47, 2011-01-24 02:52:06, 2011-01-31 02:41:34, 2011-02-13 23:09:09, 2011-03-23 05:59:11, 2011-04-06 01:33:19, 2011-04-24 22:15:24, 2011-04-24 22:51:30, 2011-06-06 22:36:07, 2011-06-16 02:27:10, 2011-06-30 01:26:18, 2011-07-31 23:10:35, 2011-08-17 04:15:14, 2011-09-11 17:13:48, 2011-10-01 15:55:35, 2011-11-02 15:14:47, 2011-11-08 01:49:00, 2011-11-29 23:28:27, 2011-11-29 23:30:17, 2011-11-30 06:58:06, 2011-12-08 02:41:21, 2012-01-17 17:27:10, 2012-01-20 16:59:54, 2012-01-31 17:26:17, 2012-02-07 15:46:44, 2012-02-10 17:15:32, 2012-03-03 18:35:25, 2012-03-30 02:45:19, 2012-04-23 21:44:13, 2012-07-13 16:39:31, 2012-07-13 16:56:55, 2012-07-17 01:15:15, 2012-08-21 22:12:00, 2012-08-22 21:26:44, 2012-09-19 15:35:27, 2012-11-15 21:27:40, 2012-11-15 21:28:49, 2012-11-26 09:40:14, 2012-11-30 22:05:50, 2013-02-22 20:37:08, 2013-03-08 08:50:26, 2013-03-16 21:41:50, 2013-04-06 06:50:15, 2013-04-15 04:18:48, 2013-04-15 20:27:06, 2013-04-23 20:43:29, 2013-04-30 20:39:31, 2013-06-14 00:17:17, 2013-06-18 16:45:24, 2013-07-08 10:33:06, 2013-07-25 05:00:00, 2013-09-05 14:07:31, 2013-09-25 15:31:00, 2013-09-26 15:35:00, 2013-11-12 15:49:00, 2014-01-04 01:46:27, 2014-02-02 21:48:41, 2014-02-24 02:55:00, 2014-03-05 18:42:00, 2014-07-22 00:46:00, 2014-11-11 14:15:00, 2014-11-13 16:33:00, 2014-11-21 22:17:00, 2014-12-01 20:30:00, 2014-12-05 17:57:00, 2014-12-16 19:53:00, 2015-01-13 18:28:00, 2015-02-12 22:12:00, 2015-07-11 23:54:00, 2015-07-12 00:22:00, 2015-10-18 22:57:35, 2015-10-19 00:32:40, 2015-11-28 19:01:47, 2015-11-29 17:03:00, 2015-12-06 03:02:00, 2015-12-10 13:34:00, 2016-01-03 17:45:00, 2016-01-03 17:56:00, 2016-01-16 20:43:00, 2016-05-10 01:41:00, 2016-05-12 02:01:00, 2016-05-15 14:32:00, 2016-08-01 13:15:00, 2016-08-22 22:05:00, 2016-08-23 22:10:04, 2016-10-26 17:33:48, 2016-11-26 01:36, 2016-12-05 14:42:00, 2016-12-05 19:31:00, 2017-02-03 18:00