Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default template code has bad coordinate generation #16

Open
WAHa06x36 opened this issue Sep 21, 2012 · 0 comments
Open

Default template code has bad coordinate generation #16

WAHa06x36 opened this issue Sep 21, 2012 · 0 comments

Comments

@WAHa06x36
Copy link

The default code that gets loaded when a new effect is created has some pretty bad code for generating the coordinates. It generates coordinates in the range 0..1 on both axes, no matter the size of the window. This causes effects to be stretched in one direction or another under most circumstances.

As this is rarely if ever desired, it should be replaced with a better line, saving people the work of replacing it themselves when they notice their effects look wrong in another browser window.

I suggest the following:

vec2 position=(2.0 * gl_FragCoord.xy - resolution) / max(resolution.x,resolution.y);

This generates coordinates in the range -1..1 on the larger axis, and less on the other. If you want a 0..1 range on the larger axis, this should work, but this is less useful as it is hard to center anything:

vec2 position=gl_FragCoord.xy / max(resolution.x,resolution.y);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant