简体   繁体   中英

Particles with different textures in OpenGL

I'm using OpenGL version 3.2 and have successfully created a particle system. I draw my particles using instanced rendering and giving the particle offset in the instanced buffer. I use billboarding to find the correct rotation for the particle.

My current problem is that if I wanted to use different types of particles with different textures I'm unsure how to do so in a 'good' way. I can't find any information on how to pass a texture ID in as vertex data which was my first thought. I could pass in an integer and use an if-elseif structure to find the correct structure but this doesn't seem right.

OpenGL 3.2 supports 2D array textures. That would be the simplest way of giving these instanced particles different textures using an integer index. There is one caveat here, that each of the textures should have the same dimensions, but that's probably not a big deal for particles.

Newer versions of GL also support bindless textures (as an ARB extension) and they can be used for the same purpose, but 2D array textures are what I would personally consider pursuing. Otherwise, the really archaic fallback would be to use up to 16 different texture units or a packed texture atlas and modify the texture coordinates per-instance.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM