Creating a Procedural Eyeball with Blender 2.8

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
we are going to be creating as you can see on screen a procedural eyeball model and material we're gonna be rendering it with evey setting it up for real-time viewport shading complete with refraction in the eye and the process actually was not that hard the shader I don't think is that complex model is definitely not that complex and I think the result ends up looking pretty good so let's get started them we are going to begin with a brand-new fresh blender scene I'm going to delete everything in the scene select everything hit X to delete and then we're gonna hit shift a to add a UV sphere this is gonna be the basis of our eye and right away I'm going to rotate it 90 degrees so I'm tabbed into edit mode with everything selected our X 9 0 the reason is with a UV sphere you've got the way it's constructed as you've got to geometry polls at the ends that's where all these lines come and converge into what's called a triangle fan and this is gonna create some problems for the shading potentially it creates problems I'm kind of keeping my fingers crossed that we don't notice it once we get to the end but what is good about the UV sphere is that we have these concentric edge loops that can be easily manipulated into being the iris bulge or the corneal bulge so speaking of the corneal bulge let me quickly jump over to my browser and let's just look at refresh what our eye anatomy is like in our heads so let's just look up human eye take a look at a diagram like this one I like so the eye anatomy it's not actually a round ball it's organic so it's roundish and we're gonna we're gonna go with the ball shape but it's not perfectly round and especially the cornea bulge right here is not round it literally bulges out which is where the iris is at so we're gonna want to create this in the geometry and we'll do that very simply but that's that's kind of as far as deep as we're getting into the outside shape of the of the eye we are going to then create another disc inside that serves as the iris and this structure will will work really well to create the recognizable refraction inside the cornea so I want to just take a mental snapshot of this ice structure and the size of the iris all right so I'm not gonna like bring this image into blender and get it right it is just a diagram so I'm going to eyeball it pun intended and then we will create that bulge I'm gonna go into my side view go to wireframe and it looks like this section about matches what we just saw on that diagram so I'm going to select those verts hit s Y to scale in the y axis and that's going to create our bulge and I can just move it forward to continue that smooth line into that smooth contour into the cornea and that's really all it should take we can shade smooth and then ctrl like three to make it as smooth as we can or make it very smooth and that should be pretty good honestly that's all we really need to do for modeling this is the shading artifact we've been talking about if we move it to madcap and something like the car paint shader it gets very very bad shading artifacts it's not that noticeable in the eye but let's go ahead and fix it just to say we did our best maybe move this above the grid floor a lot of you know that that is a pet peeve of mine so let's fix it I'm going to create a new UV sphere and hit ctrl 4 which adds a subsurf modifier at 4 levels making it extremely smooth and I'm going to scale this down and position it to align to the contour that we have in our in our cornea all right so I'm gonna scale it up make it fit as close as possible and you'll see why all right so that close and remember this is a perfect sphere we just created it and the pole is on the top as it usually is by default so this means that the side is the is like optimal smooth sphere geometry so with that created well it's just called sphere oh one let's call the original sphere I and with that created I can tap into the original sphere and delete that middle vertex and then grid fill oh so ctrl F I never use that hotkey that's good to know grid fill right there in control-f usually what I do is hit space and type in grid and that will fix it perfectly as long as it's got an even number of vertices it's going to fill that in with quater geometry and I'm going to rotate it let me look from the front view I like to rotate these so that we have if possible we have a horizontal line continuing all the way across and a vertical line which you can see here once I've created that I'm going to hit let's see vertex smooth vertices and do that a couple times with shift R then I will use my snapping to snap to the face and project individual elements make sure that's turned on and I can hit G and then left click to end the operation and that's going to smoothly snap those verts right on to that that secondary smooth sphere all right so I can even scale this and it's still no no actually I need to I need to enable that to the scale option now when I scale it will continue to snap to the surface all right let's hide the Sphero 1 and let's see if that solves it it really didn't did it vertex smooth vertices and I mean let's see oh maybe what I need to do is turn off subsurf first okay yeah I think that was my problem I put the secondary sphere in line with the smooth version of the I geometry and I needed to put that on the unsmooth Berg I needed to align it to the unsmooth version whoops alright so when I move that you saw that it snapped to the surface and move and went went really wonky all right try this again all right snap from the front view there we go okay so yeah that's gonna be I think the smoothest we can get it and granted it's not perfect so that's that's part of the frustration with this with spherical geometry is you're never going to get it perfect it's going to be imperfect to some degree so if you can while this is less of a shading artifact if you look close you can still see left over square corners from the grid fill that we did leaves those corners and and it's less noticeable but it is still noticeable I mean now I'm getting into the weeds this is kind of why I wanted to avoid this because it ends up being like taking more time than you ever want it to what I did that what I did there was just simply use alt s to just push it in slightly sometimes pushing it in slightly can take care of some of that anyway it was never meant to be that complex when it came to the eye shape but we are going to call that finished it looks pretty good it's definitely going to suffice for this model the next thing we need to do is duplicate a circle that will serve as our iris so I'm going to let's see here probably ctrl R to select to create a new edge loop right here shift D with snapping turned off we're gonna scale it down slightly e s gy e s G Y and an E alt in at center and then scale everything to make it a deeper dome all right that's going to serve as our iris shape and we don't need that edge loop that we cut is just going to unnecessarily make that section of the sphere rigid so ctrl X to remove that and then we're left with our smooth iris are smooth scelera and cornea with the iris as a separate piece of geometry now we're done let's save the file I'll call this record re C underscore a1 all right let's go to we're done with the model so we can switch to our shading tab we're not gonna use any texture Maps we're gonna go all procedural so we're gonna remove that browser window also to do this by the way if you don't know you hover your cursor over any corner of any blender window and you'll see the cursor the crosshair pop-up and you can click and then drag to merge windows alright so we don't need the UV editor we don't need the file browser we're going to create a new material and we're going to call this scelera and underscore cornea all right so if we look back at our Anatomy the cornea is the the dome the clear dome that sits in front of the iris and the scelera is the white portion the eye whites and then the iris and the pupil those are really the only four parts were going to be mindful and as we model this and shade it all right so we've got the the sclera cornea which is going to be a combined into one shader I'm also going to select the interior iris control eye to select that invert you know if you select the exterior invert it and that's how you get that selection in the material section we will add a new material slot a new material and call this iris now right away I'm going to change this color to be like a bluish just a generic blue we'll come back and make that proper but I want it to be blue so that when we make the cornea transparent we'll see right away the difference so we're gonna go back to material preview I don't like to personally see the background so much I'm gonna turn that off and also turn off the look dev preview keep in mind when you have two materials on the same object you might it can be confusing to which one you're editing and you have to be mindful of the slots that you that you are currently have active so we're gonna work on the scelera first and so I want to make sure slot one is selected so the first thing I want to do with the material is identify isolate the the portion of the eye that's going to reveal the iris so the the cornea essentially and we're gonna do this with a gradient texture so I'm gonna hit shift a to add a texture gradient texture and then I have the node or angular tool enabled so ctrl T with that selected will add a texture coordinate and mapping node which is exactly what we need shift ctrl clicking on that also a node regular tool will plug whatever I shift control clicked on and show it's deep it's a it's raw data in the viewport alright so by default the the gradient texture has a left to right gradient across the sphere but we don't want the linear type we want the spherical type this will create a sphere of texture data in 3d space and wherever it intersects with your object that's how you're going to see it projected on to onto your model now we don't want to use the generated texture coordinates we want to use the object coordinates the reason being if I enable our object origin the object type of texture coordinate is dependent like the origin of that texture coordinate is the orange dot the origin of the object so I know it's at the center and that just helps me navigate my way through through this mapping node a little easier also it it it works fine whenever you're rotating the object around as long as you're not deforming the mesh so we've got the object coordinates going into the gradient and I know that there's a white sphere in the middle of a white texture sphere in the middle of this eye and if I move it forward you'll see that it starts to intersect a little more clearly alright and this is going to be perfect for us to add a converter color ramp and we can dial in exactly where that cornea is going to end all right we want a nice smooth edge let's switch it to ease all right so maybe a little bit smaller than that about like this all right so that this creates a factor where the black will be the eye white and the white will creat will be the transparency the refraction so with this factor created I can plug this right into our transmission if you maybe I should make this a little bit bigger the transmission socket of our principle B SDF this will start to create refraction so if I shift control click on that now you should see that we have a white scelera and a transparent cornea however we need to change something so that we can actually see the geometry behind it by default evie does not refract objects in the scene you have to tell it to do that it's more CPU intensive v's you know oriented towards real-time playback so I kind of elissa it like limits the amount of computer intensive things from the start so the way we can turn that on a couple places number one in the settings your so also refractions are tied to screen space reflections so enable screen space reflections open the drop-down and you'll see refraction so we will enable that still nothing happens because you also need to enable refraction in the material settings so go to the material tab under settings change the screen space refraction to turn it on and now it will get a recompile and we should have seen that nuts screen space refraction why didn't that work I think I know what I did not a bug I think I'm just an idiot I never I created the material slot and never applied it to the selection assign it to the selection now I'm going crazy I did do that a sign okay so okay all right so actually if you assign if you tell it if you turn on screen space refraction for the material that's not a transmission transmissive material it will make it disappear okay I'm sure I just probably confused the Meseta you the problem being I did not assign this original iris material to the iris geometry and so it was refracting twice like both pieces of the mesh were refracting I am sorry for that I promise you I went over that like three times thinking like it's a great reveal when you show it working the first time but it's really confusing if you don't get it right the first time and I didn't get it right the first time so I apologize for that but the point being now we have a cornea that's being viewed that transmissive we have refractions for the interior iris material right so we've we've created this gradient section of the node network I'm going to copy that paste it into the iris material and just manipulate it so it becomes the pupil right so this I want to plug into let's switch the flags around we're going to create a nice little pupil all right so bring the flags really close if you want more room to manipulate that you can drag the color ramp out a bit I'll give you more room more room to work with okay now the white flag let's go ahead and make it that blue color very temporary blue color because at this point we have a basic structure of the eye complete with scelera cornea iris and pupil pupil is probably a little bit big though all right now let's start polishing these off to be realistic and believable so the sclera in the back is going to be like red you know bright red where the veins start and then it's going to become a gradient into white or like a yellowish white so let's again we can use the same structure we've already been working with this this gradient this gradient set up and for this I might just duplicate all three of these because I think I will need to move around the mapping node to get exactly what I want so I'm just using the object coordinates I'm gonna hit shift right click and drag to create a reroute node just so it's clear that I am using only one texture coordinate and then for this let's shift ctrl click on it so we can see the raw data I'm gonna switch to b-spline and then drag this out yeah okay so I thought that I might have to manipulate the mapping I want to increase the size of the gradient sphere and with the mapping point type that means taking the value down so point five I'm gonna move it backwards or actually forwards okay now we're getting more of the range that I want so the black can become a dark but very rich red dark herb a very rich red add another flag that's going to be a little bit towards the yellow orangish direction and then finally white at the tip actually make that maybe a little more no that's fine that's fine all right so this is this will be plugged into the color now and we are going to be just a little bit closer to a realistic eye let's turn down the specular value to like point one we want it to look wet but don't want it to look overly wet next we need to add the veins we're gonna do that with a Voronoi texture so shift a texture Voronoi and we're going to also use the object coordinate so let's just plug that in from this reroute node and I'm trying to do a better job keeping my node networks like cleaner and more understandable so we're going to pull that out there and also I need a mapping node so vector mapping you kind of when you do this stuff a lot you just kind of realize like I know I'm gonna be manipulating these texture coordinates so let's go ahead and add it and then you know start to start playing with it kind of preemptively adding the nodes that you use all the time so with the Voronoi texture let's look at that by itself I'm gonna add a converter color ramp change it to b-spline and drag up the black flag alright once we do that we can it doesn't really look like veins but hopefully you can see that veins are going to be to come out of this type of pattern so by dragging the black flag up we get these really fine spindly can interconnection of vernal edges basically alright and that's gonna work really good for the vein pattern but first what I want to do this I'm gonna change the type to normal and I'm going to scale in I believe the y-axis yeah so I admittedly don't know exactly why this works it's just something I figured out while I was playing with it but whenever you switch to normal and scale in Y it it kind of sucks it down into into the tip of the of the sphere where the cornea is so this works perfectly for stretching out this this pattern to be more veiny and then the last step is to add a noise material the noise texture node to kind of wonka phi this pattern to kind of make it wobbly is is how I usually think of it and I'll show you what I mean so texture you see me do this a lot if you've watched me do shading tutorials at all we're gonna add a noise texture and a color mix node we can actually mix a noise texture into the texture coordinates themselves using the color s socket and I'll also use object coordinates for this as well hopefully that's readable alright so we're going to change the mix to be linear light and I'm gonna make the value really low let's just turn it off to begin with and now if I drag it up you'll start to see that all our lines you know become wobbly become broken up with a with a noise pattern and from here we're starting to get into the vein territory let me make the scale a little bit less so if you if you go up it's going to look very serrated is maybe the word I'm looking for so the higher scale value go you get this serrated type pattern whereas the lower you go you get them or curvy pattern so if we increase that hopefully you can see kind of what I mean but we're we have all the the ingredients to get what we want out of these veins at this point and to incorporate them into the color I'm going to add a color mix RGB node and we're going to use this vein black and white pattern that we just created as a factor in that mix and then we're gonna copy the dark red color control hover over it ctrl C and then control V when we hover over color to change the operation to overlay shift control click and we should take a pretty big leap into realism when it comes to this vein pattern what I like about overlay is that you know we have the red being incorporated pretty believably but as we as the color gradient switches to that that slight yellow coloration the the veins also change into that orangish type color and I find that to be very believable and effective to look like the veins and the scelera the white of the scelera are interconnected right if it's just a mix this is a small detail but I find that it's not as as connected I guess and so I like to use overlay here I just really like that slight color differentiation and it looks to me like the we need more veins a higher frequency of veins so the Voronoi scale let's make that higher like 10 that works pretty well we can also adjust the you know we have we have all kinds of things to adjust to get exactly what we want like the color ramp here we can change that all right so if we want a more bloodshot effect or we want it to be a little more realistic and keep in mind whenever we overlay on white they're going to the effect is going to diminish so if we make the white more distinct we're going to lose the veins entirely and so that could be that's just something to be aware if we do want the veins to to diminish as it gets closer to the the cornea and so at this point let's see what it looks like in the final material all right so yeah the veins are actually reaching into the cornea defin not what we want so let's just bring that white value down more like this there we go maybe the veins are a little too plentiful as well so we went from five to ten let's go to seven point five not too bad all right veins are included what else do we have to do on the scelera oh we can use the vein pattern as a bump map of course so that there aren't like the veins on your I do protrude out ever so slightly from the surface so you're gonna use if you look really close at your eye I don't even have my reference loaded what a goober right so we are going to okay right this black and white is going to be perfect for using as a bump map the white will appear to protrude out and the black will stay down so we are going to add a vector bump note take the color of our color ant plug it into the height and I know that the strength of the one is gonna be way too much so let's go to 0.1 shift ctrl click on this and we'll get a rainbow e-type type data set for the for the normal bump data and but you can see that there is a protrusion effect now I actually I want to modify this because it's a little too sanddune like so I am going to add a converter I'm sorry a color RGB curves node and I'm going to make an s-curve which you can't let's let it compile I am going to what I'm doing with this node is basically bottoming out the darks and the lights alright so if I buy this s-curve I'm bottoming I'm yeah I'm bottoming them out on both ends and we're gonna get a more believable kind of vein effect all right so that should work pretty well let's plug this into our normal let's see what that looks like okay so ignore the cornea because now it looks like some sort of weird gemstone but the actual thing Dane's do you have a very nice pattern to them like you can see them the reflections are playing off them like they are an actual vein you know cylindrical vein shape I think it's still too strong in effect so let's go down to 0.05 just to make that a little more subtle this is one of the realistic things I missed for a long time when it came to an eye is that I would just create a sphere it would be perfectly glass like and reflective and it didn't look real because the the surface of the eye actually has undulation from the veins so that is a very important effect however once we get to the cornea as you can see in the reference it smoothes very much I can only imagine that if the surface was like this on the cornea our vision would be significantly blurred so I need to use the same gradient effect right here to eliminate the bump effect from the cornea so I think what I can do is just duplicate this is the only kind of this if i duplicate this shift ctrl d and move it down i've got this very confusing line going down the entire node Network but hopefully that's not too confusing but before we get to the bump node I want to change this gradient to essentially invert it so let's switch the flags around all right and I'm going to shift egg color mix RGB node this is going to be a multiply at a hundred percent so that the black is multiplied over the the data of our veins and so now we should see the veins kind of stopped once we get to the cornea and then I could also like kind of taper it if we go to b-spline I think that'll look pretty good so we can see now that our cornea is very very clean there's no bumpiness going on the veins end but believably before we get to the cornea all right so the sclera and cornea are now finished we can jump over to the iris but before I go there we're going to to create this pattern in the iris we're going to just simply copy the Voronoi nonsense that we did here we're going to copy it remember that we're using object coordinates and we're gonna paste this into the iris material grab the object coordinates make a reroute node and then pull it down alright so this we're gonna use all these but just manipulate them to be more what we want so if we go back to the Voronoi after it's been in the color ramp we should be able to just scale this value up even more first let me let's mute the linear light where we had the noise kind of doing its thing all right so now we can scale this up and and as it pulls to the center we start to get a very believable pattern that looks like an iris so yeah you can see that I hope you can see that we only use a few components right like the gradient along the sphere and we're using the Voronoi texture you know as it's manipulated according to noise scaling it down the normal y-axis and yeah it's kind of it's pretty easy there's simple building blocks to create a fairly complex material so yeah we've scaled that down we have that iris shape let's rien a Belen ear light and we want it to be a higher noise value let's go to 5 and way lower factor we don't want it to be messed up that much all right so now as we start to squiggle these lines that's like actually looking really good alright so let's take that and incorporate it into our original gradient up here that created the colors we can do that with a color mix RGB node and overlay let's mix that together see what it looks like okay so the blue yeah when you overlay overlaying a saturated color typically increases the saturation and the value so it takes this already overly saturated blue and makes it like super stylized very not believable so this is a great opportunity since we've got this color ramp to imitate the coloration in this gradient we're going to need another flat let's just color pick let's start by color picking it starts as a dark color and then it turns to a very light D saturated blue and I'm sure this this image has been photoshopped I mean I feel like eyes that particular color are not common but so you can see color picking that did not really give us the desired results so maybe we'll make that brighter manually take it up in value down and saturation like point 1 5 maybe the darkness let's bring that up and actually there's kind of a little hint of orange in there I mean we can definitely do that whoops I switch to what did I do here let's switch to b-spline all right so with b-spline if I want this black to be really sharp I simply need to drag another black flag up to meet it all right and you'll see that that eventually connects but I want that I don't want a super crisp razor-sharp line at the pupil you can see that there is a little bit of a fuzziness to it all right and then I wanted to add another flag in here that kind of goes into the yellowy spectrum just ever so slightly anyway I think this is a little bit more believable very cool alright so that's looking pretty believable I think one thing I can do is in the picture you can see that the pattern the gradient pattern is wobbly as well I keep saying wobbly I hope you guys know what I mean so that means any time you hear wobbly we're going to add a noise texture and a linear light mix so we will shift D duplicate these nodes and we'll do that to the gradient all right so we're going to take the object coordinates linear light this noise texture let's plug that in you can see that if we slowly crank up the value of the linear light it gets more and more wobbly all right this is great except it also makes the pupil wobbly so similar effect to the cornea whenever we eliminated the bump map from the cornea we can do that same sort of thing let's just duplicate these nodes shift ctrl D we will reset them or reset the mapping no no no no no let me hold up reset the color ramp by hitting the backspace key and also we will use object coordinates here you need to make a little more room for this right so what I need is to eliminate the pupil all right so we will do this kind of thing to make it an ease type all right so black whenever we whenever we plug this into the factor of the linear light black is going to have no effect so no wobbling us and white is going to have full effect we don't want full effect remember that value is really really low so let's take that down significantly all right and let's play with that see what it gives us all right okay this is actually pretty good so you can see as I manipulate this color value we have no wobbly nasaan the outside a lot of wobbly nasaan the outside and almost none in the pupil so this actually worked out really good all right so that's good for the colors in my opinion the last thing we need to do is incorporate the bump map let's see what that looks like we should be able to use it just as is let's look at the raw bump map data it looks like it's not shade smooth okay now it is yeah I think that looks good I want it to be a little stronger so let's go to 0.1 instead of 0.05 drag that into the normal socket all right so that looks pretty good but we have a problem the nor are the normals are showing up inside the pupil so this kind of brings up the point that I don't like specular for the iris I like to turn specular off and turn metallic on okay cuz metallic I don't really know why but it respects the fact that the pupil is black and it doesn't reflect whereas specular will reflect over top of the black and so also you get this really kind of I feel like eyes shimmer you know and so that also makes sense to me to use the metallic but we really get a vibrant effect when we turn on the metallic we are going to save that scene whenever you want to incorporate this into a model because again like well maybe I haven't said this already but I'm not making eyeballs just to have eyeballs like you I always want to put these in characters so if I save the scene ctrl C to copy it I'm gonna open the a'course a model that I built maximum set quality material preview all right so let's I copied the eyes from the other scene so we can simply remove this one control V there's our new eye once it compiles correctly Jake now that you mentioned cycles with this material show up well in this cycles render or I should I should let me turn on cycles and see if it and see if it does for sure or not alright so we're gonna move this into position just gonna eyeball huh that's the second time I've used that pun that one was unintentional there we go that looks fairly believable it can be tricky to position the eye there we go all right so the difference notice the difference between these two eyes the brown eye looks like it's more integrated into the into the head and it looks more believable whereas the right eye seems to be glowing and this drove me crazy when I when I first stumbled into it and the reason is sorry that wasn't positioned quite perfectly the reason is something about screen space reflections negates ambient occlusion so if we look at let's see here screen space reflections this is important again all this is important if you want to incorporate this eyeball into a character let's go back to shading our shading tab look at the rendered version and mess around with the material a bit so yeah if we add an ambient occlusion node input a mean occlusion it is enabled you can see in the render settings shift control clicking on ambient occlusion should show ambient occlusion appear I'm on the iris hold on not what I meant to do go to the scelera add an input ambient occlusion what we should see here is a darkening at the contact points and if we turn off screen space reflection it appears you can see the darkening now so whatever it is about screen space reflections which you need to have on in order to get refraction in the material it eliminates the ambient occlusion so it always feels like your eyes are kind of glowing so we need to fix that and I think I messed up the iris a little bit yeah disconnected it and I want to show you how you can quickly fix it it's kind of a silly fix but we're going to use this same color ramp shift control D all right so let's click on this what we want to do is create that Amy occlusion from a gradient by ourselves since this happens to be an almond shape we can get pretty close with a fake ambient occlusion all right and so if we scale out in X scale down and Z you'll start to see that we can whoops not that one Oh if we change it to b-spline you can see that we can create the ambient occlusion manually and this is how you this is the only way I figured out to get it to work nice with Eevee so let me move that into position a little bit better there we go that reads like ambient occlusion a bit to incorporate it shift a shader mix shader' shift a shader diffuse the SDF and the diffuse of the SDF is going to be pure black it needs to go in slot number one since we're since the a mean occlusion is black so that will be slot number 1 and then slot number 2 gets the rest of the eye and that should look like the eye is set more in the actual lids it's all comes down to the ambient occlusion there we go now that I see it in context this is also where you could adjust the colors like maybe the maybe the white it's a little too white so like let's bring up the other almond color a Hallman via like tan type color bring up the red a little bit you know you can change the veins around but really I think I need to adjust the color here I don't want the ambient occlusion to be too dark but anyway yeah all this is just to show you how to incorporate it better into a model and if we want to make the eyes brown we can simply do that with a hue/saturation node color hue saturation and I know somebody I think McHale you didn't like blue eyes so we can switch that to like a brown let it compile darken the value anyway there's the you actually leave some purple so it might be a better idea for brown let me mute that and instead add color RGB curves all right so if we take the green and blue values down green blue and take the color down there we go that's more of a brown okay so that's gonna be it that that's the eye that's about everything I know about creating a procedural eye yeah any any last-minute questions let me hear them okay so
Info
Channel: CG Cookie
Views: 192,732
Rating: undefined out of 5
Keywords: blender, tutorial, blender tutorial, cg cookie, blender 2.8, blender how to, anatomy, human, eye, eyeball, character
Id: JcHX4AT1vtg
Channel Id: undefined
Length: 41min 7sec (2467 seconds)
Published: Wed Mar 11 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.