Jelly Shader, Part 7: Project Clean-Up and Final Steps

Michael Sanders
2 min readMar 15, 2018

--

Part 7 — Project Clean-Up and Final Steps

This is article 7 in our multi-part series on developing a custom shader for Unity 3D. In the final article in this series we will focus on last touch-ups that will make this shader usable in your next project.

Our project is now mostly complete, but I’d like to add one more variable to the shader and make our shader values configurable from inside the editor. First, inside the subshader, we’re going to modify all our static variables to be non-static. We’re also going to add a new variable to the bottom of the list called _WaveSpeed. That section of your subshader should look like this.

The Mysterious Disappearing Assignment

You may have noticed that we also removed the assignment operation from our declaration. Now that these variables are no longer marked as static, we can’t assign them in their declaration. They will be overwritten when the shader is initialized. This is fine though because we will be passing in values for these variables from our UI.

We also need to expose all these variables to the editor, to do that, add them to the properties section of our shader.

Next we need to actually include _WaveSpeed in our vertex calculation. Add it here.

Fantastic! Our shader is now complete and all of our configuration values are editable from the inspector. I’ve tried to include some sensible defaults for an interesting jelly effect but feel free to play with the values and find your own interesting effects. To find those values in the editor, select the sphere inside the Unity editor and expand the JellyMaterial component near the bottom of the Inspector. The final shader and script code is pasted below for your convenience.

You can also find the final code along with example model on the asset store.

JellyShader.shader

JellyClickReceiver.cs

Originally published at heliosinteractive.com on March 15, 2018.

--

--

Michael Sanders

Director of Interactive Development at Helios Interactive. And part-time Pirate.