Membrane

Hello, everyone! This is going to be my last post talking about my membrane prototype. I have been working on it for quite a while and I am fairly satisfied with the result. There are, however, some things I couldn’t get to work, even though I tried to. For example, I could not implement @tjwhale’s lunging behavior while at the same time eliminating the “jumps” you can see in the membrane. Nonetheless, I did end up rewriting most of my code to use tjwhale’s method as it provides a lot of flexibility and turned out to be a lot faster than mine was, so thanks for that.

One thing I did manage to implement that I thought was cool is phagocytosis. The player is able to pull on the cell membrane and stretch it out to cover an object, be it an enemy cell or a compound cloud, and when he lets go, the membrane smoothly glides back to its original shape.

So to reiterate, I finished my prototype—I am now able to create a smooth looking 3D membranes from the organelle positions—but my program only manages to create static membranes (they don’t deform at all as the cell moves forward or rotates). My question becomes, are you guys fine with this or not?

If you are, tomorrow I will begin porting this to the actual Thrive game. If you are not, I can continue trying to fix it and make it dynamic and maybe something will happen.

Here is a wireframe of one of my models:

And here is the respective positioning of the organelles:
http://forum.revolutionarygamesstudio.com/uploads/default/original/1X/2c5a76fb87afb63d2d3cd86cafca8900ea647d8f.png

That is awesome!

The way my prototype works is that it moves the organelles and that causes the membrane to move, have you tried that to get the membrane to move?

If you want any help or advice with it feel free to post your code. Happy to do anything I can to assist.

Woo, membranes! Great work!

For now this is absolutely fine. In the future it’ll need to be fixed, but at the moment we really just need something that looks more attractive and realistic than the arrangement of hexagons already in place. I assume your algorithm doesn’t handle collisions since you didn’t mention it? That might be a little more important than other environmental distortion.

Yeah, the things is that when I move the organelles, this happens:

The problem is that I average out the location of the points only when they are more than a set distance away from all the organelles. This can be fixed by making the organelles push really hard on the points, but then you can see jumps in the membrane which look too artificial. I could give you the code to play around with if you want. Hopefully you might find something I missed.

I was going to complain about the deformation going on in the center of the mesh (ie, the sharp point on the near and far flat sides), but then I realized that it would not matter at all, because we’ll be using fresnel shaders. Very smart, good job.

Making the membrane respond to organelle movement is not necessary right now, and would probably require something like what tjwhale did with repulsion terms etc. That would probably necessitate changing how we construct the cell’s outline from your bezier/slope trickery, but the good news is that we could keep what you’ve done to turn the outline into a 3D solid.

I think I’ve managed to make it a little better, see this video

What I did was simply change this function

def checkdistance(self):
    truelocation = self.pos + Vector(centre[0],centre[1],centre[2])
    for pt in controlpoints:
        distance_to_organelle = distance(truelocation, pt.pos)
        if distance_to_organelle <= 200:
            spherical = tospherical(self.pos)
            spherical.x += 30*math.exp(-distance_to_organelle/100)
            self.pos = tocartesian(spherical)

So basically the vertices flee from the organelles BUT when you are far from them flee slowly and when you are close to them flee faster. That way thy don’t suddenly jump. What was happening is that before I had it so if they were less than 100 they would add 30 to their radial coordinate. So they would be 102,101,100,130,129,128 etc and that was a bit horrible, I think this rather nicer they now flee at 30*exp(- distance/100) which decays nice a smoothly as they get further away.

Hope this is helpful! If there’s anything else I can do let me know,

Shouldn’t really be too hard to fix, either way. I originally put it there as a place-holder and was planning to code a triangulation algorithm later, but eventually I realized that since we aren’t going to put an actual texture there, we shouldn’t worry about texture warping.

Too late :stuck_out_tongue: Everything works now!

You are truly amazing! I took a look at your code and now everything works perfectly. I was already using an exponential function to control the movement, but no matter how much I tried I couldn’t make its look good. Interestingly enough, here is the function I used:
20*exp(- distance)
I was just one operation away from perfection :wink: Thanks again,

