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

Please pass texture resolutions to shaders #2364

Closed
mal opened this issue Sep 20, 2020 · 3 comments
Closed

Please pass texture resolutions to shaders #2364

mal opened this issue Sep 20, 2020 · 3 comments

Comments

@mal
Copy link
Member

mal commented Sep 20, 2020

The textureSize function was only added in GLSL 1.30 and GLES 3.0 so at present it's not possible to create or use shaders that rely upon or make use of texture aspect ratios or pixel calculations as there's no good way to pass texture dimensions to a shader program.

Would it be possible to add this information as standard under a predictable name? I'd suggest something like resN to mirror texN, such that uniform vec2 res0 would hold the pixel dimensions of tex0 and so on for the available textures. The data (at least for tex0) is already available to the Transform at the time shader uniforms are being set, so this seems like it could be a quick and simple win.

Would be happy to PR a basic version of this. 🙂

@renpytom
Copy link
Member

I think that makes sense to do, so if you want to PR it, I'll accept it.

@renpytom
Copy link
Member

a8e2cc0 fixes this. I didn't think your PR was correct - you're using the resolution of the Model, which is in virtual pixels, rather than the resolution of the actual texture, which is in drawable-space pixels. I also made this change as the uniform is loaded, provided that it's loaded from a GLTexture (which it should be everywhere except for the texture loader.)

@mal
Copy link
Member Author

mal commented Sep 24, 2020

Aha! Thanks, taking a look implementing the correct solution, this addition looks to be working great in the a8e2cc0 nightly! 🎉

@mal mal closed this as completed Sep 24, 2020
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

2 participants