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 Studio Chat / Need help with 2D Shaders

Author
Message
Arch-Ok
AGK Developer
5
Years of Service
User Offline
Joined: 11th Jul 2019
Location: Bursa/TÜRKIYE
Posted: 11th Aug 2024 22:41
Hi, I was using Classic and when it came to Android SDK Update I had to move on with Studio. But the problem is, now everything messed up. I suspect the shaders I use which were ok with Classic. I set the renderer to basic but nothing changed. For example, when I try to set a variable in a shader for color, it changes to object's (sprite, text) position. I'm not into shaders that much and I hope my shaders are buggy. If this is the case can someone fix them for me? The very core of the shaders are so tiny and simple;
Vertex Shader


Pixel Shader


And here what I mean with messed up;







OpenGl and Vulkan are different ofcourse, so can anyone fix those tiny shader codes suitable for Studio please?

Attachments

Login to view attachments
blink0k
Moderator
11
Years of Service
Recently Online
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 13th Aug 2024 21:58 Edited at: 13th Aug 2024 21:59
Try adding this to the first line of your program
#renderer "Basic"
Arch-Ok
AGK Developer
5
Years of Service
User Offline
Joined: 11th Jul 2019
Location: Bursa/TÜRKIYE
Posted: 13th Aug 2024 22:41
@blink0k Thank you. I tried that but nothing changed. Just if someone might adjust those tiny shader codes for Studio to make them work as they expected would be great. My only hope is those shader codes of mine are wrong.
smerf
19
Years of Service
User Offline
Joined: 24th Feb 2005
Location: nm usa
Posted: 14th Aug 2024 05:56
i think we might need more information or a test project with a shader, Its a big difference but from a shaders perspective its small it could be a tiny difference of a .1 of a float value causing you this issue or it could be that multiply on the shader texture color. Id suggests try using a mix maybe (txt,colorVar,colorVar.a)

Arch-Ok
AGK Developer
5
Years of Service
User Offline
Joined: 11th Jul 2019
Location: Bursa/TÜRKIYE
Posted: 16th Aug 2024 17:43
Sorry for late answer, it was a busy week. For a group of sprites like 20+ sprites in it, I only load one shader and set their shader to the same shader. But when it comes to 'text group' like 20+ texts in it, I load same shader for every single of the texts and set their shaders to their own, separately. It works in Classic but maybe not in the Studio? And then the texts are still buggy but I'll give it a try anyways, hope I find some solutions and share the info here.
Arch-Ok
AGK Developer
5
Years of Service
User Offline
Joined: 11th Jul 2019
Location: Bursa/TÜRKIYE
Posted: 16th Aug 2024 18:30
Nope. It just got even worse.
Arch-Ok
AGK Developer
5
Years of Service
User Offline
Joined: 11th Jul 2019
Location: Bursa/TÜRKIYE
Posted: 16th Aug 2024 18:35
Actually using the same shader for lots of sprites in the same group is just fine. Classic proves this. Shaders are buggy in Studio, maybe setshaderconstant commands or maybe agks attributes paassed to the shaders are or maybe converting GSLS to SPIR-V Idk. I am sure not my job to find out and, I'm so done with agk...
agkcoder
19
Years of Service
User Offline
Joined: 12th Dec 2004
Location: AGK Forums
Posted: 17th Aug 2024 22:13
Arch-OK, as smerf said, it would be cool if you could provide a small code with a mini-shader and some simple media that produces the same bug you're describing. So we could try to figure out what is not working properly, maybe try to fix it, or if nothing else we could just avoid it by knowing about it or find workarounds.
Arch-Ok
AGK Developer
5
Years of Service
User Offline
Joined: 11th Jul 2019
Location: Bursa/TÜRKIYE
Posted: 18th Aug 2024 11:37 Edited at: 18th Aug 2024 12:54
Ok, just left click and move the mouse in the window.







Please be informed that my library is way more complex and has tons of attributes and abilities but this testing just matches positioning ability and even at this point, Studio fails. (Thank god for early fail)


Setting object depths and setting their shader constants are buggy. Bonus, opentoread & write is also buggy, it corrupts string space eventually, you may test it if you know what I mean. There are more bugs, to find way arounds but I stopped informing them years ago cuz nobody seems to check them.

Thanks for trying mates, I do appreciate very much...

Edit: Tested on Windows 11
agkcoder
19
Years of Service
User Offline
Joined: 12th Dec 2004
Location: AGK Forums
Posted: 19th Aug 2024 00:34 Edited at: 19th Aug 2024 08:16
...processing...

smerf
19
Years of Service
User Offline
Joined: 24th Feb 2005
Location: nm usa
Posted: 20th Aug 2024 05:03
I took a look at your project and I'm not really sure what you want it to do. I'm guessing make a little green square on a Redbox? there may be a few issues with it. I overrode the color and saw that is is clipping then i realized your attempting bit shifting with operators that don't work in agk >> && don't function. .Left and .right are also reserved keywords. Might start with combing through your code. the shaders look fine and passing vars seems correct

Arch-Ok
AGK Developer
5
Years of Service
User Offline
Joined: 11th Jul 2019
Location: Bursa/TÜRKIYE
Posted: 20th Aug 2024 05:57
Thanks for trying.
Arch-Ok
AGK Developer
5
Years of Service
User Offline
Joined: 11th Jul 2019
Location: Bursa/TÜRKIYE
Posted: 21st Aug 2024 18:25 Edited at: 21st Aug 2024 18:26
Reported this as an issu at git hub. Hope this time they find a solution.

Oh and the link;
https://github.com/TheGameCreators/AGK-Studio/issues/1129
Arch-Ok
AGK Developer
5
Years of Service
User Offline
Joined: 11th Jul 2019
Location: Bursa/TÜRKIYE
Posted: 30th Aug 2024 12:51 Edited at: 30th Aug 2024 12:53
even this does not work in Studio. it affects just nothing.
any ideas?



edit: ofcourse it works as expected in Classic.
Arch-Ok
AGK Developer
5
Years of Service
User Offline
Joined: 11th Jul 2019
Location: Bursa/TÜRKIYE
Posted: 30th Aug 2024 21:08
Since I'm making mobile apps I don't need Vulkan so I updated shader codes to this and set renderer to "Basic";

vertex shader;



pixel shader;


the interesting part starts here, when you change the pixel shader code to this;


still the green sprites are gone. That is a bug.

Even;
myOutputColor = vec4(0.0, 0.0, 1.0, 0.1);
shows only the red sprites but in Classic the alpha blending shows all.
Arch-Ok
AGK Developer
5
Years of Service
User Offline
Joined: 11th Jul 2019
Location: Bursa/TÜRKIYE
Posted: 30th Aug 2024 23:04 Edited at: 14th Sep 2024 08:07
It's definetely a bug to be fixed.
Arch-Ok
AGK Developer
5
Years of Service
User Offline
Joined: 11th Jul 2019
Location: Bursa/TÜRKIYE
Posted: 31st Aug 2024 15:06 Edited at: 14th Sep 2024 08:09
It seems like Studio sends wrong datas for color and/or position attributes.

Login to post a reply

Server time is: 2024-11-17 22:29:48
Your offset time is: 2024-11-17 22:29:48