Hey to all,
I'm trying to create an dilation like shader for UDK.
Basically, the same effect of Iris/Pupil dilation of the eye, kinda like this shader:
http://carlosmontero.com/shader_eyeball.php
Problem is, my dilation of the texture doesn't work correctly. It 'expands' my texture (EI: making them larger) without a proper center position (EI: stretching from the middle to out with a stretch tolerance) .
So basically, anyone know of a cheap way to this?
Cheers!
Replies
That may not be the best approach, but it worked for me. Hope this helps!
Edit: Now that I actually thought about it for a minute, you could also warp the UVs coming in to your texture sample and distort it against a radial ramp from photoshop. Not sure how clean it would render, but just another thought.
I also tried using a Tan function to get the correct single expansion, but that didn't work either.
use a simple greyscale texture to paint where the pupil is white. have it falloff/feather so its like a bright phong highlight covering the iris.
Make sure the parts you don't want to scale are black. not dark. Black.
Multiply a scalar parameter, called say, "iris" by this texture, then append the output so that its a 2vector. Add that 2 vector to a texcoord node, then plug the result into yoru uv's.
A value of 1 will be no distortion, values less will constrict, and higher than 1 will dilate.
You CAN do this entirely programatically with a product of sines or gaussians and some manipulation to get it into the right place, but the texture is easier to explain.
Thanks Vailias, however, I'm still having a weird issue. It seems like my texture is being dilated AND twisted around the corner. I both tried a soft radial texture and your Gaussian function, but still no dice.
Also, for fun, I tried putting up my Iris parameter, a Light Vector instead, and I'm getting an overlay like effect at certain angles, is this normal?
The test package if you want to take a look: http://www.mediafire.com/?ipdmm89dwm4s376
also your package is only 81k when I download it. Is that right?
Also, yeah, I just uploaded the shader since my UDK keeps on breaking my links for the functions and textures. I have a separate file just for this issue with the textures in it: http://www.mediafire.com/?2ca3qoh0ehpi58i
This file doesn't have the shader in it BTW.
Credit goes to Carlos Montero for the textures and you for the Gaussian :P
Now I'm trying to figure out how to clamp and get actual values of light distance from -1 to +2 so that the dilation is light dependent, but am unable to get it right, the eye just...wobbles in place when I put up the light. As it shows in the image, the light wobbles the iris on the RG axis, and doesn't actually spread linearly.
If anyone has tips about this, I would like to hear it.
EDIT: OK, a cosine/sine function with a linear clamp works wonder for the dilation amount, but I'm still getting the wobble and weird overlay issue previously mentioned.
This is a little simpler instruction wise, but same concept. The distortion texture isn't perfect either, thus stretching it really wide open would give an uneven circle. But for smaller values as demonstrated in the image, it works good enough.
Hope this helps!
Haha, if anything, it was your shader which enticed to me to look into this ;P
Also, hope it's OK I'm using your textures are placeholder for now, I can take down the package if you like, just wanted to use them as an example.
@imbuefx: Where were you, when I need it mate ;P
For light direction control It gets a bit harder as you need to control the scale of the entire shader based on the light vs the object, NOT the light vs the normal of the vertex or pixel in question.
I gotta jet but see if more experiments help.. In the mean time, here's another network and examples.
edit: Fwiw the texture based one with that whorl looks freekin amazing in motion.