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

Add rationale in the README? #9

Open
bfops opened this issue Nov 13, 2014 · 4 comments
Open

Add rationale in the README? #9

bfops opened this issue Nov 13, 2014 · 4 comments

Comments

@bfops
Copy link

bfops commented Nov 13, 2014

I'm having some trouble understanding the need for this repo. I found this, but as far as I know, OpenGL texture units that solve this problem. Can somebody clarify this for me?

Thanks!

Edit: Oh this makes sense if there's a backend being supported that doesn't support texture units. Are there other use cases I'm missing?

@bvssvni
Copy link
Member

bvssvni commented Nov 13, 2014

Yeah, the idea is to have implementations of the algorithms.

Where can I find more information about OpenGL texture units?

@bfops
Copy link
Author

bfops commented Nov 13, 2014

https://www.opengl.org/wiki/Texture#Texture_image_units and http://stackoverflow.com/questions/25373634/opengl-rendering-with-multiple-textures?noredirect=1#comment39595524_25373634 are both a good basis.

Each sampler in a shader is bound to a specific texture unit (e.g. GL_TEXTURE0), not a specific target (e.g. GL_TEXTURE2D), so you can do something like:

glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE2D, tex1);
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE2D, tex2);
glUniform1i(tex1_loc, 0);
glUniform1i(tex2_loc, 1);

and then both your textures will be available inside the shader.

Looking into it a little further though, it looks like the number of texture units can be pretty limited (e.g. 32), so it doesn't scale nearly as well as sprite sheets created with this repo.

@kvark
Copy link
Member

kvark commented Jul 28, 2016

Texture atlas is an old and well-known technique, still used in production, albeit much less than before.
Binding many small textures is just slower than binding a single atlas.

I do agree though that the rationale needs to be a part of README.

@simnalamburt
Copy link
Member

Good idea. This repo can always accept more PRs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants