Could anyone explain how to script an emissive shader to flicker?

oraeles77
oraeles77 polycounter lvl 7
Hello,

I study modelling and texturing, not scripting. I have NEVER understood scripting and wasted a lot of time making sure the } or ] is in the right place, so currently I am copy pasting so I can focus on other things.

Recently I redid the 'Clock' tutorial using a clock model I made myself.

and I have been learning to make lights flicker.

https://youtu.be/CZKaB2UyRZk

however this affects point lights.

I would like to make a script which makes emissive shaders flicker.

either by cannibaling the script in the youtube video above or another way.

thank you.

Welcome!

It looks like you're new here. Sign in or register to get started.

Replies

  • mvdrocco
    mvdrocco vertex
    edited Oct 2017
    Hi! 
    Simple question: do you absolutely have to do it via script?
    If, indeed, you are just "copy-pasting so you can focus on other things", why not try creating a simple animation for the flicker? Lots of random values with linear interpolation between each.

    Anyway, if you're trying to learn how to actually do it by script, then a quick search would land you on this page: https://docs.unity3d.com/ScriptReference/Material.SetFloat.html
    Start by accessing the material parameters in your script, practice with changing different values and colors, and then, once you have a firm grasp of the logic of it all, you can try to re-implement the content of the "Update" method from the video you picked. 

    I'd be weary of using that video as a starting point though, as it contains lots of code that just calculates a value (which can be visually overwhelming for a beginner, I suppose), instead of getting you accustomed to playing around with components. 

    Good luck :)






  • McDev
    McDev polycounter lvl 2
    oraeles77 said:
    I study modelling and texturing, not scripting. I have NEVER understood scripting and wasted a lot of time making sure the } or ] is in the right place, so currently I am copy pasting so I can focus on other things.

    Frankly then you will never get rid of the problem. Spending a few hours and days in coding might safe you a lot of headaches. But if you want to avoid it then the animation system as mentioned is probably a good solution for you. Placing some random keyframes and making it loopable will work.
  • feloxy
    feloxy polycounter lvl 6
    Hi oraeles77,

    Are you still looking for a solution? If So I might be able to help. I am not a programmer either but I am studying it as a hobby as I am more of a 3D artist. I made a script for my game that gets the emissive to flicker. It may not be the best and well optimized script but it works for what I wanted it for. I am not at home but I can check if you still need it. 
  • derphouse
    derphouse polycounter lvl 4
    You could do some research on using sine waves. Start out with 2 or three at various frequencies(speed), and multiply them together, that'll give you a sort of flickering.

Welcome!

It looks like you're new here. Sign in or register to get started.