I’ve been playing around with texture atlases the past few days and have been having a bit of fun. One thing that I did which I’m not sure on how beneficial it was, was to combined my mesh diffuse, normal and specular maps into a single image. Was a fun project, works great.
What I am considering now is something that I’m sure will have a payoff. I have several meshes that use merged buffergeometry with multiple
groups for material indexes. I originally did this as opposed to separate meshes thinking it would make a difference. Turns out… not so much. Each Mesh has as many drawcalls as it’s geometry has groups.
So, what I am thinking of is creating a texture atlas that contains the diffuse/normal and specular maps for each piece of merged geometry.
Before I start coding this out, will this even work? I am going to need to know at least the geometries current index value in order to determine which uv coordinate to sample right?
I know I can access the
gl_VertexID according to https://www.khronos.org/opengl/wiki/Built-in_Variable_(GLSL), however since this is not accessible in the fragment shader (right?), would I need to create a varying variable in order to access this value within the fragment shader? Is there a better (or more common) way to do this?
Not sure if it’s worth all this work, but I am super curious.
I’m relatively new to shader programming so sorry if this is a dumb question.