Corona fragment screen position

Hi folks,

I’m new to Corona and trying to transfer one of my projects over from another SDK.

Some of the shaders I have written require the pixel knowing its screen position. 

In OpenGL there’s a gl_FragCoord that is part of the fragment data. I’ve checked through all the documentation but I can’t see an equivalent anywhere.

How do I find the position of the pixel a fragment shader is trying to write to?

Many thanks for your time,

  • D

Hi.

It’s in GLES, too. See the top of page 4, here: GLES reference

Are you running into issues trying to use it?

(sigh) No. Not apart from having too little coffee. You’re right. It works perfectly. Doh! I assumed Corona put a wrapper around it somewhere and didn’t document it. Never occurred to me that it would just work out of the box. Thanks! 

By the way… don’t you ever sleep? I’ve looked up about 50 things over the last 48 hours and you were first in with help in almost every thread!

For people coming to this post hoping for an answer:

TLDR: Yes, you can get the screen position of a pixel in the fragment shader from gl_FragCoord.

Good to hear it. Also, the “transfer one of my projects” got me a little curious. Spellrazor looks really nice!

I’m subscribed on this particular sub-forum and have the advantage of some background on the shaders side of things. Once more users can say the same I shouldn’t be quite so ubiquitous.  :) If we’re talking non-graphics topics too, it was probably just coincidence.

Hi.

It’s in GLES, too. See the top of page 4, here: GLES reference

Are you running into issues trying to use it?

(sigh) No. Not apart from having too little coffee. You’re right. It works perfectly. Doh! I assumed Corona put a wrapper around it somewhere and didn’t document it. Never occurred to me that it would just work out of the box. Thanks! 

By the way… don’t you ever sleep? I’ve looked up about 50 things over the last 48 hours and you were first in with help in almost every thread!

For people coming to this post hoping for an answer:

TLDR: Yes, you can get the screen position of a pixel in the fragment shader from gl_FragCoord.

Good to hear it. Also, the “transfer one of my projects” got me a little curious. Spellrazor looks really nice!

I’m subscribed on this particular sub-forum and have the advantage of some background on the shaders side of things. Once more users can say the same I shouldn’t be quite so ubiquitous.  :) If we’re talking non-graphics topics too, it was probably just coincidence.