Tuesday, August 26, 2014

Water is Fancier Than You Think


Progress? On my project? It's more likely than you think. As you can probably see from the above picture, I've been working on water. While it may not look that impressive, this actually involved several significant changes. To get to this pretty scene, I had to do the following:
  1. Deal with having two blocks in the same spot (for water intersecting the shore).
  2. Add support for transparency.
  3. Remove internal faces from between world chunks.
  4. Add support for non-solid blocks (so that the player could walk through the water).
  5. Add support for animated textures.
Lets cover each of these in detail:

1. Deal with having two blocks in the same spot (for water intersecting the shore).

Allowing each cell to hold two different blocks would double the memory I'm using, so that wasn't a feasible solution. And if I ever needed three in the same spot, I'd be back where I started. 

The obvious answer was to use extensions (the same technique I'm using for vegetation and decals). However, I wanted the water to look like one large body, rather than a bunch of cubes. This meant eliminating internal faces. Unfortunately, extensions don't take adjacent cells into consideration during the mesh building phase.

So I introduced a new extension type for blocks. The meshing algorithm was modified to handle these the same way it handles normal blocks.

2. Add support for transparency.

For those unfamiliar with game programming, properly handling transparency is actually quite difficult. To get it looking right, you have to render the faces from back to front. Unfortunately, the most optimal way to render non-transparent things is front to back (and with blending turned off). Thus, the best solution was to create two meshes, one opaque, and one transparent. The opaque meshes are rendered first, front to back. Then blending is turned on, and the transparent faces are rendered back to front.

I also had to modify the meshing algorithm to account for the fact that transparent faces don't hide opaque ones. There are also still some problems that can arise from having multiple layers of water in the same chunk that I have yet to fix.

3. Remove internal faces from between world chunks.
Until I made this change, the meshing algorithm only took into account blocks in the same chunk. Unfortunately, this lead to underwater walls being generated between chunks. I had to modify the algorithm to take neighboring chunks into account. This also meant waiting until all those neighbors were loaded before running the meshing algorithm in the first place.

4. Add support for non-solid blocks (so that the player could walk through the water).

This was relatively easy. I simply added a flag to each material indicating whether it was solid or not (likewise with transparency). This flag could then simply be checked in physics, and non-solid blocks could be ignored.

5. Add support for animated textures.

I spent a long time thinking about ways to accomplish this. The solution I settled on ended up being stupidly simple. I simply built a table of animation info. that corresponded to each texture. This info is passed to the shader, which does some simple math to figure out which texture to draw each frame.

This did force me to start using array textures, but that also got rid of some aliasing, so it was a good move all around.



I also did a few other miscellaneous things, including some minor optimizations and bug fixes. All in all, it was a very productive week!


Tuesday, August 19, 2014

Sex Talk

So heads up, gonna talk about sex (and rape) in this post. If you don't want to read about those, turn back now.

The idea that sex is bad is something that permeates our culture so thoroughly that it's difficult to even see it as a cultural idea. However, it's not hard to find examples of cultures that were/are more permissive. Many went so far as to promote it as an important part of human life, and not just as a means to procreate.

However, sex is far from a riskless behavior. So what are some legitimate reasons to avoid sex? Unwanted pregnancy is an obvious one. In general, contraceptives are highly effective, but not perfect, and unexpected pregnancies do happen. The second obvious problem is STDs. Again, contraception can go a long way to prevent transmission, but there's always some risk. There's also the danger of physical harm when sex is done improperly or forcefully, especially in the case of anal sex.

So if sex is so risky, aren't we justified in tabooing it? Well, first of all, it's not that risky. Even though bad things can happen, the vast majority of (consensual) sexual encounters are completely harmless. Furthermore, there are plenty of benefits to having sex, both in the short term and the long term. And it's not hard to think up other risky behaviors that receive comparatively little scrutiny.

And yet it becomes a historical controversy when a woman's nipple is exposed for a few seconds. It's considered inappropriate because it reminds us of sex, and sex is bad. And if you think nipples are scary, let me tell you, they have nothing on penises. Nudity is completely harmless, yet society is outright frightened of it.

A little while ago, an idea struck me. It occurred to me that people might be sensitive to sex and nudity because, well, people are sensitive to sex and nudity. That is to say, people get nervous about sex because they live in a culture that tells them (implicitly and explicitly) to be nervous about sex, and that nervousness they feel tells other people to be nervous, and so on.

Sexual assault is, of course, highly traumatizing, but I can't help but feel that it's made even more traumatizing by this attitude. Rape should absolutely be taken seriously, but could it be that taking it too seriously actually makes it harder for survivors to move past it? Even the term survivor, while probably better than victim, puts rape on a level comparable to death. For survivors, it may feel that way, but how much of that feeling is a result of the culture we live in?

Tuesday, August 12, 2014

Diversity

Diversity. It's something you hear about a lot. Specifically, about how we need more of it. And while I don't disagree, I think we sometimes lose sight of why we need diversity and why a lack of it is a bad thing.

In my opinion, diversity isn't a goal in and of itself. The real goals are equality and representation. When you have those, diversity should arise naturally in a way that mirrors real life. Worth noting is the fact that some mindfulness is required to make this happen. Even in the most egalitarian circles it's easy to under-represent minorities simply because they're less visible.

Which is precisely why representation is important in the first place. When a group has low visibility, we tend to ignore it, often unintentionally, making the group even less visible. This effect is even more pronounced in media, where appealing to the largest group of people is often advantageous. This process also isn't limited to literal minorities. Women are terribly underrepresented in media despite making up half the population.

Additionally, not all representation is equal. The presence of minority characters is not enough if those characters don't receive equal treatment. When representation is done wrong, you get token characters.

There is a unique challenge when it comes to representing queer characters. Unlike race and sex, sexuality and gender identity often aren't obvious. On the one hand, unless it comes up, we have no way of knowing if a character is queer, and hence no representation. On the other hand, overplaying a character's sexuality/gender identity can reduce that character to a single trait. It's a fine line that can be hard to hit, even for writers with first hand experience.

There are similar challenges when it comes to religion. However, religion is often correlated with race and can sometimes be inferred from a characters clothing (a cross necklace, hijab, etc) and speech.

Anyway, the bottom line is that characters belonging to group should appear at least as often in media as they do in real life. This isn't a moral fact, just a statistical one.

---

In other news, I have a job offer! I have not officially accepted it yet, as I was still interviewing with another company when I received the offer, but I will be making a decision before the end of the week, with proper employment following soon after!

Tuesday, August 5, 2014

When Life Moves Quick

It completely slipped my mind that today was Tuesday! I don't have much of an excuse. All I can really say is that life's been moving quickly lately! Last week was both fun and stressful. We went on a trip to Tahoe to spend a few days with friends in a cabin we rent every year. However, our car started acting up right as the (700+ mile) trip was coming up. Additionally, I had an interview scheduled for the day after we got back. There wasn't really time to do anything about the car so we had to do some contingency planning. Fortunately, everything ended up working out. I think the interview went well too, but I'm holding my breath until I hear back.