Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Shader Water for all

Author
Message
janbo
15
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 9th Mar 2016 22:10 Edited at: 19th Jul 2017 17:02
Hi,

For all who play with the new terrain... I have enough water for all of you!
During the past few days I've made a Water shader with reflection, refraction and specular highlights for you.
And it comes with a little Demo so you know how to setup and get things running.

Video


3D Water shader Demo
Demo Link

I commented the lines for soft edges and darker color for deeper water, because AppGameKit Version 2.0.18 can't render depth textures on windows, but if you uncomment them you can test it on other OS's.
I'll work on it later and when the new AppGameKit version comes i'll add foam for sure.

Let me know what you have made with it and hope you guys post your improvements and thoughts.


[Edit]
For all who want water but don't like the 3. Dimension.

2D Water shader Demo
Demo Link

[/Edit]

Using AGKv2 Tier1

Attachments

Login to view attachments
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 9th Mar 2016 23:45
That's really nice Janbo. Stunning! Thanks for sharing

Once I have finished my current 2d project, I will do something 3d for sure.
V2 T1 (Mostly)
Phone Tap!
Uzmadesign
Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 10th Mar 2016 00:08
Quote: "AGK Version 2.0.18 can't render depth textures on windows"

It works fine for me, It just can't use render targets as images.
janbo
15
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 10th Mar 2016 17:56 Edited at: 19th Jul 2017 17:02
@Mobiius: You mean, images can be used as render targets
but you can't use images(your target to render to) for the depth textures, not ?

@CJB: Then I have a 2D water shader for you too.
Nothing very special but it is something

2D Water shader Demo
Demo Link

Using AGKv2 Tier1

Attachments

Login to view attachments
Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 10th Mar 2016 18:47
No, you can use depth targets in windows, as use them in the VR Zelda game. you just can't show them onscreen as an image.

Anyway, it's a good shader, and one I'll have a play about with.
empty
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 10th Mar 2016 19:52
Nope, on Windows depth render targets are not usable at this point, as they are always replaced with internal depth buffers (as confirmed by Paul).

Good job, janbo! Will give it a try as soon as I find time to get back to AGK.
janbo
15
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 10th Mar 2016 20:05 Edited at: 19th Jul 2017 17:02
Mobiius !!

Quote: "you just can't show them onscreen as an image"

Thats what i'm saying ..at least wanted to say

Quote: "you can use depth targets in windows"

But then you could uncomment a few lines in the shader and have soft edges like I get on android..but it doesn't work on windows... jet.

Using AGKv2 Tier1
Stab in the Dark software
Valued Member
21
Years of Service
User Offline
Joined: 12th Dec 2002
Playing: Badges, I don't need no stinkin badges
Posted: 10th Mar 2016 21:26
Something is not right with this demo. The FPS is way too low to be usable.
The coffee is lovely dark and deep,and I have code to write before I sleep.
janbo
15
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 10th Mar 2016 23:11 Edited at: 19th Jul 2017 17:02
Yup, if you say me how I can do vertex clipping in stead of discard pixels in the Fragment shader we can save processing the Terrain a 3. time.
But i have not managed to get gl_clipdistance working... So for now it is done per Fragment.
I'll look in to it again tomorrow.

And maybe I messed up with some Render() or Update() commands, but beware that you also need to update the Terrain, bevor you render the reflection Image, or the Terrain will get Clipped where you don't want it to.

You could also reduce the render image size or don't use the special sun fog command.

Using AGKv2 Tier1
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 11th Mar 2016 10:59
Very nice!
Using AppGameKit V2 Tier 1
Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 11th Mar 2016 11:14
Should add it to the AGK2 codebase!
Survey
15
Years of Service
User Offline
Joined: 2nd Sep 2008
Location: WA Australia
Posted: 11th Mar 2016 13:32 Edited at: 11th Mar 2016 13:38
WS.Reputation.1

Your link has a virus according to Norton.

In the 3D water exe file.
Asus T100. Win 8.1 CPU Z3775. AppGameKit V2 2.0.16
HD Graphics (Bay Trail)
empty
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 11th Mar 2016 15:59 Edited at: 11th Mar 2016 15:59
http://community.norton.com/forums/clarification-wsreputation1-detection

Basically Norton says it might be potential risk, because the executable is more or less unknown. O.o
janbo
15
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 11th Mar 2016 18:53 Edited at: 19th Jul 2017 17:02
Must i worry ? (I checked my PC with several tools.. Nothing)
Anyway if you don't trust the executable, just compile one your self

It seems that the clip plane isn't enabled ?!
For Vertex clipping with gl_ClipDistance[0] I need glEnable(GL_CLIP_PLANE0);

Using AGKv2 Tier1
Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 11th Mar 2016 21:03
No, you don't need to worry. Norton is just saying that it's never seen the file before and wrongly saying it's harmful.
Blendman
10
Years of Service
User Offline
Joined: 17th Feb 2014
Location: Arkeos
Posted: 26th May 2016 11:15 Edited at: 26th May 2016 11:36
Hi

I have tried to play with your shader 3D demo, but, When I add some object, the reflexion on the water is strange, and I don't know how I can change that.
I have tried to add a clipping change in syncwater, but it has no effect :



The matter :


