Jump to content

How to use the underwater shader?


havenphillip
 Share

Recommended Posts

Ah ok. What's the one you were talking about earlier that comes with Leadwerks but doesn't look very good? I have the Shadmar shader. But I wanted to compare it to something else so that I can learn shaders. When I look at it it just looks like nonsense to me.  I wish there were more tutorials and shader packs I could get my hands on so I could mess with them.

Link to comment
Share on other sites

2 hours ago, havenphillip said:

What's the one you were talking about earlier that comes with Leadwerks but doesn't look very good?

Just the one that Leadwerks activates when you add water to a scene.  If you move the camera underwater, there is no blue/swaying effect at all.

By the way, shadmar uploaded a version to dropbox some months after that discussion Thirsty Panther linked.  The post is here: https://www.leadwerks.com/community/topic/10334-day-and-night-cycle-shader/?do=findComment&comment=106706
I believe that's the latest version but someone let me know if that's not the case.

 

  • Like 1
Link to comment
Share on other sites

I think a while back I just used the wobble.shader in the stock assets. The trick is checking if the camera is below the world's water level and applying/removing the effect respectively. You can also use the engine fog system with the wobble shader and get a decent result.

Cyclone - Ultra Game System - Component PreprocessorTex2TGA - Darkness Awaits Template (Leadwerks)

If you like my work, consider supporting me on Patreon!

Link to comment
Share on other sites

I did watch that tutorial. It was pretty good. I grabbed that Day/Night shader. I was hoping it had the rain shader attached to it. I found this snow shader online and was able to get it working but I can't figure out how to get rid of the grey background. It works as a PostEffect but pretty much useless thus far.

#version 400

uniform float currenttime;
uniform vec2 buffersize;

float time=currenttime/1000.0;

out vec4 fragData0;

float snow(vec2 uv, float scale, float time)
{
    float w=smoothstep(1.0,0.0,-uv.y*(scale/10.0));if(w<.1)return 0.0;
    uv+=time/scale;uv.y+=time*2.0/scale;uv.x+=sin(uv.y+time*.5)/scale;
    uv*=scale;vec2 s=floor(uv),f=fract(uv),p;float k=3.0,d;
    p=.5+.35*sin(11.0*fract(sin((s+scale)*mat2(vec2(7,3),vec2(6,5)))*5.0))-f;d=length(p);k=min(d,k);
    k=smoothstep(0.0,k,sin(f.x+f.y)*0.01);
    return k*w;
}

void main(void)
{
    vec2 uv=(gl_FragCoord.xy*2.0-buffersize.xy)/min(buffersize.x,buffersize.y);
    float c=smoothstep(1.0,0.3,clamp(uv.y*.3+.8,0.0,.75));
    c+=snow(uv,30.0,time)*.3;
    c+=snow(uv,20.0,time)*.5;
    c+=snow(uv,15.0,time)*.8;
    c+=snow(uv,10.0,time);
    c+=snow(uv,8.0,time);
    c+=snow(uv,6.0,time);
    c+=snow(uv,5.0,time);
    vec3 finalColor=(vec3(c));
    fragData0 = vec4(finalColor,1.0);
}

 

//vertex

#version 400

uniform mat4 projectionmatrix;
uniform mat4 drawmatrix;
uniform vec2 offset;
uniform vec2 position[4];
uniform float currenttime;

in vec3 vertex_position;
out float time;

void main(void)
{
    gl_Position = projectionmatrix * (drawmatrix * vec4(position[gl_VertexID]+offset, 0.0, 1.0));
}

 

 

 

Link to comment
Share on other sites

  • 1 year later...
On 2/18/2019 at 11:31 PM, reepblue said:

I think a while back I just used the wobble.shader in the stock assets. The trick is checking if the camera is below the world's water level and applying/removing the effect respectively. You can also use the engine fog system with the wobble shader and get a decent result.

Hi there team!! Hi there Reepblue!!

I'm working on my project trying to make this idea. Using WOBBLE.SHADER effect only underwater... But i don't know how check if the camera is below the world's water level. And more less how apply or remove effect by code...

Any clue so I can get it???

