OK HI i wanted to put these on here so all my tutorials werent trapped on patreon. this ones a breakdown of this bad boy:

so before we get to the Shaders lets talk about the model and the textures. the three of them are honestly always going to go hand in hand in hand. i've gotten a decent amount of comments on this mentioning that I was probably following a blender donut tutorial to make this. TRY AGAIN

i went out and got a donut and 3d scanned it. the app i use is one called "AR Code", which i don't have much to say about other than it was the one that worked the best out of a few i downloaded it, unfortunately, turned out a little bad! this is what will happen if you try to 3D scan something shiny, but i wanted the shiny donut over the matte one because it looked tastier. the texture of the frosting is also all kinds of messed up but it's ok, because we aren't actually going to be using that part of the texture

nothing that a little bit of sculpting in blender can't fix! after sculpting, and then vertex coloring the frosting on the donut, i got it looking presentable

using a matcap (on the left) can help a lot with this. when you want to go for a "tactile" feel, a lot of the intricate details out of your shader are going to pop up from how the normals of the model interact with it. so making sure the smooth parts are smooth and the parts that jut out jut out are going to end up going a long way now that we have the model, the textures, and the vertex colors masking out the frosting, we can get to working on the shader. the vertex colors are there because we are essentially just going to replace the real frosting with our own shader, and leave the actual donut part as it is, to give a bit of contrast between the realistic donut and the stylized frosting we're going to make. we also didn't bother with baking it down to a lowpoly mesh, since this is just going to be a GIF on the internet and not a game asset

the shader


the whole donut is one single shader - we use the vertex color to blend between the icing and the donut. full white means 100% donut, and full black means 100% frosting. we'll talk about what happens if it's in-between later the donut itself is really simple. all we have is a bit of fresnel shading and just the most basic "normal dot light direction" lighting, offset the tiniest bit to make sure the whole mesh always has a little bit of light, even the darkest parts. the 3d scan also came with a normal map, so that helps make sure it doesn't look too simple. i do want it to look a bit photo-realistic after all

the frosting is where i make sure it really shines! i use three textures for it: a black & white mask and a color texture for the base color, and then some random noise for the sparkles

the two textures on the left i've gotten from the excellent free noise pack by Luos. he makes amazing textures and i cannot recommend enough checking them out for yourself for the base color, i sample the left texture to get the strength of the parallax effect, then sample the left texture again with the parallax effect now in place to get a value. then i multiply that by the color from the middle texture to get my base color next i add a fresnel effect like i added to the donut base, but additionally i add environment reflections and some sparkles. the sparkles are also affected by the parallax from earlier lastly, i use the technique written about by Alan Zucconi in his excellent blog series on iridescence here to add physically-accurate CD refraction grating, giving it that iridescent rainbow finish. i've added a second uv map to the donut that's just an aerial view so I can use the same math Alan used in part two to get proper CD-ROM tangents circling along the donut

and last but not least, i faked some ambient occlusion between the donut and the frosting by darkening any part of the mesh that didnt have the vertex colors at exactly 1 or exactly 0 (so anywhere it was transitioning between donut and frosting). gives the frosting some very convincing depth!!

and that's it!! except for the slice taken out of the donut!! this was added at the last minute when I decided to double check the item description since it's been 4 years since I told myself I was going to model this. and what do you know it turns out it's a bagel and not a donut. I boolean-ed a slice of the donut out to cover my tracks and it just worked straight out of the box. now no one will know thanks so much for reading!! feel free to ask if you have any questions or need any clarifications