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 / Any 2d water shaders?

Author
Message
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 21st Mar 2017 22:16
I checked the shader thread and didn't really find what I wanted. Think top-down view, not side-scroller. Something that just sort of showed some animated caustic effects. I'd like to use it as an optional layer in my TMX loader and I know nothing about shaders.

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds
janbo
16
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 21st Mar 2017 22:29 Edited at: 21st Mar 2017 22:30
Hey Phealax,
I'll look into it tomorrow and maybe convert a shader found somewhere flying around in the World Wide Web
Can you describe or show the effect you want to achieve ?

Using AGKv2 Tier1
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 22nd Mar 2017 01:23
Preferably something not image-dependent, so a user can change the texture to fit their tile maps.

Here's an animated one I did using a caustics generator to build the animation frames.
https://www.youtube.com/watch?v=kaV2v_Y-9Ro

Same tiles (i think) mixed with a tile map:
https://www.youtube.com/watch?v=nruqQ7muVPc


But honestly, I have no specific style envisioned.

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds
janbo
16
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 22nd Mar 2017 14:05 Edited at: 22nd Mar 2017 14:08
I got something to play with...
Four different shader, they are commented out.
not sure about the texture dependency, but I'm sure the 4th would count as independent.
That shader was 3 lines and I still don't understand it
I don't get that zooming out of the equation for now

Using AGKv2 Tier1

Attachments

Login to view attachments
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 22nd Mar 2017 22:59 Edited at: 23rd Mar 2017 00:12
I think the zooming has something to do with illustrating noise generation, just a hunch based off some stuff I read earlier about perlin noise. But looking at the code for water4, I'm so lost lol. So I studied it like I did QB programs way back in the day, start changing variables to see what happens!

The zooming is happening with this:
k.xy = uvVarying*agk_time;

My best guess is that agk_time is equal to agk's timer() function, the runtime of the app in seconds (a float). So changing agk_time to a literal constant like 10.0 stops the zooming. Higher numbers zoom out further.

Thanks for those shaders! 3 and 4 I think are my favorites.

I changed water4.ps to the following:



Then you can adjust the level of zoom with:




"I like offending people, because I think people who get offended should be offended." - Linus Torvalds

Attachments

Login to view attachments
janbo
16
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 23rd Mar 2017 00:25 Edited at: 23rd Mar 2017 00:27
Of-course it is the agk_time, its obviously...I scale the UV coords
Got little Concentration problems the last days

But I'm glad I could help you
And it looks good in the level

Using AGKv2 Tier1
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 23rd Mar 2017 00:38
I've added another variable to control the alpha level, so I can have some water shimmering effects over top of whatever might be underwater. (like an old cobblestone road) Setting the sprite's alpha had no effect when shaders were applied. Yet setting it in the shader code itself also didn't appear to effect anything. To make the alpha take effect in the shader, you have to set the sprite's alpha channel to anything other than 255. Only then will the shader work with an alpha value.


"I like offending people, because I think people who get offended should be offended." - Linus Torvalds
janbo
16
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 23rd Mar 2017 00:53 Edited at: 23rd Mar 2017 00:58
Who said that he doesn't know anything about shaders ? ...leaning by doing

Make it more easy for you to change things, like so

Change the color via SetShaderConstantByName(ShaderID,"color",0.0,0.1,0.2,0.2)

Using AGKv2 Tier1

Login to post a reply

Server time is: 2024-11-24 18:58:01
Your offset time is: 2024-11-24 18:58:01