Slope shader : Real-Time Meteorological Effects for Envirronement

Hi !

Finally, thanks to the new Lamp Data node, we are able to do a mask capable to adjust itself with the orientation of the object’s faces.

Let’s take an example of a concrete application : The snow.
(same effect in UDK)

The snow only fall on the top of an object. If you use a diffuse texture to apply that effect and then rotat the object, the snow follow and will not be well placed anymore.

With this shader based on the world orientation, if you do a rotation, the snow will stay on the top (and adapt itself to the geometry of the object!)
(all the rocks are the same object with the same shader and textures)

The realisation of the mask is really simple in fact, we use the Vector of the lamp (Hemi) as a World Vector. All we have to do is make a dot product with the Normal Vector of our Geometry node. The Lamp is only used as a vector reference, so if you don’t want the lighting effect, just desactivate it.

I’m in the beginning of the experimentations but the possibilities are endless to create easily some variations (rain, volcannic dust,usury…) in your environnement or put new assets without create a separate texture for each object .

Hope you find this trick usefull !

Please forgive my bad english :slight_smile: (and the poor quality of the model, it was just for tests)

“All we have to do is make a dot product with the Normal Vector of our Geometry node”…yes, easy! :wink:
Great shader!
Thank you very much for sharing.
P.S. A little .blend, maybe?

nice one Yadoob!
Thanks for sharing your knowledge! :slight_smile:
I will try it out!

Very nice. It can be use too for simulate rain, but is only an idea.

This is great! Thanks for sharing.

Call me a bit dim but how can this produce a rain effect though?

Scrolling UV alpha rain texture that orients to the Z axis. It’s more the effect of the water running down the rocks than falling drops. (I assume that’s what he meant).

Thanks for sharing. Great trick for game map creation productivity.

Hi, thanks everybody for your answers !

…yes, easy! :wink:
Well “Blender” realize it really easily :slight_smile:

I didn’t tought about the falling rain like that, seems like an excellent idea ! I will definitly try.

I just uploaded a .blend file with the snow explanation : be sure to use a recent build with Lamp Data Node on it.

Tried it out myself, I have to say that this works better than I would’ve thought, this actually means that we can now do the blended box mapping technique inside of the BGE.

I have an old project where I wanted to use global mapping to create a level building environment without textures repeating on each block, and now it’s finally possible :smiley:

And to prove that box mapping is possible now, here is a .blend showing the new and beautiful shader in action (complete with normal mapping done in the node editor).

To note, if you want blended box mapping instead of generic box mapping, just change the blend type of the color-ramps from constant to linear. This new node type might indeed herald a new generation of graphics and texturing in the BGE.

Could you use a trajectory to assign a texture? I was thinking reentry debris tumbling and burning and blackening and scaling.down…

There’s a distance output (gives a mask based on the distance from the lamp), but I think what you would need is an additional ‘position’ output for the lamp and as far as I know it may not be that doable with just the light data node.

I think in a animated specular map that simulates the rain fall in the top of the objects.
But i think that i speak too fast XD

Glad to see the Lamp node added into the game engine, and to see so many possibilities from it! Thanks for the tips, Yadoob.

I would love to see a bge centered texture tab, (when you switch the mode to bge) with a nice dropdown list of.examples and premade textures.

With neat things like this in there, :slight_smile:

Hi !

Thanks for your comments, I’m glad that this shader help !!

I tried the falling rain shader as LFDA Studio, Rubbernuke and MrPutuLips suggested. It was quite a challenge and I have not finished yet ! I’ll upload a .blend when I’ll be happy with the result.

Here is my attempt (mainly based on the equivalent UDK effect) :

To explain a little, the main goal was to dynamically UV map the object with the global vector (thank you Ace Dragon by the way, your method was a huge inspiration) and then change the UV offset of the rain texture to make it fall with time.

So basically, I use the global vector, switch the Z value to Y value of it(In order to have a nice UV mapping), add it the time value and then split it to 2 différents vector. One is facing the X direction, the other the Y direction. Then I used the two vectors as UV vectors for two rain textures (normal map) and mixed them :

The two final rain textures.

This method is far from perfection : as you can see with my third test, a lot of “stretching” appears : its mainly because i’ve some probleme to make a nice mask who blend the two rain textures. I’m working on it !(I’m currently trying to create more UV vectors (moar and moar:yes:) to have smoother transitions)

The slope effect only take part in the fact that the rain won’t follow the geometry who face the ground (there is no white rain in the center of that image:eyebrowlift2:):

I hope I can use the slope as a factor for the falling speed (I think that the effect you talk about BluePrintRandom ?) : on the vertical surface, it’ll fall quicklier that on the horizontal surface but I’ve some trouble making a good Time input (that’s really a pity that a node like that doesn’t exist. I’m not familiar with the BGE logic so maybe its because it’s easier to set it up with logic bricks or code?)

Your idea, LFDA Studio, of the rain who drop on the top surface is a very good idea too but I have no clue yet how to restrain the mask only on the first top of an object. The danger is that, even if te face is under a protection (like in the third test), this effect applied. Maybe the Shadow mask of the Lamp Data could help but I didn’t investigate this way.

Thanks again for your kind words, don’t hesitate to propose ideas or solutions, it’s always a pleasure to read them !!

Thats fantastic, Yadoob! I have never really used the shaders in Blender, so this idea is just a guess:

For rain, can you have two masks? For the rain splashes (mask 1) have a mask that is looking down (so only upper surfaces are ‘painted’ with the splashes) and the rest of the object you have the running water animated texture (mask 2) as you have now?

Rubbernuke; I will note that in some cases, you will need to have multiple mappings leading to multiple image nodes and then mixing them together on the other side of the tree.

Basically, I found that blending coordinates together work great when you do it two colors (black and white), but when you place grey in there, I realized that I’m then forcing an interpolation of coordinates and creating a lot of stretching. I’ll try to quick edit the .blend file to show a truly blended box mapping technique.

EDIT: The .blend is complete along with an edited normal map creation technique that seems very accurate (or at least a bit better than the old one).

And here’s an image showing blended box mapping on a more complex object (read, the BGE is running and it’s rendering an object with no UVmapping)

This is a big deal, it means for some cases like complex level geometry, you now have a choice of choosing a technique that ends the need for UVmaps (which can also be great for random level generation that might also have random deformations of geometry).

That looks great Ace Dragon!

Nice work!!!

Do you think you can handle emission etc the same way?