20
\$\begingroup\$

I want to create realistic pizza and allow user interact with it.

What I want:

photograph of pizza with a slice being lifted

What I created:

screenshot of rendered pizza, with a slice missing

I created model of the pizza (8 pieces) in Blender, then imported it into Unity. The piece of pizza looks very artificial, mostly because it is "rigid triangle".

How can I make the cheese stretch and break when the user moves a piece?

\$\endgroup\$
8
  • 1
    \$\begingroup\$ Better models, better textures & better shaders. As simple as that. \$\endgroup\$
    – API-Beast
    Oct 1, 2014 at 14:40
  • \$\begingroup\$ Are you actually wanting the cheese to stretch and break? If you could be more specific about what aspect you want to be more realistic, that would help narrow the scope of the question. \$\endgroup\$
    – House
    Oct 1, 2014 at 14:42
  • 2
    \$\begingroup\$ @Byte56, I understand that I can improve quality of pizza via improving model, textures and shaders, but I interested in cheese. Yes, I want it to be stretchable and breakable. Like real cheese. \$\endgroup\$ Oct 1, 2014 at 15:01
  • 6
    \$\begingroup\$ Personally, I would take a look at realtime cloth simulation and see how far you can get from cloth to cheese by tweaking parameters. I would handle the cheese layer of the pizza as a seperate mesh and use a spring/mass model to compute deformations. I've also seen cloth systems before, that let you rip the cloth apart, which you would want for your cheese as well. Combine this with a shader that blends from a solid cheese texture to a streched/ripped cheese texture based on the force applied to the nodes of the spring/mass model, and it should give you a pretty neat result. \$\endgroup\$
    – Invor
    Oct 1, 2014 at 15:23
  • \$\begingroup\$ Just to play the devil's advocate here, are you sure you need to have this kind of animation? I know it's sounds strange to ask, but you should see from the answers already given, this is a fairly complex effect you're aiming for. Obviously it depends on the game (I don't know if you're making a Pizza making simulator [I know people who'd pay good money for one]), but you should ask yourself if the work you'll put into this really adds enough to justify your effort. Even if you have a lot of time, devoting it elsewhere might pay off more in the long run... \$\endgroup\$ Oct 1, 2014 at 23:53

3 Answers 3

28
\$\begingroup\$

The Simple Way

Add a quad which connects adjacent slices to each other. Texture this with a nice, melted cheese texture, complete with holes. As the slice is moved away the quad will naturally be stretched and thus stretch and skew the texture.

This should look reasonable, although there will be no break. What to do here is make that texture an animated one. Iterate through the animation based on the quads area (or just the distance between the slices) instead of time. As it gets pulled further away more holes will appear due to the animation progressing.

Eventually when a distance threshold is hit, split the quad into two, programatically shrink the two quads in the direction of their attached slices to shrink them a bit and keep the animation playing which shows the snapping. Freeze the animation at the end.

For a bit more dynamics, you could attach the quad to the two slices using a joint in a physics engine.

The Hard Way

Use a soft-body physics engine or write one. Define a cloth section between the slices and texture it with cheese. Allow the physics engine to model the dynamics of the material stretching and snapping.

This is a far more intensive, but more generally applicable method. It may also be very uncontrollable but could be an overall more compelling effect.

\$\endgroup\$
7
  • 3
    \$\begingroup\$ I would totally suggest the first approach. \$\endgroup\$
    – jhocking
    Oct 1, 2014 at 16:46
  • 6
    \$\begingroup\$ At the very least, spend a few hours trying the first approach (you could easily use multiple quads) before you spend a few ... err... months writing a physics engine... \$\endgroup\$
    – corsiKa
    Oct 1, 2014 at 17:43
  • 3
    \$\begingroup\$ So hungry to see the result! Please update us when you finish it. \$\endgroup\$
    – John Moses
    Oct 1, 2014 at 18:11
  • 3
    \$\begingroup\$ For a moment there I thought I read "Use a soft-body cheese engine" and thought, wow, people will write engines for anything. \$\endgroup\$
    – Thomas
    Oct 2, 2014 at 0:26
  • 2
    \$\begingroup\$ Unity has a built in cloth physics engine that supports stretching and tearing so the hard way might not be so hard. Although it will be far more computationally expensive. \$\endgroup\$ Oct 2, 2014 at 2:22
2
\$\begingroup\$

@originalDaemon's answers are good! I think there is a middle way that may get better result than the first approach and will take a reasonable amount of effort (perhaps unlike "The Hard Way" approach).

What I suggest is too actually model the cheese "web", it looks a lot like stalactites to me. Model a few pieces of stretchy cheese. Randomly position them on the edges of the triangle of deliciousness and scale them to 0 on y-axis and when the triangle is removed from its compadres, slow scale them on y-axis back to the needed size.

You may need to choose another axis instead of y if you plan to pull the triangle slightly away. Either way, I feel that although a flat texture would be a lot easier and cost-effective, modeling the cheese could turn out more realistic for close-up although a texture might work too. If you do choose a texture, maybe use more than one layer to get a more realistic feel. Also don't forget to add a little steam perhaps to emphasize the hotness of the pizza in the shot.

Another thing I noticed is that it appears the pepperoni is only a texture right now. I would definite consider modeling it or adding some detail in that area to the existing model. You could makes it slide down with the stretchy cheese for extra realism.

\$\endgroup\$
2
\$\begingroup\$

Using a preset animation:

So create preset animation in a 3D modelling software like Maya/Blender which has features like soft bodies and cloth that can do a good job simulating the pizza tearing. Export both the pizza texture AND the model animation to Unity (probably as a set of .obj models or some such).

The model animation will represent the cheese being stretched and torn using many many triangles, which you can load as a set of tri-meshes into Unity. They are collection of many mesh states, each representing the cheese pizza at different positions of stretching. Based on where the user positions the pizza slice, you'll jump to that 'mesh state' and display those triangles.

There're a few problems of-course. The user interaction is a bit restricted. If cheese is already torn a bit, you can't go back to 'untorn' state for that area of cheese. If the preset animation removes slice 1 and then 2, the user will be forced to remove the slices in that order. The size of data exported can become pretty big, based on how granular the mesh is and how long the tearing animation lasts.

But it can look very realistic, if the model artist does a good job when creating the preset animation. And you don't have to implement a soft-body simulator.

Using Unity:

But in-case you're interested Unity does implement its own Skinned cloth and Interactive cloth components. The interactive cloth supports tearing. But support for them are restricted to only a few platforms, last I checked.

Using you:

In the end, you can always implement your own soft-body simulator. Here's a sample research paper that's pretty popular. It is a lot of fun :). Good luck.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .