Can someone explain how eyeballs are supposed to be made work for Source?

Hey there. I ripped a model from Kingdoms of Amalur: Reckoning, got the textures, rigged it, separated some stuff as bodygroups, done all kinds of things, and everything seems to be working. I’m pretty much stuck at the final step; making posable eyes.
What I’m trying to achieve:

How I’m trying to achieve it:
This is my QC:


$scale 0.38 //because I forgot to scale everything before I started rigging.
$modelname	"metssfm/Alyn_Shir.mdl"
$contents "solid" //don't know why this is here, but removing it doesn't help
$cdmaterials "metssfm"
$sequence idle "Alyn_Shir"  activity ACT_IDLE -1.0 loop fps 30
$attachment "eyes" "bip_head" 11.172699 -5.4241066 -0.00015258795 absolute rotate -7.48869 89.9989 7.85175 //removing this removes the "Eyes" part from the animation set editor.

$model Alyn_Shir "Alyn_Shir.smd" {
	eyeball righteye bip_head -3.268 -8.478 182.38 eyeball_r 1 4 RightEye 1
	eyeball lefteye bip_head 3.279 -8.478 182.379 eyeball_l 1 4 LeftEye 1
}


My eyeball_r and eyeball_l .vmt’s look like this: (which I stole from one of kp’s models :3)



EyeRefract
{
$Iris "metssfm\Eyes" //an eye texture I ripped from the game.
$Envmap "Engine/eye-reflection-cubemap-" 
$CorneaTexture "Engine/eye-cornea" 
$EyeballRadius "1.0" 
$AmbientOcclColor "[.4 .3 .27]" 
$Dilation "1.5" 
$ParallaxStrength "0.25" 
$CorneaBumpStrength "1" 
$halflambert 1
$nodecal 1
$ambientocclusion 1
$selfillum 1
$RaytraceSphere 1 
$SphereTexkillCombo 0 
}



And this is the result: (the eyes have some texture and specular map it seems, but well, no pupils or anything…)

Can anyone tell me what am I missing? Also, I was told that using $scale is bad, if anyone has some tips on how I could rescale everything in 3DS Max without screwing everything up, that’d be great.(just normally rescaling doesn’t seem to have any effect, strangely) I’d also gladly switch to Blender, but idk what format I could export in. Tried .FBX, that doesn’t seem to export any materials nor bones.

Thanks in advance.

I don’t know a great deal about eyes, but you don’t want your eyeball mesh to actually be a sphere. If you look at the HL2 characters, their eyes are just flat planes between the eyelids.

This is because the Source engine eye shader draws a sphere on that flat plane, so if you try to make it render a sphere on top of something that’s already a sphere it’s going to fuck up. That may not be the cause of the issue you’re having, but it’s probably useful to know.

And yeah, scaling anything with eyes or flexes with $scale in the .qc isn’t a good idea. You can scale the root bone in 3ds max to adjust the scale of the model, then re-export everything (including flexes) once it’s scaled correctly. Decompiling and importing a HL2 character is a good way of telling what size your model should be.

This happens when I try to scale the root bone in 3ds max :frowning:

The model’s scale is actually correct, but the skeleton’s isn’t. I tried resetting stretch/scale of bones in 3ds max’s bone tools, but it ended up with bone sizes randomly changing(with stretch) or the character’s skin just going nuts(when resetting scale)

Scaling breaks flexes and eyeballs. in the qc.

In the picture of the face that is in the OP, there is no scaling, yet the eyes still don’t work.
I will also want to use flexes in the future, so yeah, some way to correctly scale the model would be much appreciated. And still dunno how to get the eyes to work ofc.

if you use $scale in the qc it breaks things.

Stiffy is correct.

If you are using $scale in your QC, such as in the one in the OP ($scale 0.38), you need to manually apply that scale to your eye coordinates. Which is to say, multiply the XYZ coordinates by 0.38.

Similarly, if you want your eyes to behave properly in the SFM, you need at least two attachments: the eyes attachment, and some other attachment (I usually use “mouth,” but I know “forward” works, and I honestly think any other attachment could work. Just haven’t tested it.)

And as Stiffy stated, $scale in the QC will also break flexes. In general, you do not want to use $scale. Instead, resize the model in your modeling program before making your flexes and setting your eyeball coordinates. Just makes life easier.

[editline]30th January 2015[/editline]

I won’t say this is incorrect, because I don’t know the gritty details, but I do know that spheres work perfectly fine.

Valve characters have planar eyes because it’s part of their amazingly low-poly paradigm.

Similarly, the sphere-on-sphere projection will in no way fuck up. In fact, my experimenting on this issue has shown that the less spherical the surface your eyes have to travel over, the more distorted they will become at extreme angles. This is generally not noticeable for normal-sized eyes, but if you make really large eyes (like, 15 times larger than HL2 eyes), the effect becomes more apparent.

However, something to be aware of with sphere-on-sphere projection is the diameter. The eyeball control has a diameter parameter, and the more disparate this value is from the actual mesh, the more distorted it will become. Namely, if the diameter parameter is larger than the mesh, the eye will slide too far and too quickly to the left/right. If the diameter parameter is smaller than the mesh, the eye’s movement will be limited and slow.

The more spherical your eye mesh is, the more precisely the diameter parameter will map to it, giving a better overall quality.

Thanks, I’ll try now without any $scale, and I guess I just add another random attachment line in the QC? I mean I do have a mouth model, but I don’t quite get how I’d link the attachment to the actual mouth model. (and what would that give me anyways, an automatic jaw_drop flex? that sounds hard to imagine)

So, here’s what I did, the QC:


