Hello.
How to achieve dynamic rain drops (and water drops) in 3DS Max for games or Unity?
Watch some photos of my point below:
Photo one Have a look at the wet body of this car in NFS Rivals:
Photo two Just look at the dynamic water drops in the Project C.A.R.S photo below:
Photo Three and Four Then we have GranTurismo here, watch the tiny water drops in the Project C.A.R.S screenshot:
Photo five This is a photo that should be watched, look at GTA V's rain drops:
And finally A photo of real world rain drops.
I know programming, I've used Unity3D and I've used 3DS Max for a while, I also know it is hard to achieve these shaders but everything today is almost hard to get. So please express a way to get such effect for my games if possible.
Regards.
Replies
[ame]http://www.youtube.com/watch?v=hViwrRGfuHU[/ame]
Discussing this on another forum, probably a 2D particle sim for the front window, wind forces, deflectors on the wipers, maybe using a metaball system for clumping. Side window probably is done with looping normal maps/height maps (water streaks repeat).
Okay. I am learning how to code shaders. what you've said is really useful for me, thanks again.
considering render times so much fast, we can assume that there are multiply passes in a frame.
Get good reference video & pictures. Try to replicate a real effect. This will keep you on the path.
Look into dUdV, a shader trick for water refraction. http://wiki.polycount.com/wiki/DuDv_map
Here is one basic example, I think you could start from here:
https://udn.epicgames.com/Three/MaterialExamples.html#Wet
If you need explanation about it, let me know.
But one thing, in 3DS Max, I used a normal map and specular map to simulate a wet surface:
but this should be animated in Unity3D some how (water drops movements on car body, I mean), I should figure this out too.
Then that normal map is used in the refraction shader that distorts the scene.
To "clean" the windshield (say, when the wipers sweep the glass), you can also blit a neutral (blue) rectangle onto the window normal map, with a rotation and scale that matches the wiper state in the windshield.
There's a minimal calibration necessary for this to be visually convincing.
In the shader the normal map is just used to offset the sampled pixels. So a neutral direction (which will be [0, 0, 1]) will indicate that no distortion will happen, for parts of the windshield without water.
The rendering order should be: environment, windshield and then the car. The windshield rendering will sample the current framebuffer (containing only the environment).
Edit: there's some great ideas here https://seblagarde.wordpress.com/2012/12/27/water-drop-2a-dynamic-rain-and-its-effects/
I will explain how to recreate this effect as soon as possible. However this is not really prefect and yet windshield and the car body are still in queue.
EDIT: Kryzon, your suggestion is very useful, I should think about this soon. @Shrike, thanks for your seggestion, I just did that. I just added refraction and is awesome (see the picture below). However for car body, Refraction seems not working, logically. However Eric said about the refraction and DuDvs and I will use that approach for the exhaust heat later. Please share your knowledge more here and I also am trying to do my best to make this thread useful for other developers,too.
what do you think?
EDIT: did some tweaks.
for example Shrike told me to add refractions, I did it or Kryzon told me about "bliting" and later I should learn that. Even I am reading the link that you've shared (the UDK page) and that is very useful, I am only one person so I can't do everything very fast. I am taking note of all of your suggestions. And mr.Erick's suggestions are vital for my projects; I need all of your recommendations guys,though.
[Deleted Text]
Anyways, although I am studying the ways that were mentioned here for the windshield, but I'm just wondering something else....how about simulating water in 3DS Max and then import it into Unity3D?
[ame="http://www.youtube.com/watch?v=JAJ-pImnqKc"]https://www.youtube.com/watch?v=JAJ-pImnqKc[/ame]
Also here is the material setup and the animation setup.
These are just the basic I didn't add distortion or any fancy thing, I just wanted to show how the moving bubbles could be approached. This is just one option btw.
I think there is no easier way without coding... A similar animation tool is available for Unity.
As a last note, you should take a look at clear coat effects, so you won't loose the specular and normal direction of the underlaying surface (car body).
Intersection search:
I used a black-white bubble mask with the same coordinates as what the given bubble normal use. I did that with an another one too. I Added the 2 masks together, so I get value above 1 where they are intersecting. Now we can know where are the intersections, an IF can tell it. If A (added masks any pixel value) is greater than 1.0001 then it returns the union.
It would also require some sort of filtering on the edges of the union, so soft transition between the original normals and the averaged normals would be possible. Maybe a sobel edge detection method would work?
I should try it with shader forge in Unity3D. Lots of new things there.
So... Unity3D particles won't work as expected, Unity3D can't import RealFlow meshes... this looks impossible for unity3D to handle.
For now, I paused this project since I just got puzzled. I will study the "blit" and what Obscura said in the last posts soon. Hopefully I will find a way for that. This is way harder than I thought,though.
http://codeartist.mx/tutorials/liquids/
About the realflow thing: I don't think that you could use that animated mesh in any way in a game engine, because it has changing topology for example, and they doesn't have bones or any reference point to animate. Game engines can handle only vertex anim driven by bones, or morphs, or vertex anim with material effects. But, I think you could bake a flipbook texture from the real flow mesh, which can work perfectly, it just need huge resolution for what you want. A flipbook material setup is very simple, it require only a few nodes. But it wouldn't be dynamic at all.
So this is how a flipbook texture looks. Sprite sheets works the same way... You have frames rendered out and put next to each other, and are simply stepping on then with modifying the current texture coordinate.
Here is an example for the flipbook. He is showing the material setup around 1:10. With a very little bit of coding, or with an anim tool you can make it playing the frames.
[ame="http://www.youtube.com/watch?v=6K8XMc6Z89M"]https://www.youtube.com/watch?v=6K8XMc6Z89M[/ame]
Oh yes, I saw that yesterday. Thanks for sharing the link,though.
That's for 2D games, I did tried it in my game and I tried it with the Unity3D's particle emitter, unfortunately the particles couldn't get affected by the wipers, also some minor errors occurred,either. Drove me nuts... .
However, I work on it more when possible.
Thanks for the info, it seems it gets too much ram and is not 3D. (particles in RealFlow were at least 3D). I will use this technique for other things,though. It is useful.
I mean I should bake a normal map of the particles that were created in RealFlow and then put it on the windshield, is this true?
Sadly these ways are - as you've said - not dynamic... I might retry working on that 2D particle, If I failed, I'll try this flipbook method.
I believe it's highly possible to achieve the meta ball effect with the asset that Mr.Chadwick provided it's link. (the 2D particle) I will be working on it next two days, since tomorrow I should work on an other project.
EDIT: I changed my mind, I will work on the 2D Particles tomorrow morning. I highly believe that it is super easy to make those meta balls with the 2D Particle.
With a random timer and some random properties you can "stamp" as many water drops as you want onto the windshield normal map:
(Notice the fringe of neutral normal map colour so when a drop falls on top of another it'll clear the one below.)
Each time the internal timer ticks you change the delay to some random value, so drops fall at random moments.
The drops are rendered as quads onto the dynamic windshield normal map texture using manual GL commands.
- http://answers.unity3d.com/questions/31651/random-delay-time.html
- http://docs.unity3d.com/ScriptReference/WaitForSeconds.html
- http://docs.unity3d.com/Manual/class-RenderTexture.html
- http://docs.unity3d.com/ScriptReference/GL.Begin.html
You can also encode some other information in the alpha channel of that normal map texture. Something like turning the effect on or off for a pixel, if the alpha value is above 127 etc.
When you want to clear the normal map (for example when the wiper sweeps) you can also render some primitive into the texture like a polygonal fan and using a neutral normal map colour (127, 127, 255):
I'm not sure if this would introduce too much distortion.
EDIT: The normal map texture is always flat, so when rendering to this texture you just use screen-aligned quads.
Here is what I did with the 2D Particles, it is now more ready to behave like the water drops of the DriveClub's metaballs.
This needs more time, I hope in the meanwhile, the problem about the normal maps gets solved.
@D4NOO5H - I don't think Driver Club used metaballs in the way you think. That would be as expensive and impossible (in my opinion) as using a RealFlow mesh. Because of the same reasons. If they used them then they must had to bake them. I'd like to ask Eric about this, cause I don't THINK 3D metaballs is possible to use in games especially with physics. That would be extremely expensive. If it would be possible then we could do complex 3d fluid simulations in games.
So up to now, the wetness of the car body and the windshield's particle are 50% done. That's awesome.
@Obscura, I'm going to do what you've said about the water drops of the car body tomorrow or sooner (Outed below) :
I was wondering if there is anything more about that to do?
Thanks Eric, Actually I actually should thank you for that 2D Particle again.
Here is a new problem, when the car goes faster than 20 Km/h, it looks like it goes over 400 Km/h. (Please have a look at the image below)
http://answers.unity3d.com/questions/1026813/fake-rigidbody-speed.html
still no answer for that.
EDIT: I asked this with more details here: Click Here .
I decided not to waste time and paused working on the particles, instead I'm going to do what Kryzon said after finishing the car body water drops.
The problem with using a 3D particle system is that the particles need to be created in 3D as well. Right now they're all being created at the same spot on the windshield; it would need some spread as if the car is under heavy rain.
I think you need to use a custom particle system -- something written in C# -- with abstract 2D particles that are only used to render normal map "stamps" onto the normal map texture of the windshield and any other part of the car that you want drops to be seen.
You can still have particle physics related to car movement, wind, windshield wipers etc., it's just that it'd all be done in code, manually.
The GIF from Drive Club posted by Eric seems to have particle physics only on the windshield. If you look close, the side windows just seem to erase and recreate particles at random, so there seems to be "tricks" involved (you don't need particle physics in the entire car).
- - - - -
When rendering, you set up a normal map texture as your render-target (everything you draw will appear on that texture), then you generate a single mesh consisting of several quads that represent each particle. All quads have the same "water drop normal map" texture like in post #34.
Then you clear the normal map with a neutral colour and draw that mesh so the particles are stamped on it.
The resulting normal map texture with the water drops is applied to the windshield and is what the refraction shader uses.
The more particles, the slower it'll be. If it's extremely slow for the desired number of particles (since their logic would be written in C#) then it's possible to pass on all processing to the GPU in the form of "GPU-based particles" which is a technique that stores (and processes) particle data on textures, but it's much more complex.
These are just ideas of course.
That would be the same thing as what I suggested on the previous page :P The animated thing, you would just control it with physics instead of hand setting the parameters in an animation.The material setup could be the same or almost the same and you could control the material parameters with C#. So I think it should be possible, if you can get physics values and do some math with them.
Here is how it works:
but suddenly I figured out a weird problem accidentally, look at the image below for more details about the new problem:
All that mean is that I should revert back to working with 2D particles with 3D colliders (like two days ago). But I'm going to do something about the normal maps and shaders first.
Yes, thanks for your info. According to what I've done in these 4 days, it is the best option to use 3D particles instead of 2D.