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 / Basic 2D shader questions: co-ordinates

Author
Message
nz0
AGK Developer
17
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 5th Aug 2017 00:00
I want to be able to work with co-ords rather than percentage in the sprite frag shader.

I ultimately need to pass multiple x,y co-ords to my shader, but first I have to work out what a screen pixel is.

I could do 1.0/1024.0 or that kind of thing, but is there a way to use a passed var like AGK_Ortho to quickly reference pixels?

I should say that I am using a full screen sprite, so it will always be the same size as "resolution".

In the same question, how does SetShaderConstantArrayByName( shaderID, szName, arrayIndex, value1, value2, value3, value4 ) work? Can I use it on 2D shaders?
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 5th Aug 2017 08:41 Edited at: 5th Aug 2017 08:43
maybe this helps
GetSpritePixelFromX ( iSpriteIndex, x )
GetSpritePixelFromY ( iSpriteIndex, y )
that coords belongs the used image position.
i guess you are looking for the back buffer size.

from reading the agk docu i would say yes you can. it seems it fills a vec4 type.
https://www.khronos.org/opengl/wiki/Uniform_(GLSL)
AGK (Steam) V2017.07.19 : Windows 10 Pro 64 Bit : AMD (17.4.4) Radeon R7 265 : Mac mini OS Sierra (10.12.2)
janbo
15
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 5th Aug 2017 14:23
I think 1.0/agk_resolution should do the trick.
from the agk doc: vec2 agk_resolution - The resolution of the current render target, image or window
Quote: "use a passed var like AGK_Ortho"

I'm not sure what you mean by that.
Quote: "how does SetShaderConstantArrayByName( shaderID, szName, arrayIndex, value1, value2, value3, value4 ) work ?"

It can pass float,vec2,vec3 and vec4...just start at value1

Using AGKv2 Tier1
nz0
AGK Developer
17
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 7th Aug 2017 14:54
How should I define the array in the shader?

Does it need to be pre-declared?
janbo
15
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 7th Aug 2017 19:51
Quote: "Does it need to be pre-declared?"

Yes

Using AGKv2 Tier1

Login to post a reply

Server time is: 2024-09-30 05:24:06
Your offset time is: 2024-09-30 05:24:06