Here is an image of when the cell is moving upward fairly fast (the faster it goes, the more stretched out it becomes):


Keep in mind that it will be smoothed out even more once I make it three-dimensional. Eventually, I also plan to add motion blur to make it look even better.

No problem, very glad I could help. I think in general I am trying rebrand myself in this project from Theorist to Programming Assistant. The main thing I want to do is help people build stuff so this is really pleasing. I’m glad you’re making good progress. Let me know what I can do to help, whatever, whenever.

Time for another membrane update! For those of you not on slack, it might look that I (and the rest of the Thrive team) have disappeared for almost a month. Let me assure you that it isn’t so. Below is a picture of the current prototype of the membrane:


It has no organelles, is of one color, and has no collisions implemented—yet—but it is already so much better than the honeycombs we had previously.

I am looking forward to your critiques and suggestions (note that the jagged edges will be fixed once I turn on my sub-surf algorithm).

Edit: Fixed the jagged edges :slight_smile:

Awesome. *Applause.

Ah yes, here it is—the final, rendered version of the cell membrane. It looks done; however, the material is only semi-permanent. Rather than messing with shaders, I simply used a texture that I laid over the vertices. Some day I will get to fixing it, but if we want to get this into the next release, it will have to do. Plus, I’d say it looks good this way too, even if it’s not at all customizable.

Anyway, I am now going to take a break for a few weeks, but when I get back I will start working on the physics (note the three cells in the top right) and getting the organelles back inside the cells.

Cheers.

Edit: Silly me, forgot to upload the picture :blush:

3 Likes

Sorry for double posting, but I have done some more work on the membrane. I have created the following semi-transparent texture for the membrane. The one I had previously looked good, but you wouldn’t be able to see the organelles in it; plus, I think this actually makes it look more “celly”.

Comments?

Also, for those of you who don’t know this yet, I added physics, so you cannot go through a cell anymore. Basically, at this point I think that I am pretty much done with the membrane, and am ready to move on to some other part of the game.

3 Likes

It looks amazing! The only thing I can think of for adding in the feature, besides the point where we try to make them move dynamically, is varied colourations for different species, and allowing the player to change their colouration in the editor. The texture especially looks very nice.

Incredible work! I can’t really tell from the screenshot, but how apparent is the 3D-ness of the cells when playing? Have you made any progress on finding a way to map the flagella to the membrane edge?

The next release is going to be epic.

Well, as I mentioned before, I’m using a colored texture instead of a shader, so it’s not that easy to change the color. But now that I think about it, I guess I could use a black and white texture and then color it in in the .material file.

It’s not apparent at all—the center of the microbe is completely transparent, so you only see a rough outline. But isn’t this how microbes look in real life under a microscope?

I’ll get working on it as soon as I have some free time, but I already have an idea of how this could work.

Edit: Okay, I’ve started working on the flagellum. It seems to be a lot easier than I had originally thought.

1 Like

Sorry to revive this thread, but my post is 100% related to this topic, so I didn’t want to start a new one.

Anyway, I was reading this interesting paper about how cells maintain their shape (basically, they have a high pressure on the inside, which inflates them similar to a balloon), and I thought that it would be interesting to code that in c++. Anyway, here is the result after a few hours of tinkering.

Possible improvements that I see: add drag forces to fix the unnatural acceleration (just friction looks really wonky), add springs on the inside that will act as microtubules, giving the cell a nonspherical shape, and allow the membrane to be manipulated by dragging.

Cheers.

4 Likes

That looks cool.

IMO the trick to the dynamic membrane is going to be doing the calculations for it on the gpu. That way they can be super fast when you have a lot of microbes on screen.

Looks great! Though I do strongly disagree with the idea of clicking and dragging to move the membrane, because I feel it’d get really annoying and tiring after a while.

Yeah, that might not have been the best idea. I think we agreed on the community forum thread to only have engulfment be drag and drop and have everything else be normal WASD or click where you want to move. Would be easier to code that way too.

1 Like

IMO, engulfment should be WASD too. To me, click-and-drag engulfment in a game where movement is based around the WASD keys (assuming you’re gonna use those for regular movement) seems really awkward and counter-intuitive.