Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hughsk/glsl-square-frame
Given a screen size, get values between -1 and +1 for the current pixel
https://github.com/hughsk/glsl-square-frame
Last synced: 12 days ago
JSON representation
Given a screen size, get values between -1 and +1 for the current pixel
- Host: GitHub
- URL: https://github.com/hughsk/glsl-square-frame
- Owner: hughsk
- License: other
- Created: 2014-08-15T01:30:54.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2014-12-07T20:45:25.000Z (almost 10 years ago)
- Last Synced: 2024-10-17T16:39:16.027Z (22 days ago)
- Language: C
- Size: 128 KB
- Stars: 6
- Watchers: 4
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# glsl-square-frame [![stable](http://badges.github.io/stability-badges/dist/stable.svg)](http://github.com/badges/stability-badges)
Given a screen size, get values between -1 and +1 for the current pixel.
Useful for full-screen shaders: whereas `gl_FragCoord.xy` changes scale with the
canvas and sending the `[width, height]` over yourself results in stretching
unless you scale it properly – using this function lets you get consistent
points regardless of aspect ratio.See the code in [`example.frag`](http://github.com/hughsk/glsl-square-frame/blob/master/example.frag)
for example usage.## Usage
[![NPM](https://nodei.co/npm/glsl-square-frame.png)](https://nodei.co/npm/glsl-square-frame/)
### `vec2 squareFrame(vec2 size)`
### `vec2 squareFrame(vec2 size, vec2 coord)`Returns a `vec2` containing the scaled screen position, ranging between -1
and +1.* `size` is a `vec2` containing the `[width, height]` of your canvas.
* `coord` is the position of the current fragment, in pixels. Defaults
to `gl_FragCoord.xy`.## License
MIT. See [LICENSE.md](http://github.com/hughsk/glsl-square-frame/blob/master/LICENSE.md) for details.