This is the starting design for my idea:

screenshot54.thumb.jpg.cae7382abe27bfc1290fa2d02cc9ee69.jpg

Link to comment
Share on other sites

1 minute ago, Marcousik said:

Yeah, i have check those links and another ones, but my problem is that i'm new in LUA and I fail in the syntax when i encode them in my scripts.

For examplen for underwater i wanted use WOBBLE.SHADER adding it with a COLLISION TRIGGER. To simulate we are dry, and we enter to water.

My codes fail a lot because the sintax. And finally with help of the forum (especially Josh give me this) i have use the correct code for solve my case:

function Script:Collision(entity, position, normal, speed)
	if self.enabled then
		if entity.script ~= nil then
			if entity.script.camera ~= nil then
				entity.script.camera:AddPostEffect("Shaders/PostEffects/wobble.shader")
		        self.enabled = false
			end
		end
	end
end

I love you guys!!

I'm learning a lot about LUA sintax. ☺️☺️☺️☺️

  • Like 1
Link to comment
Share on other sites

32 minutes ago, shadmar said:

There are water shaders in Dino Land you can steal (whole game is unencrypted)

I believe the rest of the sahders are also there. 

But Steal is a horrible word ????

Anyway thanks!! I will look the code of shaders to learn from them, if I don't need it anymore because I have finished the underwater area of my game. Used the default stuff has Leadwerks inside it. (I think wobble.shader is developed by you Shadmar)

This is the final result of yesterday work (thank you very much team with the help about sintax of how use addposteffect). I'm very satisfied with it:

 

 

  • Like 3
Link to comment
Share on other sites

20 hours ago, Russell said:

@shadmar incredible Dino land!!

I don't need now, but in the future in another "minigame" or level in my museum, would you give me your permission to use the camera model and fps hands??? They are cool!! 

They are made by @tjheldna so it's not my permission to give. But you can use the shaders to your liking if not otherwise is staded in them.

  • Thanks 1

HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB

Link to comment
Share on other sites

12 hours ago, Marcousik said:

Hey Russel Nice showcase.

How did you do the floor reflections may I ask? It s cool and realistic

As adebgamesoft said, i have use SSR.SHADER (inside our Leadwerks) on PostEffects area inside ROOT. (It's a Shader like GODRAYS, SSAO o WOOBLE)

SSR.jpg.17c2521722d35fb07ba833b8146d2d90.jpg

Anyway, to take advantage of the effect, be sure work and create diffuse and Normal textures, with this the shader works well and we will get that aspect and relief on the reflection of the SSR.SHADER.

But if you create and use too Specular and Displacement textures, you will get better effect of relief with the reflections of the shader.

Texture.thumb.jpg.2be752c079651980db975e184eb1fc64.jpg

  • Like 1
Link to comment
Share on other sites

Just now, Marcousik said:

Right thx adebgamesoft

 Actually it would be nice to use this shader on a specific material as it seems to turn all the scene to marble: It is so impossible to compose a scene with old creepy material and marble

You don't need specify material for the Shader...

You can change the textures are you using for SSR doesn't work on CREEPY material or old Wood or Cloth textures... For example in my game, this reflections don't work on my Cloth textures or rought Stone material...

But you need play with the diferent types of textures you can create on your MATERIALS.

Link to comment
Share on other sites

9 minutes ago, Marcousik said:

Right thx adebgamesoft

 Actually it would be nice to use this shader on a specific material as it seems to turn all the scene to marble: It is so impossible to compose a scene with old creepy material and marble

Here...

Example only using DIFFUSE texture on our material (the skin on Triceratops). The SSR make the skin shiny and with reflection.

Activado.jpg.d353b60c8196b70329f1aa14867c8d1d.jpg

 

But if we work NORMAL and SPECULAR textures for the same Material, SSR doesn't work on them. Example on the same Material (the Skin of Triceratops):

Desactivado.jpg.9be4386800364e08c517b91e503b5c65.jpg

It's pure desing, not programation...

?

  • Like 2
Link to comment
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.
Note: Your post will require moderator approval before it will be visible.

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.

 Share

×
×
  • Create New...