Pizza Shader

Pizza Shader

Joking around, my friend and I were talking about “Bredtangle Pizzas” that were rectangular pizza’s often sold in schools in the USA. We were tired from work, at the end of the day, and starting to get silly. We came up with the idea that Bredtangle pizzas were actually farmed, and a harvester with big Pizza-cutter wheels drove over the pizza crop and sliced them up in rectangles.

We rifted on this idea quite a lot. For example – this takes place on a different planet, where the sun is about 320º. Pizza seeds determine sauce and cheese type, so you could have Marina-Mozerlla seeds, or Pesto-Provolone seeds. If the seeds are just tossed onto the soil, you get hand-tossed pizza. If you bury the seeds deep, naturally you would get deep-dish pizza.

Want Parmesan or peppers on your pizza yield? Clearly you gotta load up your crop-duster with the desired topping and fly over your pizza-field sprinkling delicious cheese/pepper dust. Literally crop-dusting your Pizza field.

I won’t go into full detail of our silly idea but we mused on actually creating a VR SIM kind of game out of this – a farming sim, where you grow pizza from the ground. As a prototype experiment, I made a shader that can take a flat plane and simulate the growing of a pizza from the earth. It starts as dirt, raises some dough, sauce naturally grows in, followed by some delicious cheese.

This was designed and implemented in Unity.

Using multiple textures and custom designed maps, the shader can be driven to render pizza grown to various degrees on a per-pixel/texel level, thanks both to my custom fragment shading and DX11 vertex shaders to displace the height of the plane. The plane, is of course, subdivided into hundreds of faces. Despite the highish poly-count geometry it’s still relatively conservative for game-engine real time rendering.

In addition to rendering a pizza growing from the ground, there are also some meta-maps for the shader that include detail like water saturation on the ground as well as things like support for on-theme fertilizers. Such as a fertilizer for extra cheese or extra sauce. Of course there are also more practical fertilizers like faster growth.

I also designed worker-shaders that could modify the meta-maps over time. For instance, one meta-map stores the wetness of the field per texel. That is, pixels that were watered (olive oiled in theme, lol) would grow faster. The growth map would drive the pizza shader to show more grown / developed pizza. The wetness-map (oil-map) dries over time, requiring the player to continuously oil their field to accelerate pizza growth. The drying of the wetness-map and progression of the growth-map were all handled in the GPU via these custom worker-shaders.

The entire system was designed around these custom texture-maps, and all it required was the ability to project image data onto a textured plane. In other words, the wetness-map for example, was just a gray scale texture but “watering” your field would just “paint” solid white to the texture to represent areas that were wet. Over time, the worker-shader would periodically adjust the wetness-map to be darker. Bright spots – aka wet spots – would slowly dry to “black” in the wetness-map, via the GPU.

So far we haven’t pursued the idea further, but I am surely proud of the shader system I designed. Below is a video I hand – animated to some music by The Fat Rat. The video below shows a mildly textured plane of dirt, growing and… well… ungrowning a pizza from the earth! Maybe someday we’ll turn this into a full VR Farming SIM style game!

BTW, the shaders were designed in Shader Forge which is now free for Unity. I’m not crazy about writing shaders / CG Code from scratch, but Shader Forge makes it easy. I feel like a node-based visual workflow is ideal for shader generation. Especially coming from a Blender background. Of course Unity 2018 has a built-in node-based workflow for shader generation (as Unreal has had), but I feel like it’s not as mature as Shader Forge yet – at least as the time of writing. Still though, shaders are powerful and I’m proud of this pizza-growth shader system. Using GPU’s FTW!

July 19, 2018 at 7:41 am | Code Projects

 

Add Comment

* Required information
(never displayed)
 
Bold Italic Underline Strike Superscript Subscript Code PHP Quote Line Bullet Numeric Link Email Image Video
 
Smile Sad Huh Laugh Mad Tongue Crying Grin Wink Scared Cool Sleep Blush Unsure Shocked
 
1000
 
Notify me of new comments via email.
 
 
Powered by Commentics

Comments

No comments yet.
© Greg Miller, 2009-2024
2fc29791367c6a4ba13727b560c2f2bd7c5945e536a239782d