Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Corona fragment screen position
Started by Madrayken Nov 25 2015 01:20 PM

3 replies to this topic
shader fragment screen
[TOPIC CONTROLS]
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

Madrayken

[GLOBAL: userInfoPane.html]
Madrayken
  • Observer

  • 7 posts
  • Corona SDK

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



[TOPIC: post.html]
#2

StarCrunch

[GLOBAL: userInfoPane.html]
StarCrunch
  • Contributor

  • 846 posts
  • Corona SDK

Hi.

 

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

 

Are you running into issues trying to use it?



[TOPIC: post.html]
#3

Madrayken

[GLOBAL: userInfoPane.html]
Madrayken
  • Observer

  • 7 posts
  • Corona SDK

(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.



[TOPIC: post.html]
#4

StarCrunch

[GLOBAL: userInfoPane.html]
StarCrunch
  • Contributor

  • 846 posts
  • Corona SDK

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.




[topic_controls]
[/topic_controls]