WIP Video – Puddle Shader / Wet Ground Shader

Hi Guys,



So last night after work I had an idea on how I might be able to build a very fast and inexpessive puddle / wet ground shader, so I spent a few hours knocking out the basics, tidyed it up just now and thought I would share the progress, I’m pretty happy so far, still a way to go yet though.



http://www.youtube.com/watch?v=kZAenlK8mTk?hd=1&feature=player_embedded

(I recommend you watch it 720p, looks way cleaner)



The video starts with dry normal ground, it is some free dirt texure I found online. The big blue ball grows to reveal the puddle shader applied to the same material.



The puddles are based off the parallax map, the shader assumes ‘low’ areas are full of water. In theory it works with any ‘ground texure’ with a parallax map. It’s pretty ‘analogue’ in that you can pass a value from 0 (no water) to 1 (completely covered in water) or anwhere in between, so it will support varying amounts of wetness or heaviness of rain.



I plan to pair this with a rain effect and fake rain drop distortion applied to the reflection.



Cheers

James

4 Likes

Wow this is awesome.

So is it a custom shader or is it based on the lighting one.



also do you use an env map or compute the reflection on the fly like for water?

@nehon its based on lighting. I don’t know how to split out my own shaders yet, and I figured one massive shader that does everything will yield better performance than multiple material passes.



It currently uses an env map purely for performance reasons, the idea was as the camera gets close to “puddles” or standing water, the env map goes transparent so you wont see missing geometry so no need to render on the fly. If on the fly isn’t too expensive I might look at implementing, I think i need to use this method something else I’m working on anyway.

No really env map is fine, computing the env map on the fly will be slower for sure, and it might not worth the effort.

Already looks pretty good like this.



Keep up the good work!

I’ve watched the video three careful times but coundn’t see the wet or puddle effect clearly, is that “water” on the plane outside the sphere which move along the player???

About the “on the fly” environment map

nehon said :

…and it might not worth the effort

No , it’s worth , smell like UDK , is good , give it a try man !!!

I don’t know it’s cool or not but …



… if the ground is more bump and the “wet effect” make the puddle look more shiny and less bump ← I wonder may be It’s will be way more clearly that the ground is wet !!!



That said if you make the “wet effect” affect bump or normal map (don’t know how :p) … and even glossary map, may be the effect look better?

@atomix Thanks a lot for all your feed back and ideas!



The wet effect is supposed to be inside the sphere that expands around the player. I was more focused on making reflective puddles than anything else, making the ground more shinny will definitively help, its still an early WIP :slight_smile:



I will be trying real time reflections/refraction soon on other things, at which point I may revisit them in here.



I haven’t fiddled with normal maps because for what ever dumb reason I’m having issues with normal maps on my card, and I’d rather be working on new ideas than fixing the basics hahaha (I’m sure that wont lead to problems later down the track;) )



There is no reason why I couldn’t try those maps, I just went with parallax (or bump) because it made sense to me, it essentially represents depth.



During dev I was working with the spec map (which my material wasn’t using) and I hand drew some puddles, it looked ok, i figured I could generate this with perlin noise and then apply it to any material, regardless of the maps it does or doesn’t use. It was that point the I had the idea of using Parallax and here we are.

Cool! Nice work ;)!

thetoucher said:
I haven't fiddled with normal maps because for what ever dumb reason I'm having issues with normal maps on my card, and I'd rather be working on new ideas than fixing the basics hahaha (I'm sure that wont lead to problems later down the track;) )


Just curious... does your geometry have tangent vectors? On some platforms, normal maps do strange things without them... and it's technically always required for normal maps. I thought parallax too required them so maybe you already have that.

What do the normal maps do when you try them?

@pspeed I had no tangent vectors, generated them and its all fine :slight_smile:

Yay… glad it helped. The rim shader idea is really neat and I’m sad I can’t easily use it. In Mythruna, all objects share the same stack of materials… and they are the same as the world materials, too. Never have I wanted per-object uniforms so badly. :slight_smile:

@pspeed duplicate target object geometry, apply new material, set diffuse alpha to 0, render in transparent bucket… would that work for an additional per object material ?

I wish. The geometry is constructed from batches per-material. And actually, ultimately per-object uniforms won’t even help me because the objects will be batched together into groups also. I could just generate it on the fly and somehow flatten the material but Mythruna already churns through direct memory like it was candy. I’ll think of something eventually… but I wish it was just as easy as a three line shader change. :slight_smile: