Home Unreal Engine

Random function?

polycounter lvl 12
Offline / Send Message
leleuxart polycounter lvl 12
Perhaps I'm overthinking this, but I can't seem to figure out a way to have a random(or at least different) pattern of using separate masks. I have to figure out a way to get certain parts of a texture masked off at individual times and then loop that effect. Since the material will be following the player/camera, I have been messing around with the actor/camera/world position nodes, but haven't been able to figure out how to set up the textures. My original idea is to have one texture with separate masks in each channel, then plug those into the opacity. As I'm typing this, I just got the idea of calling the texture sample 4 times and mask off RGBA for each one, then have a switch parameter. If I can call that parameter in Kismet/Matinee, that'd solve half of the problem.

Does anyone have any other suggestions?

Replies

  • blankslatejoe
    Offline / Send Message
    blankslatejoe polycounter lvl 19
    Hm...i cant quite visualize what you're saying, but I've used simple 1x256 textures to drive 'random' aspects in materials/FX/lighting etc. Essentially you fill the texture with grayscale noise, turn off the texture filtering, make sure it's set to tile horizontally, and run a panner through it so it scrolls-viola--randomness..

    In your case you could use 2 or 3 of these, or one that was full color and then componentmask each channel or something and use them to each drive a different lerp that controlled the mix-in of the mask you're trying to toggle on/off. You'd control the speed with the dimensions of this noise-ramp and the speed of the panner. Make sense?

    Course...if you WANTED to drive it through kismet, then you'd need to manipulate scalar params, or do some (pretty simple) scripting. You didn't used to be able to call switches from kismet, but I'm a few versions behind in my knowhow these days. goodluck!
  • leleuxart
    Offline / Send Message
    leleuxart polycounter lvl 12
    Hm...i cant quite visualize what you're saying, but I've used simple 1x256 textures to drive 'random' aspects in materials/FX/lighting etc. Essentially you fill the texture with grayscale noise, turn off the texture filtering, make sure it's set to tile horizontally, and run a panner through it so it scrolls-viola--randomness..

    In your case you could use 2 or 3 of these, or one that was full color and then componentmask each channel or something and use them to each drive a different lerp that controlled the mix-in of the mask you're trying to toggle on/off. You'd control the speed with the dimensions of this noise-ramp and the speed of the panner. Make sense?

    Course...if you WANTED to drive it through kismet, then you'd need to manipulate scalar params, or do some (pretty simple) scripting. You didn't used to be able to call switches from kismet, but I'm a few versions behind in my knowhow these days. goodluck!

    Hmm, I think I get what you're saying. The multiple lerp option seems like it may do the trick. I'm thinking the multiple lerps with a very slow sine as the alpha, so it repeats? I'll have to try that out.

    I was actually trying to do some transitions and value changes for an old material in Kismet and Matinee, but I could not get the scalar/vector values to change whatsoever. The material transition through the lerp worked, but nothing else. I'll give the other option a try though. Thanks!

    EDIT: Forgot to clarify :) Basically, my texture is a tiling pattern of various flower petals. I need to get one petal type glowing/visible at a time.
  • blankslatejoe
    Offline / Send Message
    blankslatejoe polycounter lvl 19
    Yeah--it sounds like either lerp+sine+time or panner+1dtextureramps are going to be your friends here.
  • leleuxart
    Offline / Send Message
    leleuxart polycounter lvl 12
    This is what I have right now.I guess because of the sines, occasionally two sets of flowers will disappear at the same time, but for the most part it's one at a time.

    DG9cinQ.png?1
  • blankslatejoe
    Offline / Send Message
    blankslatejoe polycounter lvl 19
    Yeah, sine-synchronization is always tricky to deal with. Right now you're using time mults and probably different sine periods, right? You could also try simply adding a stock value to time (.5?) to forcibly offset slots that had the same period/time speed.

    Also, keep in mind that sine dips below 0 for half its life. You probably want to either clamp things somewhere or use an ABS to keep things predictable down the chain.

    glad its mostly working for you though!

    edit--whoops, didnt see that abs at the end
  • leleuxart
    Offline / Send Message
    leleuxart polycounter lvl 12
    Yeah, sine-synchronization is always tricky to deal with. Right now you're using time mults and probably different sine periods, right? You could also try simply adding a stock value to time (.5?) to forcibly offset slots that had the same period/time speed.

    Also, keep in mind that sine dips below 0 for half its life. You probably want to either clamp things somewhere or use an ABS to keep things predictable down the chain.

    glad its mostly working for you though!

    edit--whoops, didnt see that abs at the end

    What do you mean by adding the value? Literally with the add function or multiplying it by a constant(like I have)? I think I may try to do one universal offset if possible that affects all of the nodes, like the Abs at the end. I didn't want to clutter up the editor with a bunch of Abs when one at the end kept it above 0. :)
  • blankslatejoe
    Offline / Send Message
    blankslatejoe polycounter lvl 19
    I mean literally add with the add function--just before the feed into the sine, and give different sine nodes different 'add' amounts. You'd basically shift any sinewav off of sync from any other sinewav of the same period--meaning two could fade in and out without ever synchronizing. Downside: it won't feel random anymore as much as it'll feel like a looping effect.
Sign In or Register to comment.