On this scene, the sphere is in Y=30 (far above the water ^^)

Do you know how I can change that ?

EDIT : for the moment, to not have the matter with the reflection, I simply hide the object in the second pass for reflection.
AGK2 tier1 - http://www.dracaena-studio.com
janbo
15
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 26th May 2016 19:24 Edited at: 19th Jul 2017 17:02
Hi,

Either you hide it before the render process and show it later again, but then you won't have reflections of that object at all.
Or you add

to the object's pixel shader.
You must then change the clippingplane in your pixel shader like with the terrain one time with the plane hiding the top and one time hiding the bottom.


By the way as Depth images works correctly on windows now you can un-uncomment the few lines in the water pixel shader and get the soft-edge and depth effect.
But I should update the shader and make a system for adding objects to the render process...later


[Edit]

Ops saw your code after writing my post.
If your setup is correct ...try playing with the -GWaterHeight#-2, make the number smaller, something between 0 and -2
If that doesn't work for you, post me the debug images.
[/Edit]

Using AGKv2 Tier1
Blendman
10
Years of Service
User Offline
Joined: 17th Feb 2014
Location: Arkeos
Posted: 27th May 2016 08:35
Hi

I have made severals tests, and I have always that strange reflection :

The code :



I have use the depth texture, and it work, but only for the terrain if I don't use the shader of terrain, else, it doesn't work with the terrain.
And it's good with the depth texture in the water shader


You can test easyli the "bug" witht the reflection with only the water and some big object (box, sphere), like on the next image ( +The debug images) :


I hope this can help.

Another question, I have tried to add a normalmap on the terrain or object shader, but Do I need to add, afetr I have add :



To see the normal map on the shader ?




AGK2 tier1 - http://www.dracaena-studio.com
janbo
15
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 28th May 2016 00:59 Edited at: 19th Jul 2017 17:02
It looks like your objects don't get Clipped by the water Plane or the Clipping Plane is far away
Take my advice above and add the

In the Pixel shader of your objects.
Your sphere for example should be cut in half ...
The top of the sphere on the left debug image and the bottom on the right image, i think

In your 3. Lines of shader Code you calculate the normals of the normalmap but facing updownwards
You could visualise the image normals via adding vec4(normal,1.0) to the result
But I don't exactly understand, what you need me, to tell you

Using AGKv2 Tier1
Blendman
10
Years of Service
User Offline
Joined: 17th Feb 2014
Location: Arkeos
Posted: 28th May 2016 08:33 Edited at: 28th May 2016 09:09
Hi Janbo

Thank you for your answer.

In fact, in my sphere shader, I have yet add the code



And it doesn't work, I get the image I have posted previously.

I have added the line ( vec4(normal,1.0)) to see the normalmap on my sphere and character but it doesn't work properly (it's logical, it add the color, but I don't know how to use that ^^).
I just would to see the normalmap on my models, how can I do and what code should I use to see the normalmap on my models ?

Here is my shader :


Thanks
AGK2 tier1 - http://www.dracaena-studio.com
janbo
15
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 28th May 2016 12:00 Edited at: 19th Jul 2017 17:03
Tested your Pixel shader and the clipping works for me.
I assume that you got the wrong worldposition in your Vertex Shader ?


I cannot say anything to you normal-map thingy as it should work depending on your other setups
If you want, PM me your code and I look over it.


Using AGKv2 Tier1

Attachments

Login to view attachments
GolWofael
8
Years of Service
User Offline
Joined: 15th Mar 2016
Location:
Posted: 28th May 2016 21:03 Edited at: 28th May 2016 21:06
Hi Janbo

Can you create glass shader like the following image ....please
janbo
15
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 29th May 2016 15:05 Edited at: 19th Jul 2017 17:03
I got something today




@GolWofael: The right image looks like they used a normalmap also, because the model is very detailed and smooth
I don't have that yet and I have a problem with the Refracted Depthmap of the water object regarding the glass shader...
But it's a start.

Using AGKv2 Tier1

Attachments

Login to view attachments
GolWofael
8
Years of Service
User Offline
Joined: 15th Mar 2016
Location:
Posted: 29th May 2016 17:35
That's amazing !!
Thank you very mush "janbo "
Blendman
10
Years of Service
User Offline
Joined: 17th Feb 2014
Location: Arkeos
Posted: 30th May 2016 07:56
Hi Janbo

Thansk for the last shader, it's great

I have seen that the bugwith water appears when an object is under water :


And As you can see, I have a matter with the normalmap & spec in my shader ^^

I have send a zip in pm .
AGK2 tier1 - http://www.dracaena-studio.com
janbo
15
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 30th May 2016 11:32 Edited at: 19th Jul 2017 17:04
@Blendman and GolWofael: you both have PM's

I'll eventually make an easy to use system for all my shaders I have done,
but that might be far in the future and you better don't wait for it

I'm looking up to Evolved, but that's huge

Using AGKv2 Tier1
GolWofael
8
Years of Service
User Offline
Joined: 15th Mar 2016
Location:
Posted: 30th May 2016 12:05
Thanks "janbo" for your advice and for your help

Login to post a reply

Server time is: 2024-04-16 21:53:46
Your offset time is: 2024-04-16 21:53:46