If there are examples, I was not able to find it. There appears to be very very old forum post that talk about it, but those post should be deleted. Post from 10years ago in JME do not apply to current JME at all anymore and make people waste time looking into those things that are no only able to be used.
I don’t know how he did it but this is my way. My snow doesn’t build up as in this example from the link, they use a bump map to give it height. I didn’t do this, my game is an old style 80s game and don’t want to much realism in it.
I followed this example for Unity.
So basically, I have an abstractApp that watches the weather temperature and then when it is below 32f. When it starts to snow it uses a accumulator to accumulate the snow over a period of time.
So I pass down variables to the shader. The Snow Color, snow strength (Accumulator of time, how much snow has fallen), The Angle to compare against and a Snow Texture (in a since a height map).
I have 5 different texture to pick from so the fallen snow collection is not the same every time it snows. So if there is no snow on the ground then it picks a new texture to use.
If it stops snowing and stays below 32f then the accumulator will stay where it is at so that screen keeps showing snow. When the temperature goes over 32f then based on temp. it will start to reduce the accumulator (snow melting effect) and the snow will start to be reduced on the screen until the accumulator because 0 or starts to snow again.
So in the shader, I look at the ‘inNormal’ and do a dot comparison against straight up and then compare the result. If when a certain degree, allowed up to a certain angle from straight up to collect snow, then I look at the texture and see if the color of of Green is below the accumulator meaning more snow has fallen in that spot to allow it to much.
float angle = (dot(myNormal, vec3(0, 1, 0)));
vec4 noise_texture = texture2D(m_snowData.snowTexture, newTexCoord1);
float newValue = clamp(min(0.99, noise_texture.g), 0, 1) + 0.1;
if (newValue <= m_snowData.strength && angle > 0.4)
color = vec4(0.8, 0.8, 1, 1);
Then after that I use that color for the output. Only thing I might add is check if the current text coord alpha mode is above certain range to do snow affect or not. That way a transparent item doesn’t get affected in correctly.
That is a very simple way of doing it.
I’m about to do that for the rain, but the only thing I’m changing instead of using the straight color light snow, I’m going to change it to mix the item textcoord and water color that has a low alpha range so the original texture color is still seen through the water color still. I would not do an affect like the water is moving, to simple of a game for me.
Hope that helps.