int main(void)
{

My Blog

Posted 02/15/12 @ 5:13pm - By Ross

Dashed Lines!

So I recently have been playing around with shaders on my Android project and with the removal of stippling from the OpenGL I thought that I had found the perfect opportunity to use a shader. With some thoughts in mind I decided to search the interwebs to see if I was thinking along the right lines. Unfortunately there isn’t much out there on OpenGL ES 2.0 yet. So it fell to me to come up with something that would work, and work it does!

The basic premise was pretty simple. Find out the world coordinates of each fragment and then, using that, determine it’s length from the line origin. Then plug that into a cosine function and alternate drawing it based off if the value returned is negative or positive.

The key to the whole thing is sourcePoint being passed in as the origin of the line. It’s also worth noting that I pass in the modelview matrix and multiply it with the vertex to determine where it is in world space. The use of position as a varying variable is also important since it is interpolated based off all the vertices that affect it. This allows for the position variable in the fragment shader to be the actual position of the fragment in world space.

With all this, I determine the distance between those two points and then use the cosine function (modified based off how I want the dashes to look) to decide to draw it or not.

So without further ado, here is my vertex shader:

1
2
3
4
5
6
7
8
9
10
11
12
uniform mat4 u_modelViewProjectionMatrix;
uniform mat4 mv;
attribute vec4 a_position;
attribute vec4 a_color;
varying vec4 v_color;
varying vec4 position;

void main() {
  gl_Position = u_modelViewProjectionMatrix * a_position;
  position = mv * a_position;
  v_color = a_color;
}

and the fragment shader:

1
2
3
4
5
6
7
8
9
10
11
12
precision mediump float;
uniform vec2 sourcePoint;
varying vec4 v_color;
varying vec4 position;

void main() {
  if (cos(0.1*abs(distance(sourcePoint.xy, position.xy))) + 0.5 > 0.0) {
    gl_FragColor = vec4(0,0,0,0);
  } else {
    gl_FragColor = v_color;
  }
}
Posted 01/08/12 @ 12:57am - By Ross

Balancing Act

For those that haven’t been following the competitive gaming scene, there has been a big surge in the last year or two. So much so that esports, as it is known, has started generating some big money. Two games in particular seem to be drawing the biggest crowd (and most of my attention). These two games are League of Legends and Starcraft II.

What I find unique about each game is that they seem to take a much different approach to achieving a balanced gameplay system. Starcraft II, as with the original, is a tightly knit balance between each of its three races. Zerg plays aggressive and relies on numbers for an advantage, Protoss relies on the strength of its units to crush the opponents, and Terran has versatility to adapt and slowly take control of the map. The races are themed and units are set (at least until the expansion) with small tweaks as needed. It’s a fragile arrangement that requires meticulous and somewhat timid changes to the system.

League of Legends, on the other hand, seems to take the opposite approach. Releasing champions every few weeks and potentially changing the game dramatically. This is not to say that Riot (the developer of League of Legends) is careless, simply that they take a different approach. Relying on the frequent changes allows for the game to stay fresh and new strategies to constantly evolve.

The reason I find the difference so interesting is that both seem to be working. Starcraft II has seen great success across the world and League of Legends has grown tremendously since its first MLG appearance. I find this to be a compelling example of two different trains of thought providing equal success. I take it as a lesson that you shouldn’t always force yourself to follow one path just because someone else has done it. Whats important is the feedback you receive and the passion you put into your project.

Posted 10/18/11 @ 11:21pm - By Ross

Wanted: More Time

Unfortunately I may be getting a cold…not happy! With Minecraft and MLG vying for my attention from projects that are piling up I haven’t gotten much done with Right to Rule. Hopefully I’ll be getting some time in the coming days to start actually implementing the menu system for castles but Blizzcon and the GSL finals are this weekend so…yea.

Either way, I’ve at least started mocking up what I want the layout to be in photoshop. I may post a picture once I finish the mock-up and then start implementing it. It’s always entertaining to look back on mock-ups I’ve made of websites and how they differ from the final versions. I’m hoping to get the same nostalgia kick from this once a few years go by.

Posted 10/09/11 @ 6:09pm - By Ross

Ah, to be a noob again…

So for those that don’t know, I’m TA’ing for CptS 121 again this semester and enjoy it quite a bit. I’ve always had a tenuous relationship with school growing up so it almost surprises me that I enjoy teaching so much. It’s strange to see the same mistakes I made being repeated by others and not being able to convince them that I know what I’m talking about. I think of Elrond from Lord of the Rings and how humanity just ignores his words of warning, despite his wisdom and experience. But I digress, TA’ing has been a good experience and I’ve learned a ton from it.

Speaking of which, I got an e-mail today from one of the students inquiring about game development. Naturally I was ecstatic to find someone else interested in the topic. I’ve met several people at WSU that talk about game development fondly, but rarely with substance. It’s ironic that I’m now the elder from which to seek knowledge when I feel like I’ve barely stepped into the subject myself. But it got me thinking about where I was when I first showed up at WSU dreaming of making games.

When you first start coding, developing a game seems like an unobtainable goal. The complexity is not only overwhelming, but daunting to say the least. I compare that to how I feel now and, while still daunting, it’s no longer overwhelming. I’m doing it with Right to Rule and making surprising progress. I don’t know when the change happened, between freaking out about midterms and starring down the clock as I frantically try to finish a project, it just clicked. I had no mentor to ask how it was done, I just tried and what happened…happened.

I suppose that’s my MO though. I’ve always been headstrong when I decide on a goal. I’m reminded of Day[9] and his unabashed attitude to doing what you love. I’ll stumble all the way there, but I’ll get there. I guess it now falls to me to help those that were once like me.

return 0;

}