Author : Nate Broach


Reply
Reply
 
Thread Tools Display Modes
Ace-Angel's Avatar
Old (#1)
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!
There's a very good chance that I experienced MORE problems, then all the internet put together in the area of 3D. Talk about being original for once...
Offline , veteran polycounter, 4,498 Posts, Join Date Apr 2011, Location Canada  
   Reply With Quote

imbueFX's Avatar
Old (#2)
I had to do something similar when I was new with UDK. The trick I came up with is to lerp between to texture coordinates. One being the open state, the other being the closed state.

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.

Last edited by imbueFX; 01-26-2012 at 04:44 PM..
Offline , triangle, 250 Posts, Join Date Nov 2011, Location Denver, CO  
   Reply With Quote

Ace-Angel's Avatar
Old (#3)
That's what I was thinking, but I'm having a hard time in getting UDK to behave properly with my UV's, no matter what I try, it doesn't help since it enlarges my images instead of warping them.

I also tried using a Tan function to get the correct single expansion, but that didn't work either.
There's a very good chance that I experienced MORE problems, then all the internet put together in the area of 3D. Talk about being original for once...
Offline , veteran polycounter, 4,498 Posts, Join Date Apr 2011, Location Canada  
   Reply With Quote

imbueFX's Avatar
Old (#4)
If I get a chance I can whip something up really quick. We've done this before at our studio with blackhole effects and it works decently.
Offline , triangle, 250 Posts, Join Date Nov 2011, Location Denver, CO  
   Reply With Quote

Vailias's Avatar
Old (#5)
Simplest way I can think of in 45 seconds:
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.

Last edited by Vailias; 01-26-2012 at 08:05 PM.. Reason: fixed terminology, explained better
Offline , dedicated polycounter, 1,572 Posts, Join Date Oct 2004, Location San Francisco, CA  
   Reply With Quote

Ace-Angel's Avatar
Old (#6)
Ah, I see, directly dilating the UV-Coords is done through texture work, interesting and genius!

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
There's a very good chance that I experienced MORE problems, then all the internet put together in the area of 3D. Talk about being original for once...
Offline , veteran polycounter, 4,498 Posts, Join Date Apr 2011, Location Canada  
   Reply With Quote

Vailias's Avatar
Old (#7)
heya ace, I realized I made a mistake on my mental math the other day which is why you're getting what you're getting. No time at the moment to fix it..

also your package is only 81k when I download it. Is that right?
Offline , dedicated polycounter, 1,572 Posts, Join Date Oct 2004, Location San Francisco, CA  
   Reply With Quote

Ace-Angel's Avatar
Old (#8)
No problem, take your time.

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
There's a very good chance that I experienced MORE problems, then all the internet put together in the area of 3D. Talk about being original for once...
Offline , veteran polycounter, 4,498 Posts, Join Date Apr 2011, Location Canada  
   Reply With Quote

Ace-Angel's Avatar
Old (#9)
OK, some more testing and I think I got it, thanks to a certain Gaussian function ;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.

Last edited by Ace-Angel; 01-31-2012 at 03:34 AM..
There's a very good chance that I experienced MORE problems, then all the internet put together in the area of 3D. Talk about being original for once...
Offline , veteran polycounter, 4,498 Posts, Join Date Apr 2011, Location Canada  
   Reply With Quote

imbueFX's Avatar
Old (#10)
Crap I actually did this the other day and forgot to post!
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!
Offline , triangle, 250 Posts, Join Date Nov 2011, Location Denver, CO  
   Reply With Quote

cman2k's Avatar
Old (#11)
Ohhh...interesting stuff. I'll keep my eye on this. ;)
Portfolio of Carlos Montero
Project Lead: Black Mesa
Offline , triangle, 416 Posts, Join Date Nov 2005, Location Los Gatos, CA  
   Reply With Quote

Ace-Angel's Avatar
Old (#12)
^
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

Last edited by Ace-Angel; 02-01-2012 at 01:02 PM..
There's a very good chance that I experienced MORE problems, then all the internet put together in the area of 3D. Talk about being original for once...
Offline , veteran polycounter, 4,498 Posts, Join Date Apr 2011, Location Canada  
   Reply With Quote

Vailias's Avatar
Old (#13)
hehe good you figured out the core of it.
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.
Offline , dedicated polycounter, 1,572 Posts, Join Date Oct 2004, Location San Francisco, CA  
   Reply With Quote

Ace-Angel's Avatar
Old (#14)
Awesome, kitty eyes!
There's a very good chance that I experienced MORE problems, then all the internet put together in the area of 3D. Talk about being original for once...
Offline , veteran polycounter, 4,498 Posts, Join Date Apr 2011, Location Canada  
   Reply With Quote

Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Copyright 1998-2012 A. Risch