Jump to content
havenphillip

Bepuddled terrain effect

Recommended Posts

Bepuddled terrain effect. I was able to put this together based on an old Shadmar shader I began fiddling with, but it's different enough that I didn't feel the need to credit him so I did it here.

*credits Shadmar*

Make a box and attach the waterterrain.lua script to it. Then drag the player into the "Player" slot of the script so it can access the camera. That's it. (Also don't forget to have a skybox set)

Some settings considerations:
It looks better on darker terrains so I set the diffuse color to about half, put the specular all the way up and set roughness to 0.0 in the Material Editor. Terrains tend to look darker when wet anyway.

Diffuse texture is set to uncompressed with mipmaps because it's so large.

Textures should be set up as shown below.

 

 

Water Terrain.zip

 

bepuddled.png

setting.png

clickdrag.png

  • Like 4

Share this post


Link to post
Share on other sites

They're kind of stretching long on the x-axis so you can go in the shader and find this line (around line 49):
vec2 spec_texcoords0 = ex_texcoords0/(vec2(puddlesize));
...and change it to this:
vec2 spec_texcoords0 = ex_texcoords0/(vec2(puddlesize/2,puddlesize));

That seems to have squared them up.

Share this post


Link to post
Share on other sites

One thing about this I've noticed is the flashlight doesn't evenly light the ground in 360 degrees. If I change "nmat" in the vertex shader from:

    //Sky
    mat3 nmat = mat3(camerainversematrix); //inverse sky on model stays in place
    ex_normal = normalize(nmat * vertex_normal);    
    ex_tangent = normalize(nmat * vertex_tangent);
    ex_binormal = normalize(nmat * vertex_binormal);

...to this, the flashlight works correctly but the sky reflection doesn't.

    //Flashlight
    //mat3 nmat = mat3(entitymatrix); //flashlight works 360
    //ex_normal = normalize(nmat * vertex_normal);    
    //ex_tangent = normalize(nmat * vertex_tangent);
    //ex_binormal = normalize(nmat * vertex_binormal);

I tried a few things including using an "if" statement but haven't been able to solve this. If anyone's already figured this out I'd like a solution. It's not too much of a big deal. It just irks me.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

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...