Quote: "The problem is the number to divide by is unknown. I am trying to find out where to get the divisor."
agk_Resolution are preset values always available to you within GLSL Shaders (see: Working with Shaders from the AppGameKit Help for a full list of Preset Values populated by AGK)
Normalisation of a value can be obtained one of two ways... but a 0.0 to 1.0 is a simple case of Value / MaximumValue
CurrentValue / MaximumValue
i.e.
514 (Pixel Position) / 1080 (Screen Width) = 0.470
try using this:
float2 ConvertToTextureSpace( float X, float Y )
{
result float2( X / agk_Resolution.x, Y / agk_Resolution.y );
}
float2 ConvertToScreenSpace( float U, float V )
{
result float2( agk_Resolution.x * U, agk_Resolution.y * V );
}
Oh as a note I forget which does it., but OpenGL and Vulkan use slightly different Texture Spaces (one is -0.5 to +0.5 while the other is 0.0 to 1.0) and AppGameKit doesn't differentiate. So you might need a pre-processor condition with U -= 0.5; V -= 0.5; for converting to the correct texture space., else the values might be shifted when using converted Screen Space values.
Now as a keynote... "Resolution" DOES NOT refer to the Screen Resolution!
It refers to the Image Resolution., meaning it will be the same Resolution as the Output Render Target (which in the case of the Shader is the Texture Image Resolution)
This is specifically why we use Texture (Cartesian Space) instead of World (Euclidian Space) Coordinates., because the actual Resolution of what we're using is typically going to be an unknown; but we don't really NEED it... think about it., we NEED our Shader to work on Multiple Resolutions to support things like Mipmapping, Anisotropic Filtering, etc.
And actually we can do some quite clever things with manipulation of Mipmaps in regards to things like Blur, Reflection, etc.
You say you want exact positions of things in regards to the UV... alright., you know the percentages; which translate to U = 0.5 and V = 1.0 - 0.15 // 0.85
There's no additional step to take with Cartesian Space; as the image is 0.0 to 1.0 in terms of coordinates.
If we were using Pixel Space., well we'd NEED to know the Resolution.
As a 2048x2048 image... 50% is 1048 and 85% is 1741 pixels; where-as with a 1024x1024., these values become 512 and 870 respectively.
In Cartesian Coordinates... well regardless of the image size., we always want coordinates 0.5 and 0.85 respectively.
I'd argue learning this coordinate system and how to calculate it in AppGameKit is a good idea for things like Scalable UI.