Reverse light vector emissive material help

polycounter lvl 10
Offline / Send Message
Swizzle polycounter lvl 10
I'm trying to create a material that will let me plug something into the emissive slot so I can have a single light in a scene and have simulated bounce light on the back of the model. I've been able to achieve a similar effect by using a hacked together inverted lambert in the custom lighting slot, but I want to be able to plug it into the emissive slot so the backlight is visible even when shadows are turned on.

Here's an image of what what things look like currently with the inverted lambert shading on a really quick and dirty lumpy test model:

EfoGv.jpg

And the ultimate goal is to achieve something similar to the shading in the Dota 2 comic:

fx78C.jpg

Thoughts, ideas, whatever? I've been noodling around with this all day and I haven't been able to come up with a solution that works. I'm by no means a shader guru, so any help would be appreciated.

Replies

  • Drew++
    Offline / Send Message
    Drew++ polycounter lvl 8
    Well, a Fresnel would do it to fake a rim light, but not the built in node... I think the Fresnel that is built in is based on a light already, so you could re-build that...
    -Then maybe since you're building your lighting already with N dot L(i guess), you could lerp between 0.0, your fresnel(rim light), with the lighting. Basically masking out the rim light that's in the direct light, so only stuff in the dark(behind) shows the rim light :)

    Maybe someone else will come up with an idea. I'll post a node view here shortly!

    ** edit ** meh, just inverting the normals will work fine I guess :)
  • Drew++
    Offline / Send Message
    Drew++ polycounter lvl 8
    Okay, in theory, and inside other engines, just multiplying the normals by -1 seems to invert the lighting, but inside UDK, it doesn't like me... Someone who knows UDK's light vector could help you out. Seems like the light vector is just in the wrong space. :P

    BUT, just use the inverted lambert that you had, and plug it into the emissive, while keeping your diffuse map and normals etc plugged in too.
  • Ace-Angel
    Offline / Send Message
    Ace-Angel polycounter lvl 6
    I asked this question in a thread of mine just a while ago, asking about Unormalized Light Vectors and Attenuations.

    http://www.polycount.com/forum/showthread.php?t=101592

    Basically put, anything which has the 'light vector' node and plugged into the Emissive is borked in the latest versions of UDK and doesn't work, not sure which version doesn't have this issue, but you can safely assume, all the way to Dec-2011, Emissive and Light Vec doesn't work together since I had the issue in that version too, which sucks big time.

    Also, JordanW mentioned UDK has the Light Vector natively in Tangent Space, might wanna change to World Space? I don't know, since I didn't try that.

    Would be grand if anyone came up with a solution to this, maybe the distance node could be used to Cull the Light Vectors Direction towards a length solution?

    EDIT: Just tried and nope, still not working.
  • Drew++
    Offline / Send Message
    Drew++ polycounter lvl 8
    Awesome info Ace! I thought I was going crazy... I wonder if it's compiler problem? Or something with the way the variable names are generated? Really strange. Now that I think about it, I noticed something odd when I tried to make a SSS shader(ear back scattering) one day.
  • Ace-Angel
    Offline / Send Message
    Ace-Angel polycounter lvl 6
    Haha, yep, I was thinking I was going crazy too with all these bugs popping out left and right.

    Pity, since as you said, it would be an awesome way to create and ambient and backsurface scatter in a simple way without messing around with the shadows for an artist.

    I wonder if Epic is fixing everything, since they still haven't released the June version of UDK>
  • Drew++
    Offline / Send Message
    Drew++ polycounter lvl 8
    In the mean time, you can get a decent back light/rim light effect by trying something like this! Although it's probably not that close to what you want. :/
    rimlight.jpg
    It's camera vector based.
    really whacky, but I wonder though, if you could just fly the camera where you want the light, then get the camera's position(somehow) and then type that into a constant3Vector then do a N dot L :poly142:
  • Swizzle
    Offline / Send Message
    Swizzle polycounter lvl 10
    Thanks for the help, guys. Hopefully they get the light vector issue fixed sometime soon. I guess in the meantime I'll just have to get a bit creative regarding the lighting.

    Drew++:
    While it looks nice, isn't that basically just Fresnel?
  • ambershee
    Offline / Send Message
    ambershee polycounter lvl 11
    I do it like this:
    backlight.jpg
  • haiddasalami
    Offline / Send Message
    haiddasalami polycounter lvl 8
    Looking at the post process heat effect thread and this makes me wonder if you could just feed the lights position to the material editor through mat instance via kismet? Could also just rebuild the phong shader and hook the emissive bit to ambient.

    Something like this for feeding from kismet?

    http://www.polycount.com/forum/showthread.php?t=97548&highlight=player+position
  • JordanW
    Offline / Send Message
    JordanW sublime tool
    Ace-Angel wrote: »
    Basically put, anything which has the 'light vector' node and plugged into the Emissive is borked in the latest versions of UDK and doesn't work, not sure which version doesn't have this issue, but you can safely assume, all the way to Dec-2011, Emissive and Light Vec doesn't work together since I had the issue in that version too, which sucks big time.


    Light vector never worked in Emissive. "Emissive" is a property that is independent from light direction.


    You cannot really put this in CustomLighting because that gets masked by the shadow if you're using normal shadows and not modulated.

    You could put it in CustomLightingDiffuse, that's what gets multiplied by your indirect lighting. You coulnd't feed it your light vector though.

    Your best bet is to probably have it come from a side (or both!) in screen space. You can transform your normal from tangent to screen space then dot it with some vector. to get a "light" direction.
  • Ace-Angel
    Offline / Send Message
    Ace-Angel polycounter lvl 6
    NOOOOOoooOOOOooo!

    Damnit Jordan! Stop teasing me with stuff I'll never be able to implement D:
  • ambershee
    Offline / Send Message
    ambershee polycounter lvl 11
    JordanW wrote: »
    Light vector never worked in Emissive. "Emissive" is a property that is independent from light direction.

    Take a look at my above post - it's tried and tested, and uses a light vector fed into emissive.
  • Gestalt
    Just an idea but you could do custom and put it in both customlighting and customlightingdiffuse and take a 'matcap' type of approach for the stylized shading (using a gradient that you define). You use a custom lambert for a gradient map for the grayscale. NdotL gives 1 to 0 to -1 and I've experimented before by plugging it into the UVs of a custom gradient texture to get custom shading. I should probably double check though, I'm just throwing out ideas.
  • JordanW
    Offline / Send Message
    JordanW sublime tool
    ambershee wrote: »
    Take a look at my above post - it's tried and tested, and uses a light vector fed into emissive.

    In that situation you're not getting light vector, you're getting some garbage vector of 0,0,1.
  • Gestalt
    JordanW wrote: »
    In that situation you're not getting light vector, you're getting some garbage vector of 0,0,1.

    It's using vector transform, I'm guessing tangent to world.
  • JordanW
    Offline / Send Message
    JordanW sublime tool
    I know, and i'm saying it's a garbage vector, it's not actually the light vector. Reference light vector in Emissive and move the light around, it wont change ;)
  • Ace-Angel
    Offline / Send Message
    Ace-Angel polycounter lvl 6
    What Jordan is saying if that all you're getting is the Z-Up Vector, light won't affect the position, which is what you want, especially with shadows enabled.

    Changing the color from 'Blue' from the Normals in that case, to any other color, won't work, unless you go for a more 'Rim Lighting' effect kind of deal, in which case the artist will need to manually change the orientation so it corresponds to that of the light.

    Invert the Normal has a chance of canceling the effect.

    Factor in lack of 'distance' and radius, and you have a recipe of Blends/Animation being tied to your Kismet, being tied to your Material, which in turn is looped back to the animations/level just you can get some back-scatter effect.
    Gestalt wrote: »
    Just an idea but you could do custom and put it in both customlighting and customlightingdiffuse and take a 'matcap' type of approach for the stylized shading (using a gradient that you define). You use a custom lambert for a gradient map for the grayscale. NdotL gives 1 to 0 to -1 and I've experimented before by plugging it into the UVs of a custom gradient texture to get custom shading. I should probably double check though, I'm just throwing out ideas.

    If you say what I think you're saying, I tried that, but no avail.

    UDK already has a pseudo-depth calculation from the Custom-Lighting when a Lambert term isn't used for Clamping.

    The issue is, you cannot run away the 'shadows' or override them to get a desired effect, without getting rid of the shadows out right. Try using an Inverted Specular or Lambert term on an Opaque Material and on a Soft-Masked one. You will see the issue.

    Emissive is the key here, to fake the filling up of light without destroying the shadows on a mesh, or inverted specular effect for somewhat internally bounced light behind an object.
  • Swizzle
    Offline / Send Message
    Swizzle polycounter lvl 10
    Ace-Angel wrote: »
    What Jordan is saying if that all you're getting is the Z-Up Vector, light won't affect the position, which is what you want, especially with shadows enabled.
    This is consistent with tests I did yesterday. Great if you want a top-to-bottom gradient, not so much if you want anything useable.
    Ace-Angel wrote: »
    Emissive is the key here, to fake the filling up of light without destroying the shadows on a mesh, or inverted specular effect for somewhat internally bounced light behind an object.
    Exactly. The problem is getting self-shadowing and faked bounce light at the same time, and it seems the only way to achieve this is with the emissive channel or secondary lighting. The problem with using more than one light is that the shading transitions don't work so hot in multiple-light situations. They're not terrible, but they're not what I want.



    I'm admittedly bad at math and I'm by no means experienced with creating shaders, so this may be a dumb question:

    Is there any way to grab the distance/orientation/whatever from the light and feed that into the emissive? Perhaps with some sort of null or invisible geometry or locator or something that could be bound to the location of a light by way of scripting or parenting or some other magic?
  • haiddasalami
    Offline / Send Message
    haiddasalami polycounter lvl 8
    @Swizzle: Yeah thats what I was thinking with the kismet to a param node in the material editor. Check out the link I posted. Ill take a stab at it later and see if I can get it working.
  • Swizzle
    Offline / Send Message
    Swizzle polycounter lvl 10
    Ah, I missed that link. Iiiiinteresting...
  • Ace-Angel
    Offline / Send Message
    Ace-Angel polycounter lvl 6
    If there is a way to translate that material into an Emissive Backwards setup inside the material, it would be fantastic.
  • haiddasalami
    Offline / Send Message
    haiddasalami polycounter lvl 8
    So heres my try at it:

    SwizzleDotaShaderTest.JPG

    Mat:

    SwizzleDota_MAT.JPG

    I tried animating the light to see if I could get the light to move as Im grabbing its location from kismet and no go. Must have screwed up something :( Also ignore the colors haha.
  • pior
    Offline / Send Message
    pior quad damage
    Hey there - not sure on how to achieve it in UDK, but an image-based "matcap" shading would achieve that very easily. It's a very cool look indeed...

    Brice's shader does that very well. You basically just paint that lightsource as a gradient in the axis representing forward/backwards normal direction.

    http://www.mentalwarp.com/~brice/brdf.php

    I can set up an example of it with a simple mesh in Maya if you want to see it.
  • Ace-Angel
    Offline / Send Message
    Ace-Angel polycounter lvl 6
    That would be awesome indeed! I never figured out what they're doing in the math of the shader, but if I could see a setup with examples textures of the gradient you're talking about, it should be pretty easy to recreate it in UDK.

    In the meantime, I would honestly suggest finding someway to occlude your model with an AO texture and just a simple lambert/half-lambert term without shadows.

    Put in a traditional matcap/sphere mapping on your model, and call it a day.

    Very cheap, I know, but hey, if TF2 and Dota are able to getaway without shadows and only a HL terms, why can we, eh?

    I know UDK allows you select if a light is able to cast shadows or not, but I'm not sure if UDK allows you to do the opposite with that effect (EI: Hookup a light to follow your models around, and only cast light to a select mesh per light and no shadows).
  • ambershee
    Offline / Send Message
    ambershee polycounter lvl 11
    JordanW wrote: »
    I know, and i'm saying it's a garbage vector, it's not actually the light vector. Reference light vector in Emissive and move the light around, it wont change ;)

    It does work, but admittedly I'm not using vanilla UDK.
  • Ace-Angel
    Offline / Send Message
    Ace-Angel polycounter lvl 6
    I didn't know Epic had released DLC for UDK!
  • Drew++
    Offline / Send Message
    Drew++ polycounter lvl 8
    I liked the Lit Sphere/Mat Cap idea, so I tried it. I think it looks pretty good! Here's an example so everyone can check it out!

    litSphere_UDK.jpg
  • Ace-Angel
    Offline / Send Message
    Ace-Angel polycounter lvl 6
    Yes, it does look good, but if I'm not mistaken, it acts like a Rim Light, right? Since Matcap relies on the Camera.
Sign In or Register to comment.