$modelname	"metssfm/Alyn_Shir.mdl"
$surfaceprop "flesh" 
$contents "solid" 
$cdmaterials "metssfm"
$sequence idle "Alyn_Shir"  activity ACT_IDLE -1.0 loop fps 30
$attachment "eyes" "bip_head" 11.172699 -5.4241066 -0.00015258795 absolute rotate -7.48869 89.9989 7.85175 // I dont know where I got the last 3 coordinates from, but setting them to 0 didn't change anything.
$attachment "mouth" "bip_head" 0 -9.7710991 175.42592 rotate 0.0 0.0 0.0 //random mouth attachment
//I also tried adding a "forward" attachment, with the same properties as the mouth, but made no difference.
$model Alyn_Shir "Alyn_Shir.smd" {
	eyeball righteye bip_head -3.268 -8.478 182.38 eyeball_r 1 4 RightEye 1
	eyeball lefteye bip_head 3.279 -8.478 182.379 eyeball_l 1 4 LeftEye 1
}

I got a warning sort of message during the compile, but it did compile successfully:

I highly doubt anyone can do anything with this information, but ohwell.

And here’s the result, I made the face textures invisible(alpha 1) to see the eyes better:

The eyes, first of all, seem to be rotated(even when I set the coordinates after “rotate” to 0 0 0). There’s still no controls for the eyes. It also seems like the eye texture is projected onto each eyeball twice, once on the entire eyeball, and once a smaller one. The eyes are also very bright, I tried removing everything that didn’t seem necessary in the VMT, but couldn’t find out what’s making it so bright, or reflective rather.

There are a lot of things gone wrong here, but if anyone has an idea for fixing any one of them, I’ll appreciate it.

The bad projection and brightness are due to the eyeball coordinates being misaligned.

The coordinates you use for eyeballs are the exact centers of the sphere. Since your eyes are hemispheres, you want to use the center vertex of the back.

The lack of viewtarget suggests you still only have one attachment, and you do not have flexcontrollers for updown and leftright, which SFM requires.

You don’t want to manually set your rotation. Just set them to absolute, like this:


$model "mymodel" "mymodel_ref.smd" {
     eyeball righteye "NPC Head [Head]" -1.146 -2.029 60.779 eyeball_r 1.800  2.000 null 0.525
     eyeball lefteye "NPC Head [Head]" 1.146 -2.029 60.779 eyeball_l 1.800  -2.000 null 0.525 
	
	flexcontroller eyes range -45 45 eyes_updown
	flexcontroller eyes range -45 45 eyes_rightleft	
}

$attachment "eyes" "ValveBiped.Bip01_Head" 0 -2.029 60.779 absolute
$attachment "mouth" "ValveBiped.Bip01_Head" 2.20 0.00 2.84 rotate -81.11 0.00 -180.00 // The position of this is NOT important, but it has to exist and be attached to something.


Also note that the eyes attachment should be centered between your two eye coordinates.

Sorry, I don’t understand what you mean by this part, but I’ll try the coordinates of the center vertex of the Iris.

result QC:


$modelname	"metssfm/Alyn_Shir.mdl"
$surfaceprop "flesh" 
$cdmaterials "models\metssfm\alyn_shir"
$sequence idle "Alyn_Shir"  activity ACT_IDLE -1.0 loop fps 30
$attachment "eyes" "bip_head" 0.005 -9.477 182,376 absolute
$attachment "mouth" "bip_head" 0 -9.7710991 175.42592 rotate 0.0 0.0 0.0

$model Alyn_Shir "Alyn_Shir.smd" {
	eyeball righteye bip_head -3.4 -9.477 182.376 eyeball_r 1  2 RightEye 1
	eyeball lefteye  bip_head  3.4 -9.477 182.376 eyeball_l 1 -2 LeftEye  1

	flexcontroller eyes range -45 45 eyes_updown
	flexcontroller eyes range -45 45 eyes_rightleft	
}


Result in SFM:

I now actually do have controllers for the eyes, but when I move around the viewtarget or the sliders, nothing seems to be changing, and I can’t even see where the iris is supposed to be. I changed the coordinates back to the center-of-hemisphere coordinates, and I can see where the iris is, but it’s still not moving. Some progress was made though, so thanks, further help is still much appreciated! :slight_smile:

Sphere on sphere fucks up though. It creates double eyes.

Never has in my experience, at least after turning on raytracing and texkill in the eye VMTs.

Okay, I have no idea what happened overnight, or well, I literally forgot how I did this, but the material now seems OK. It seems I’ll still have to edit it in PS to leave more empty space, because the texture repeats too much, but the eye now looks more or less the way it’s supposed to, so that’s settled. But still no eyeposing, and I can’t understand why. In the meanwhile I’m also poking other people for help, if I ever come up with a solution, I’ll make sure to post it. Further tips in the meanwhile are much appreciated. Also about scaling something with bones in 3ds max.

Well, mostly for the sake of a bump, I’ll post that it turns out that I indeed had wrong coordinates, but now got them fixed, and in the model viewer the eyes now follow correctly. But they still do not move in SFM.

I’ll also post all my source files, in case anyone wants to check it out for themselves.

Bump of hopelessness q.q.

SFM requires that you have the following flex controllers in your .qc for it to generate a viewtarget:

flexcontroller eyes range -65 65 eyes_updown
flexcontroller eyes range -65 65 eyes_rightleft

Sorry for bumping old thread but i need help
When i done rippping and applying texture to model
Then suddenly this happen:
The eye texture resized and centered into middle eye
Then somehow,the teeth texture instead appear in front,its appear backward (inside)