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 / Can we access model matrices for shaders yet?

Author
Message
Santman
13
Years of Service
User Offline
Joined: 15th Sep 2011
Location: Inverness
Posted: 30th Jun 2024 17:38
Hey.

Long time AppGameKit user, but I abandoned it long ago after it....well, let's be kind and say on the PC front couldn't keep up!

One of my frustrations was the rubbish lighting, and only basic directional shadows. I know Janbo and Evolved have release their own shader (I own the shdaer pack), but these seem way way too complicated to include, especially since all TGC need to do is give us access to a couple of matrices that they must be generating internally anyway. I asked Rick a couple of times, but never got any answer.

What I mean is, if we take a simple billboard shader (from Bing co-pilot):


So looking at this, this is what I have deduced from what TCG make available in shaders, to this code:
uniform mat4 gxl3d_ModelViewProjectionMatrix; = mat4 agk_ViewProj
uniform mat4 gxl3d_ModelViewMatrix; = mat4 agk_View
uniform mat4 gxl3d_ProjectionMatrix; = mat4 agk_Proj
uniform mat4 gxl3d_ViewMatrix; = ???
uniform mat4 gxl3d_ModelMatrix; = ???, but not needed anyway in this shader

Anyone any ideas? The code below works fine, but only while the object is placed at 0,0....as soon as you move it, the effect just goes all over the place. I am fairly sure this is because the gxl3d_ProjectionMatrix is wrong, or the position is wrong.

James H
17
Years of Service
User Offline
Joined: 21st Apr 2007
Location: St Helens
Posted: 2nd Jul 2024 19:10 Edited at: 2nd Jul 2024 19:30
In light of you asked and got no response from Rick - you could try other TGC members but use Discord instead, orvillian, the next. dave are usually on the agk server, or Lee if you have access to the ggmax server, or just Lee by email as thats available publicly.

You should be okay to use evolveds code from his common.agc to get the view matrix and there is code showing its use. Looks like you just have to set up a test project and call whats relevant; so some pre loop set up stuff like create effect for example, in main loop you might have to use evolveds cam controls(for now) so the cam data gets processed and then call the view matrix function, send it to shader. I wanna stress that I am not saying I know this will work for certain, but in theory it should.

I will say that I had a go at converting his shaders from vulkan to ogl and found that passing arrays to the shader in ogl fails. So if you are using ogl, start off in vulkan for the test first, then convert. If the intention is ogl at any point then what you have to do for anything in evolveds(or your own code) is instead of passing the array, break it up into vectors(within the relevant functions that you need that also use mat4 sending as an array to shader) and send the 4 of them, but then in the shader reconstruct those vectors as your mat4. Hope that made some sense. I did post them(the easy ones) on discord so there is code there showing what I mean. https://discord.com/channels/436107917037404160/436107917037404162/1201724968459837632 The cube lighting has code to show breaking up of mat3 array I think that is 3 vec3 reconstructed as a mat 3 - I don't recall what others I had to deconstruct/reconstruct so thats the only example I can recall. If you post .ps maybe with simple example of agk code you use I could give it a shot?(not that I know it will work for certain but will save you some hassle seeing as I am the one saying this stuff lol)

Am fairly sure someone already did a billboard shader - I think it might have been Blendman. I will look for link and edit this post if I find it.

I don't suppose you have an update on your project by chance? Another vid would be cool I was literally saying just days ago while discussing editors that it had been a good while since your last post - thought we might have lost you, good to see you're still around.

Edit: So while looking for where I thought Blendmans shader might be I came across another instead https://forum.thegamecreators.com/thread/214598?page=2#msg2582932
Win 10 Home 64, Intel(R) Core(TM) i5-10300H, 8GB DDR4, NVidia GeForce GTX 1650 4GB GDDR6
agkcoder
19
Years of Service
User Offline
Joined: 12th Dec 2004
Location: AGK Forums
Posted: 2nd Jul 2024 23:25
Santman, according to Rick, Lee is dealing with all things AppGameKit now. Contact Lee.
Santman
13
Years of Service
User Offline
Joined: 15th Sep 2011
Location: Inverness
Posted: 7th Jul 2024 18:28 Edited at: 7th Jul 2024 19:26
Hi guys.

AKG or Studio, not really bothered...AGK is dead now anyway going by the updates, so that's why I came back to look at Studio. If I'm honest, I kind of hoped it had advanced slightly to be more than AppGameKit with a GUI, but it appears not. Anyway, I shall try getting in touch with Lee.

As for my editor, no I've done nothing more as I moved away from AppGameKit totally; essentially without access to key shader functions to improve things like the shadows and lighting anything PC based just look....old. Did I not post a copy of it? I'm just looking at it in Studio now - it has a few issues to fix before it will run, but once I get it up and running I'll happily share all the code if you want to try and decipher it.
Santman
13
Years of Service
User Offline
Joined: 15th Sep 2011
Location: Inverness
Posted: 7th Jul 2024 19:38
So I have it running, but the same shader issues as launch still seems to be there - the "Position" attribute isn't passed anymore, so the water doesn't move. Everything also seems darker, and the landscape is now showing lines, so I am guessing the mipmapping thresholds have also been moved. Other than that, performance seems to have taken a good old hit as well, which is odd.

Has anyone else noticed that general performance, especially file access, is slower with Studio over AppGameKit? And this is using OpenGL.
James H
17
Years of Service
User Offline
Joined: 21st Apr 2007
Location: St Helens
Posted: 16th Jul 2024 16:12
Not so sure I have the time(or capability!) to look through and understand the code in full at least...but others might benefit far more than me.

Win 10 Home 64, Intel(R) Core(TM) i5-10300H, 8GB DDR4, NVidia GeForce GTX 1650 4GB GDDR6
Raven
19
Years of Service
User Offline
Joined: 23rd Mar 2005
Location: Hertfordshire, England
Posted: 24th Jul 2024 15:01
Model Matrix = agk_World
View Matrix = agk_View
Projection Matrix = agk_Proj

All of the Matrices we _could_ use are going to be combinations of multiplying these together., but we have a few pre-calculated versions available to us.

agk_ViewProj is agk_View * agk_Proj
agk_WorldViewProj is agk_World * agk_ViewProj



That should be the original code converted to AGK
Santman
13
Years of Service
User Offline
Joined: 15th Sep 2011
Location: Inverness
Posted: 23rd Aug 2024 22:33 Edited at: 23rd Aug 2024 22:35
Hmmmm....nope, that doesn't work at all, that's even worse. However the breakdown you gave:

Model Matrix = agk_World
View Matrix = agk_View
Projection Matrix = agk_Proj

Might be. Are you sure about the model matrix? I've been trying much more complex shaders and I am pretty sure agk_World isn't the model matrix.

Take this for example:
https://learnopengl.com/Advanced-Lighting/Shadows/Shadow-Mapping

And this specific part of the code:


The model matrix is the one (I think) we have no access to, and why others have had to create complicated ways to calculate it that are much slower.

Login to post a reply

Server time is: 2024-11-17 22:24:09
Your offset time is: 2024-11-17 22:24:09