Home Technical Talk

Shader - Internal Bounce - Any tips?

polycounter lvl 12
Offline / Send Message
Ace-Angel polycounter lvl 12
Heya people,

Quick question, does anyone have a quick and dirty idea on how one would go about creating an 'internal' bounce of the Specular/Reflection?

Basically I have a sphere mesh, and one part of it is masked to show the reflection, I inverted this reflection 180 to fake the refection, but cannot for the life of me fake the 'bounce' as if it's pushed in internally, it still looks like its 'floating' ontop of the mesh itself.

I tried an inverted my normal map and using a Bumpoffset to try this effect, but no avail.

Anyone have tips? Cheers!

Replies

  • Neox
    Offline / Send Message
    Neox godlike master sticky
    I'm not really sure what you mean could you show a real world example of what you would like to achieve?
  • Ace-Angel
    Offline / Send Message
    Ace-Angel polycounter lvl 12
    A quick example of what I mean:

    http://img442.imageshack.us/i/eyeballrefraction.jpg/

    Basically, I'm trying to get that internal bounce as seen in the image in shader format, all on a single mesh.

    The math in theory suggests that I flip my RG channels of my Normal map with a decent Parallax map, and it should fake the effect correctly. I tried that over and over again, but it seems like inverting my Red and Green channels for said effect breaks my Specular and Cubemap setup.

    So I was wondering if any kind soul had any tips or snippets on which they might have the solution.

    Cheers!
  • Gestalt
    Offline / Send Message
    Gestalt polycounter lvl 11
    Just a quick idea but if you are using a sphere and making the apparent iris highlight with a normal map the you could use the iris normal map when doing the specular highlight and just mask/fill the eye with 0,0,1 for its normals when doing the environment map (gives you the cornea and rounded exterior eye shape described by the plain geometry). If I get what you're saying you would like to have the iris highlight while also having the cornea reflections. You could use vert color to mask out the eye geometry so you don't need a mask texture.
  • Neox
    Offline / Send Message
    Neox godlike master sticky
    why would you want to invert your R channel? usually its just G that you need to invert to let the light hit the surface from the other direction as this is your Y vector
  • Farfarer
    For my eye shader, I just baked two normal maps. One with the iris is plugged in to the diffuse shading, one with the lens bulge is plugged into the specular shading.

    It's not physically accurate, really, but it works fairly well.

    Flipping the y component would probably give a similar result...
  • LoTekK
    Offline / Send Message
    LoTekK polycounter lvl 17
    I just did a quick eyeball model+nm, and a shader modification to test this out, and I think ideally you'll want a custom shader for the eyeballs. Essentially you're doing a double specular. First specular will use the normal map with the iris indentation, and the second will use the vertex normals. And... that's pretty much it. Obviously the illusion will still break at high incidence angles (whether you have the double specular or not), but it works well enough for a single mesh eyeball.

    eyeballShader.jpg

    edit: That should have been reflection instead of specular... read your post wrong :p But the idea's still the same.
  • Ace-Angel
    Offline / Send Message
    Ace-Angel polycounter lvl 12
    Hey guys, thanks for all the feedback, and tried all the ideas and they helped. Thanks alot to everyone!

    For some reason, inverted Normal Maps don't help (even dented ones) I had to end up 'inverting' my whole formula's for some reason (like my Blinn had to be inverted), I guess it's a UDK issue since that's where I'm doing my shaders, I tried Max and Maya shaders, but they worked alright with inverted Normal channels only.

    Also, I just wanted to add that I forgot one thing that made me run in circles, and that is an inverted Diffuse term, if anyone tries it out, you'll know what I mean when you see the results for you pupil :P

    Once again, cheers to all and thanks for everything!
  • JordanW
    Offline / Send Message
    JordanW polycounter lvl 19
    Just to be clear you're trying to recreate the specular on the iris correct? Why does using 2 speculars with 2 different normals not work? You should have your geometry be the shape of the cornea and use it's surface normals to create your first specular. Then create geometry representing your iris and bake a normal map, then use that as the normal for your 2nd specular.

    I'm not sure why you want to invert normal maps or whatever, if you're trying to recreate an eye why not break down what's actually happening in the physical world to create your material?
  • Ace-Angel
    Offline / Send Message
    Ace-Angel polycounter lvl 12
    I guess I suck at explaining stuff, so bear with me.

    I have two Specs currently, one is the Cornea on the Iris (I will call this IC) and and the other is the internal one is for the Iris.

    I'm using the math of the bulge of the Cornea as the 'inverted' math to fake the refraction internally, when it comes to the light bounce in the inside, at angles as a buildup for 'wet' light on the internal iris.

    The ideal solution as you said, would be for me to simply model in low poly the stuff I need and base it physically, with the proper shaders later on and it would be much more simple, but then I would need another layer that is Translucent for the Bulge, usually bring in it's own issues, like Depth sorting with hair, I still haven't found a solution to that in which I could tell UDK on how much it can clip in distance.

    And yes, I have quite a few characters who have their hair ontop of their eye balls, very niche market, but I make it happen baby!

    And soft masked is not an option, since I need the smooth keratoplasty build up and scatter of light near the edges between the said rims.

    Plus, I also have a dilation setup going for the texture, I'm not too sure how well I can do that in vertex format to fake the stretching of the Pupils details.

    Plus, many artists I know tend to be abit lazy when it comes to creating them maps, so I'm trying to explore my options of fallback math for such stuff.
  • JordanW
    Offline / Send Message
    JordanW polycounter lvl 19
    Hm, to clarify I was saying use 1 model for the whole eye and bake 2 normal maps. Then use custom lighting that will do 2 lighting responses, one for the cornea and the other for the iris+scelera. With that solution you don't need translucent materials.
  • Neox
    Offline / Send Message
    Neox godlike master sticky
    and if you don't have the extra map for texturespace reasons (though it could be the same normals for all eyes in the game) then just bake out the normalmap for the cornea bending out to build the specular, and flip the green channel for the iris bending inwards to create the diffuse shading.
  • Ace-Angel
    Offline / Send Message
    Ace-Angel polycounter lvl 12
    JordanW wrote: »
    Hm, to clarify I was saying use 1 model for the whole eye and bake 2 normal maps. Then use custom lighting that will do 2 lighting responses, one for the cornea and the other for the iris+scelera. With that solution you don't need translucent materials.
    Ah right, understood, will do.
    Neox wrote: »
    and if you don't have the extra map for texturespace reasons (though it could be the same normals for all eyes in the game) then just bake out the normalmap for the cornea bending out to build the specular, and flip the green channel for the iris bending inwards to create the diffuse shading.

    Yep, that's the idea, but for some reason in UDK, when I invert the G channel, it ends up 'skewing' location of the highlight slightly to the side from where the light is coming, rather then inverting it to the opposite location outright as hoped, so I ended up inverting my whole formula, which works correctly now. No idea why this happening, but it's the current work around.
  • Gestalt
    Offline / Send Message
    Gestalt polycounter lvl 11
    Hm, to clarify I was saying use 1 model for the whole eye and bake 2 normal maps.
    and if you don't have the extra map for texturespace reasons (though it could be the same normals for all eyes in the game) then just bake out the normalmap for the cornea bending out to build the specular, and flip the green channel for the iris bending inwards to create the diffuse shading.

    or as was mentioned just use the geometry normals 0,0,1 if you are using one piece of geometry for the eye (which is the way to go imo); mask with vert color would be a decent option if you have more to the mesh pieces than just the eye. You could use bump offset (can store a heightmap -1 to 1 in the blue of the normal) to get a refraction type effect applied to the iris texture and spec but not the sclera/cornea reflections so that it appears there are two separate layers even though it's one piece of geo.
Sign In or Register to comment.