Game Development Community

Wetness

by Joshua Horns · in Torque 3D Professional · 08/04/2009 (7:49 am) · 125 replies

Rumor has it the wetness effect won't be in the release, so I'd like to think about making one of my own.

To that end I'd like to view the wetness demo that was displayed a few months back but it appears to have been pulled. Is there any way to put that up on the site?

** NM found it on Gerhard's blog.
#81
03/06/2010 (7:34 pm)
@Kory
Just to clarify, whether or not anything beyond 1.1 will be a paid update has not been determined yet.
#82
09/21/2010 (10:29 pm)
Introduction:
Reviving an 6.7 month old thread here. As I've stated in an other thread, this effect will probably never be released by TP (like it was some sort of secret FBI files <.<), and therefore I've decided to try to re-create this effect myself.

As I've also realized that I'll probably need some help by the shader geniuses from this forum to help me with... Stuff (more info below).

Since I'm going to try to re-create this effect for some time now I'll use this thread to documentate my progress and share my methods.

Progress:
So far, I've managed to add an scrolling normal map that scrolls downwards z-wise and creates an nice water flow effect.
img227.imageshack.us/img227/1491/screenshot00700000.png

Question:
I'm currently wondering if someone could help me analyze the wetnes shader video and tell me exactly what method he used to create this effect. As far as i can see there are at least 2 down scrolling normal maps. And it seems that mostly the wetness that is aligned xy-wise (form the camera) is strengthen.

There are quiet some more effects in that video, and I'd like some help to track them all down.

Problem:
This shader seems to be very complicated to do in PostFX (especially when i read the pre-discussion), but I'll try anyways. Like Joshua here, the problem being is that I'm not able to get the normal form the surface in World-Space. I've drawn a painting showing approximately what I'm unable to do:
img178.imageshack.us/img178/6738/wetnessangletheory.png
For the time being, I'd only like some clarification on some shader terms here. First, what is eyePosWorld? Second, what is In.wsEyeRay? How are they defined? Why does In.wsEyeRay depend on where i aim? Can they be used somehow to get the surface normal?
Please don't use many complicated terms when explaining these expression, I'm quiet new to shader script S:
There are some other problems as well, but I'll take care of those later.

Anyways,
Thanks in advance Pat, i know you're reading this :P
Marcus L.

EDIT: I'll be uploading my shader files as soon as these problems are fixed.
#83
09/22/2010 (2:47 pm)
I heard the original code is floating around st TP, maybe someone could post it in the resource thread. Just an idea but I'll talk to some people I know and see if they have an ideas for you Marcus.
#84
09/22/2010 (3:44 pm)
@Kory James

It looks like you have to do this:
You pull the object's normal vector.

side = cross(normal, (0, 0, -1));
down = cross(normal, side);
down.normalize();

down is the correct offset.
I believe wrong results may appear of the cross order,because the cross product is not commutative:
if you have two vector A and B,then A cross B = P * N, where P is a scalar (lenA*lenB*sin) and N is a normal vector. But: B cross A = -P * N
At this point if you have an object and Zrotate this object 180 degrees,then the cross product will inverse the direction.May be this is how direction seems inversed in some cases.

Now having the down direction,you create an UV offset with this value and you're using accumTime to animate the offset.
#85
09/22/2010 (3:51 pm)
It's been a while since I've been looking at these forums. I might try downloading the latest version of the code and playing with it.

Again it's been about 3 million years since I looked at this code but I believe wsEyeRay was the ray which is perpendicular to the view plane in world space coordinates.

I believe eyePosWorld is the coordinates of the "camera" or viewer, again in world space.

#86
09/22/2010 (7:07 pm)
Thanks for the input guys,

@Kory
Thanks, really appreciate it!

@Ivan
I believe what you describe is the same as Pat described in post #1, but this will not work in PostFX for reasons discussed throughout this thread (i believe).

@Joshua
Thanks for the clarifications! I believe you're right (at least it seems like that after playing with the values). Yeah, T3D has gotten some improvements since your last visit here, so you should definitely try it. Just sayin'.

