Jump to content

Rain anyone?


Enceos

Recommended Posts

I'm not a software engineer, but I'm familiar with Unity to a certain extent.

There are a bunch of rain and snow prefabs for Unity particle system. The prefabs represent a flat plane which generates particles, on collision each particle transforms into a splash animation. From my perspective to make a simple rain one should simply strap this particles plane to the camera and bind it to the planetary coordinate system. It could also be possible to rotate the plane according to the current vessel's speed and heading so that particles change their angle. Falling speed is also adjustable.

ImpureVariableBushbaby.gifGrimyDarlingAnemoneshrimp.gif

And snow:

 

 

Edited by Enceos
Link to comment
Share on other sites

42 minutes ago, VikingStormtrooper said:

Do you think it is possible to relate the presence of the "particles-generator plane" to clouds (maybe not all of them, just those "fit for rain")? I am pretty sure that this would be a nightmare to do, but who knows!

I think the EVE clouds are particles themselves, but they come from particle emitters, so it is possible to generate rain emitters the same way. But adding a single rain emitter to a camera is much more performance friendly. However the EVE core mod is not under active development anymore since @rbray89 left the scene. I don't know, @Waz have you ever dug into the Unity particles thing?

Is this real?

7x5U64m.png

 

Edited by Enceos
Link to comment
Share on other sites

18 minutes ago, Enceos said:

I think the EVE clouds are particles themselves, but they come from particle emitters, so it is possible to generate rain emitters the same way. But adding it to a camera is much more performance friendly. However the EVE core mod is not under active development anymore since @rbray89 left the scene. I don't know, @Waz have you ever dug into the Unity particles thing?

Is this real?

7x5U64m.png

 

Yes, it's real. It's in SVE. Rain however, is not possible with EVE. that would take a separate shader

Edited by Galileo
Link to comment
Share on other sites

17 minutes ago, Enceos said:

@Galileo Do you mean that currently available shaders are not suited for raindrops?

No, not currently. Not with what is available. I have seen a few modders attempt a rain shader in the past and fail, whether it was performance crippling, or they couldn't control when it rained, all of them flopped. It has been brought up a few times to @blackrack (our friendly neighborhood shader wizard), but I forget why he hasn't done it or won't. 

EVE can't do it because it's impossible to force the particles to "fall" only on the z axis. They rotate, which creates a "rain" that defies physics. This is okay for snow, but it still can be noticeable at times

and yes I used a cloud particle to create snow.

Edited by Galileo
Link to comment
Share on other sites

@Enceos This may be far ahead in time and possibly out of scope but can this rain emitter be fixed (not to the camera, rather to the vessel orientation), bound to a hotkey or a part module, even the throttle, and the rain particles be given a custom texture and even a glow? If you say yes, the KSP warp drive experience just got real. :) If you say no or maybe, a dude can dream, hahaha.

Keeping a little close to home now, I can foresee tall mountains and enclosed basins, forever shrouded in clouds/fog and with unending rain @Galileo :wink: Whole new varieties of Kopernicus planets, or of their climates. Swamp planets, Laythe monsoons, Venutian sky storms...

Spoiler

Andddd oh yeah.... heat-inducing acid rain?

 

Link to comment
Share on other sites

39 minutes ago, JadeOfMaar said:

Keeping a little close to home now, I can foresee tall mountains and enclosed basins, forever shrouded in clouds/fog and with unending rain @Galileo :wink: Whole new varieties of Kopernicus planets, or of their climates. Swamp planets, Laythe monsoons, Venutian sky storms...

Fff, yes, make it happen!

But give us a defence mechanism if you do the bit in the spoiler :P 

Link to comment
Share on other sites

@regex I think having more than 5 rain emitters at a time will have a significant performance hit. Binding the emitter to the player's camera is the most efficient way of making it rain. Rotation of the emitter around the camera can simulate winds and movement.

Link to comment
Share on other sites

For rain maybe you could bypass the unity particle system (because, why not, lets render a million droplets instead of a few thousands). Create a single mesh including a random set of individual 'droplets' (as two triangles each, then a degenerate zero-area triangle afterward to separate the quad from the next one). Alternatively use point sprites. Then, render the mesh (oriented and) moving 'down'. 'Down' could be determined simply by the current vessel -> main body center vector. To have an infinite loop, render two instances of the same mesh, one at the top and one at the bottom, both moving down, and re-start the bottom one (above the top one) when it goes below some negative threshold from ground level.

Link to comment
Share on other sites

2 minutes ago, Enceos said:

@regex I think having more than 5 rain emitters at a time will have a significant performance hit. Binding the emitter to the player's camera is the most efficient way of making it rain. Rotation of the emitter around the camera can simulate winds and movement.

That's not what I'm suggesting at all, I'm suggesting binding the emitter to the camera based on EVE shadows or the cloud map, camera location, and some sort of random determinant. Basically bind it to the camera in a smart way.

Link to comment
Share on other sites

@regex Yep, after the first step was achieved we can start thinking in the field of how to turn on and off the rain emitter in a smart way. Depending on altitude or clouds present as you say.

@ShotgunNinja Your genius brain is already coming up with ideas, I love it :) . If the thing you're proposing is much more performance friendly than the particle system Unity offers, I'm all for it.

In my head the system looks like this:

uY2jtGU.jpg

Edited by Enceos
Link to comment
Share on other sites

Would rain be pure visual, or effect different parts?

My WIP list of ideas for effects is:

When you land a plane or apply brakes to your rover you may skid a little because of wet terrain/wheels

Downpours could cause sever visibility loss, which could effect flying ("Hey look, that mountain wasn't there a second ago!!!")

In a snowy biome (like the artic) the rain would be snow, which could cause lack of visibility and cause certain mechanisms to lose efficiency due to cold weather.

Note: ^^^^ is all subject to change as the discussion continues.

 

Link to comment
Share on other sites

@Enceos It would be much faster. That may be relevant or not depending on the amount of droplets you want to render. The speed gain is not in the rendering (well, sure is not going to be any slower) but in the simulation. The fact is, you don't need simulation. You don't need to do a vector3 add for each individual droplet. Consider that a vector3 add take on the order of a microsecond in our environment (that is 3 orders of magnitude higher than in the 'real world' of c++ move operators, gcc aggressive optimizations and simd intrinsics, where a vector3 add take a couple nanoseconds instead). So, assume you have a thousand droplets, that is a thousand vector3 additions per-frame. That could be a full milliseconds, and only for 1k particles. And that is assuming unity is not wasting any other cpu time there (let's be frank, that's probably not the case).

I did some simple stupid infographic on the method (stole your rain graphic :kiss:)

Untitled.png

Link to comment
Share on other sites

1 hour ago, ShotgunNinja said:

Consider that a vector3 add take on the order of a microsecond in our environment (that is 3 orders of magnitude higher than in the 'real world' of c++ move operators, gcc aggressive optimizations and simd intrinsics, where a vector3 add take a couple nanoseconds instead). So, assume you have a thousand droplets, that is a thousand vector3 additions per-frame. That could be a full milliseconds, and only for 1k particles. And that is assuming unity is not wasting any other cpu time there (let's be frank, that's probably not the case).

Particle emitter animation is done 100% in the C++ part of the engine, unless you want to move your particle by hand (like I do in SmokeScreen). The optimisation are already here.

Not that it would be faster than your method but it would not be as slow as you implies.

Your method may have problem with recurring pattern (depending on the size of your mesh) and number of poly (if you have 1/2 triangle particles you need to rotate your object to have the particle face the camera and I think you would have parallax visual problems when the vessel is turning)

Link to comment
Share on other sites

@Enceos Ahhh :) But seriously, that's a good start.

Untitled.png

I forgot to mention something: consider not using alpha blending, there will be too many droplets overlapping and the blending equation will simply oversaturate everything. If the droplets are small enough, the lack of transparency in the individual droplets will hardly be noticed.

 

@sarbian Let's hope the human brain can't recognize the patterns. It should not been able to if the droplets are enough.

Good point on the camera rotation. My idea was to have the rain fixed on screen, invariant to 'horizontal' rotation, with the user not noticing it too much during rotation. And to not orient them 'vertically' at all. 

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...