Search Unity

Rain in window of a car

Discussion in 'Shaders' started by JorgeJustino, Jul 16, 2012.

  1. JorgeJustino

    JorgeJustino

    Joined:
    Mar 2, 2011
    Posts:
    16
    Someone knows how to achieve the rain effect in the window of car? Like in the video below.



    Thanks in Advance..
     
  2. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723


    This is nicer. In both of these cases I think simply using particles with some nice code would do the trick and not require render textures or anything...
     
  3. hausmaus

    hausmaus

    Joined:
    Dec 9, 2011
    Posts:
    105
    You might be able to find something in the TrainGlassWeatherEffects.fx shader that comes with Railworks 3: Train Simulator 2012

    Here are a couple posts on the shader, seems like you should be able to get it and some supporting data from the game install:
    http://amabilis.com/oldforum/viewtopic.php?f=7&t=6352
    http://amabilis.com/?topic=rain-on-cab-effect
    http://forums.uktrainsim.com/viewtopic.php?f=305&t=124720
    http://www.christrains.com/ts2012_faq_weatherglass.html

    I wouldn't have known anything about this except that it's currently $3.50 on Steam and I was looking at videos. Their effect is very slick, with drops leaving trails on the glass and such.

    Generally, for an effect like that, you would be doing quite a lot of texture work. The key is driving shades of grey to be hard black or white based on a threshhold, and animating the threshhold via Shader.SetFloat(). Then you'd multiply those masks against the normal/refraction maps for an animated effect. That's how the wipers work in that train simulator, for example, just animate the cutoff across the gradient. Of course, you have to do something to track the "old" and "new" drops (swap maps?).

    Same idea for making drops appear, one way to do it is to have a lot of dots and gradients for streaks in varying shades of grey, corresponding to blobs in a normal map that you would use for the refraction effect (the normals just offset the UV coords of a GrabPass lookup, check out the nice Unity Pro water or an NVidia refraction shader for an example). Then just sweep the threshhold value. But for fancy effects, you'd need several maps, and a pretty involved animation setup I would imagine.

    -abm
     
  4. JorgeJustino

    JorgeJustino

    Joined:
    Mar 2, 2011
    Posts:
    16
    Hi Guys....

    Thanks for replys.... I will start working on that, when I have something working I post here
    for everyone who need that kind of effect.
     
  5. aubergine

    aubergine

    Joined:
    Sep 12, 2009
    Posts:
    2,880
    search the internet about texture bombing shader. There is one sample in nvidia site.
    Thats how you achieve the effect.
     
  6. stasgar

    stasgar

    Joined:
    Sep 6, 2016
    Posts:
    14
    Any results? D;