Good news:
I've currently gotten to the point where I'm able to separate 180 degree surfaces form the rest. This is good because animating wetness flows along the z-axis on an flat surface does not look good. Here is a picture of what I've achieved so far:
img836.imageshack.us/img836/8363/screenshot00800001.png
(blue = render wetness | red = don't render wetness)
Also, I've uploaded my current files for people who wants to try or to help me out with the issues.

Question:
What is the normal passed by the prepass texture? More specifically this one:
float4 prepass = prepassUncondition( prepassTex, In.uv0 );
   float3 normal = prepass.rgb;
   float depth = prepass.a;
What is does the normal value represent?

Just so that's said, I'm doing these bold titles for fun :P
#87
09/22/2010 (7:11 pm)
They are per-pixel eye space normals.
Use toggleNormalsViz in console.
#88
09/23/2010 (3:10 pm)
good job Marcus L
#90
09/26/2010 (2:49 pm)
@ deepscratch
Thanks =)

Progress:
I've been busy the last couple of days stupid graphics driver D: but now I'm back working on this PostFX! So far I've been doing some small adjustments here and there, plus added a second down scrolling normal map. I have some pictures here, but pictures aren't moving so it only tells half of how the effect looks :P:
img715.imageshack.us/img715/9787/screenshot00900006.png
Old artwork... Even before i knew about smoothing groups... Just sayin'

img180.imageshack.us/img180/9085/screenshot00900009.png
Argh! My eyes! (yeah, i know its bright.

There is still a lot of bugs to fix and work to do, but for thos who wants to check out this effect in-game, use the same link as i posted previously.
Note: This effect definitively look better with HDR enabled.

Question:
Why does my PostFX overlap the rain effect created by the precipitation object? I will eventually figure this out, but i guess it's better to ask you than to guess my way there.
#91
11/19/2010 (3:40 pm)
I've tried out the code and I'm wondering if there is any update? It seems to work, and if some more work is done to it. It would be an awesome feature for T3D.
#92
11/19/2010 (6:46 pm)
Hey Kory, I have been taking a break from shader coding but i have decided that I will make this feature (some time). You see, the way i develop stuff is feeling based, when i feel like making shaders, i make shaders for maybe a week or two, and then i take a break from it.

Therefore i might soon be back on developing this shader. Last what i remember developing was the reflection part which really annoyed me =/. I will see if i get some time this weekend to get back on developing this shader, and if so, I'll report back here then.
#93
11/19/2010 (10:57 pm)
Hey, Marcus.
That'd be awesome if you could finish this very soon.
It's really cool what you've done, so far.
Not many can do what you've done.

Thanks in advance. :)
#94
11/19/2010 (11:18 pm)
@Marcus thanks, I can see that the effect is pretty close. I wish I had a little more knowledge on shaders so I could help but great start so far!

Also a non related question, What would you think a good lightning solution would be for an effect like this in T3D? : www.youtube.com/watch?v=dhuVmbynjng

@Sorin I totally agree with you.
#95
11/20/2010 (3:23 am)
Marcus. Finish it and sell it..make money your driving force!
#96
11/20/2010 (12:34 pm)
I agree with eb but hopefully you can add more to it to make it a complete shader driven weather simulation for Torque 3D. I can assist as I mention before but I'm not a good programmer, but I have good information that may help. If it will be to much of a task, just do as you been doing and share your work with the community. I'm quite sure people would give you the proper credit.
#97
11/21/2010 (4:19 pm)
@Marcus, I just did some reading on the rendering pipeline T3D usea and the Deferred Rendering doesn't do a good job rendering transparencies which I believe is a big part of this effect. Maybe finding away to by past the method and using a more forward rendering method will help the effect, but again great start to the effect. I can't wait to see it finished!
#98
11/21/2010 (6:09 pm)
Thanks Kory, i guess that explains something. Right now i got a reflection to work with the help of deepscratch.

img507.imageshack.us/img507/209/screenshot01600000.png
Still this reflection needs some work to be applicable for any shape, and after that i need to create some distortion effect. But I'll continue working on this shader this week and hopefully I'll have some result.
#99
11/22/2010 (5:10 pm)
Good work.
Your effort is much appreciated. :)
#100
12/11/2010 (4:15 pm)
@Sorin
Thanks :>

Anyways, yes, I'm still working on this effect. Sorry it took so long but, firstly, life was in the way, secondly, windows + crash = reinstall, third(ly), I realized i was doing this effect the wrong way... after 2 weeks of failing.
Fortunately, I've been able to improve the effect quiet some the last days, and I have currently only 2 issues to fix before I would call it finished.

Until that time, you'll have to do with pictures instead of video:
(right-click->view image for full size)
img255.imageshack.us/img255/2152/screenshot01900010.png
img152.imageshack.us/img152/4307/screenshot01900012.png
img256.imageshack.us/img256/7632/screenshot01900015.png

Or you can try out the effect yourself by downloading this file.