Home Technical Talk

Switching in a glow map dynamically

Orsony
polycounter lvl 4
Offline / Send Message
Orsony polycounter lvl 4
Hey guys.

I'm wondering how one would go about switching the dark texture on the character over to the light one mid gameplay (in ue4). In the sense that the light crawls outwards from the center of the body and illuminates the character like its powering up.

Replies

  • Obscura
    Options
    Offline / Send Message
    Obscura grand marshal polycounter
    Okay, it is not so easy to understand, if you don't have an idea, but I try to explain it as good as I can. You can and you should write back if its not clear.

    1. You need a second or third uv channel on your character , with planar mapping from the front or back view.

    2. You need a mask like this. The curve of the gradient depends on what transition you want, and on how big the character's uv scale is on the uvmap.

    3. You need to lerp between the dark and the colored texture based on the mask from step 2 that use the coordinate from step 1.

    4. You can control the transition with various methods, like simply painting it to look differently, or within the shader, with "power"/"add"s or whatever.

    5. Enjoy!

    These are the basics, but you still can't control where are you at the transition, so it can't be driven by code/matinee yet... A bit later I'll make an example shader for the whole thing, but you can start experiment.
  • Obscura
    Options
    Offline / Send Message
    Obscura grand marshal polycounter
    Okay here is the sample shader, actually it is pretty easy...

    1. sample model:
    iwRVuLB.jpg

    2. second uv channel with the planar mapping from the front view:
    Rhful2Q.jpg

    3. initial material setup (parts are described in the comments above the expressions):
    jeeTWNF.jpg

    4. Actually it is done at this point, now look at the different states based on the "transition" parameter. * You need it to be a "scalar parameter" to be able to drive it through code or a matinee)

    5. state is at 0.2:
    lF8t8Li.jpg

    6. state is at 0.4:
    gcESwsB.jpg

    7. state is at 0.8:
    Atw0dJs.jpg

    8. state is at 1.4:
    HPNuIfo.jpg

    9. state is at 5:
    y70GZ0e.jpg

    10. Anything that controls the transition better, as mentioned, these are just the basics!
  • Orsony
    Options
    Offline / Send Message
    Orsony polycounter lvl 4
    Obscura wrote: »
    Okay, it is not so easy to understand, if you don't have an idea, but I try to explain it as good as I can. You can and you should write back if its not clear.

    1. You need a second or third uv channel on your character , with planar mapping from the front or back view.

    2. You need a mask like this. The curve of the gradient depends on what transition you want, and on how big the character's uv scale is on the uvmap.

    3. You need to lerp between the dark and the colored texture based on the mask from step 2 that use the coordinate from step 1.

    4. You can control the transition with various methods, like simply painting it to look differently, or within the shader, with "power"/"add"s or whatever.

    5. Enjoy!

    These are the basics, but you still can't control where are you at the transition, so it can't be driven by code/matinee yet... A bit later I'll make an example shader for the whole thing, but you can start experiment.

    I am pretty new at this :(.

    Just to make it out how obviously new i am, i understood the process as:

    make your character, uv map it, apply texture. The texture itself is just a dark base colour, with the 'armour plating' a darker texture on another layer, which gaps to show the base colour. The lighter areas is just another base colour between the dark texture and the 'plating'.

    I think i thought that somehow in-game the lighter layer (or another texture map entirely) could just be dynamically loaded in a gradient sort of way that spread outwards, meaning i would have to unwrap the character in a way that resembled the actual direction of the way i wanted the light to go.

    That's where i am :thumbdown:.

    So for step 1, i know how to make a second uv channel and gets the uv's over. But what exactly do you mean by planar mapping from the front or back view? I just want to understand how it works.

    The rest i need to do some research on but i once i understand the mechanics it should just be a matter of time.

    Thanks so much for your help so far!
  • Obscura
    Options
    Offline / Send Message
    Obscura grand marshal polycounter
    I updated my last post with a clear tutorial, so you can see now how it works :) Hopefully this is what you wanted to create. Everything from here can be applied in UE4 too.
  • Orsony
    Options
    Offline / Send Message
    Orsony polycounter lvl 4
    Obscura wrote: »
    I updated my last post with a clear tutorial, so you can see now how it works :) Hopefully this is what you wanted to create. Everything from here can be applied in UE4 too.

    I'm gonna try it out and see how i go :) Again, thank you so much for the amazing reply.
  • divi
    Options
    Offline / Send Message
    divi polycounter lvl 12
    you don't really need a texture to create a circular gradient though.
    all you need is the distance between the texture coordinates and a vector2 with whatever values you want for your center(0,5 for both values probably).

    //edit: before you could copy node setups from the material editor, paste them to text and copy&paste them later on. apparently that will now crash the editor x.X - or it is just when you copy from polycount. no idea :D

    should have given you
    Screenshot%202015-02-19%2014.32.52.jpg
  • Orsony
    Options
    Offline / Send Message
    Orsony polycounter lvl 4
    Success! I think. Tbh, Seeing that glow come up made me cackle madly.

    24b7mdi.png

    So, adjusting the parameter lets me transition between the first and second textures.

    I'm gonna need to learn why the second uv channel is necessary, and more curiously, what part the shader plays specifically in the whole thing.

    It seems the lighter texture seems to transitioning evenly across the entire body, instead of spreading from the inside out

    My assumption is the position of the shader relative to the second map has something to do with it?

    Thank you for making my robot man glow.

    Edit: you cant see the glow but it shows when the lights off.
  • Orsony
    Options
    Offline / Send Message
    Orsony polycounter lvl 4
    divi wrote: »
    you don't really need a texture to create a circular gradient though.
    all you need is the distance between the texture coordinates and a vector2 with whatever values you want for your center(0,5 for both values probably).



    You can paste that directly into your material editor if you want to.

    Being an absolute noob, i actually tried to ctrl-v that into the material editor. UE4 crashed haha. It might be a bit beyond but can you explain what that is exactly?
  • divi
    Options
    Offline / Send Message
    divi polycounter lvl 12
    Orsony wrote: »
    Being an absolute noob, i actually tried to ctrl-v that into the material editor. UE4 crashed haha. It might be a bit beyond but can you explain what that is exactly?

    I edited my above post ^^. Don't want to keep stuff in here that crashes the engine.
  • Obscura
    Options
    Offline / Send Message
    Obscura grand marshal polycounter
    You need the second texture coordinate to tell the shader that you want the radial gradient to be projected that way. The radial gradient is used to tell the shader that you want the transition to be spreading outwards from the center. Also, you can't "play" the transition yet. You need a matinee for that, or it has to be coded, or a blueprint. You can make it playing with a sine-time node combo multiplied to the transition parameter to make it playing, but that will play it back and forth. Also, you can make it actually glowing with multiplying a value that is higher than 1 to the lighter texture, and you need the bloom post process to be enabled.
  • Orsony
    Options
    Offline / Send Message
    Orsony polycounter lvl 4
  • Orsony
    Options
    Offline / Send Message
    Orsony polycounter lvl 4
    Ok so i've got the mask blueprint by devi hooked up, and i've changed the 2nd uv channel to a planar mapped version, which is (as i understand it) just a front on UV map (picture attached).

    23lgp01.png

    Just to summarize what i've learnt.
    The textureCoord expression should be set to 1 because thats the second uv map channel, which is the planar map, which combined with the mask should appear as if the the second texture is fading in from the center outwards.

    Last question i think i've got.

    Edit: Figured it out. Jesus that's impressively bright.

    I think now i'll try to figure out how to use shaders with it, as i'd like the plating over the top to not be emissive while the lighter parts are.
  • Obscura
    Options
    Offline / Send Message
    Obscura grand marshal polycounter
    Yes, thats the planar mapping.
    Show a video from the end result, so we can see how the effect looks on something more complex than a minecraft dude :D
  • Orsony
    Options
    Offline / Send Message
    Orsony polycounter lvl 4
    Sorry i took it with a goPro because i have no video recording software.

    https://www.youtube.com/watch?v=Q_TfAK8t59g&feature=youtu.be

    Now i'd like to try masking off the armour plating of the model so it's not affected by the emissive quality.

    I've set up a basic material layer blueprint, but im bamboozled as to how i can fade the glow in under the armour. Something to do with masking and the proper blend i would suppose. Going to download the UE4 example map with all the weird globes, there's one with the exact effect i want and i'm sure i can just reverse engineer it or something.
  • Obscura
    Options
    Offline / Send Message
    Obscura grand marshal polycounter
    Cool. What you want is also simple, you need a mask for the metal parts (that you don't want/want to glow), and you simply need to multiply that to the radial gradient mask (the metal parts mask has to use uv channel 1 - coordinate index 0 - so basically you doesn't have to plug a texture coordinate node into it). So you will still have the glow anim going outwards from the center, but only the non metal parts will do that, and the metal parts won't glow at all.

    UE has a built in recorder by the way :)
  • Orsony
    Options
    Offline / Send Message
    Orsony polycounter lvl 4
    Strangely enough i couldn't figure this out until i started typing another question. Then i read my question back and was like 'oh... true'.

    Anyway, it works and it looks cool.

    Something i don't understand is how the armour mask automatically applies itself to the 1st uv channel where the gradient is connected to the 2nd? Is that because of multiply node?

    I'd like to set up another blueprint to be able to switch between colours on the go. Then, god help me, connect a metallic node to the armor while having an emissive one on the lights, and keep lerp between the unlit and lit textures.

    I'll keep posting progress if anyone's interested.

    Edit: Also thank you again
  • Obscura
    Options
    Offline / Send Message
    Obscura grand marshal polycounter
    Everything use the 1st uv channel by default (index 0), except lightmaps, but you can still force them to use the channel that you want. "Programmable" colors can be driven through vector parameters.
Sign In or Register to comment.