0
\$\begingroup\$

I have been trying to figure out how to structure the VBOs in WebGL, and think that keeping them all together in one if at all possible sounds like the best approach. Right now I'm thinking of having color buffer, position buffer, and index buffer, just those 3. But my question is what about a texture buffer (maybe it's called a UV buffer, but I'm not sure if that's 3D only).

I would like to have a game with basically flat colors and alpha/opacity and some drop shadows perhaps, maybe some glows, but nothing too complex. Mainly it would be like traditional vector graphics look but in WebGL. As such, I'm wondering how to solve the texture problem. If I need a texture, or I don't at all need one.

Part of figuring this out is knowing what you should really be using textures for. I get that they are useful for mapping images to geometry, but I don't know of any other use case. Wondering if one could explain some use cases of textures as it applies to my situation. The main goal is figuring out if I need a texture buffer at all, or I can/should just stick with color/position/index.

A look I like is like this:

enter image description here

\$\endgroup\$
  • \$\begingroup\$ Can you show us a visual target for what you expect your art assets to look like? Be sure to call out any aspect of the image you don't know how to achieve without textures (or with textures) \$\endgroup\$ – DMGregory Mar 13 at 0:07
  • \$\begingroup\$ You know you can have multiple shaders, right? Let one handle textures if you need them in the future \$\endgroup\$ – Bálint Mar 13 at 0:09
  • \$\begingroup\$ I might need to have JPG photos in the game here and there too at some point. \$\endgroup\$ – user10869858 Mar 13 at 0:11
  • \$\begingroup\$ I have exported svg files into Blender and then exported them as triangle meshes. You could do this either with pure VBOs or with textures. (Yes UV co-ordinates is correct) \$\endgroup\$ – Jay Mar 13 at 10:42
1
\$\begingroup\$

You probably will want to use textures. Looking at the image you posted, I would probably make the door one texture, have another one for the lights, the wreath another, the pumpkins another, etc. That way the door can be a single quad, instead of the 9 or more it would take to draw that door using only geometry.

In addition to simply mapping images to geometry, textures can be used for a variety of other things. They can be used as a gradient. You'll likely still apply that to geometry, but not necessarily in a straightforward way. (You might make a radial gradient display on some geometry using a 1D gradient texture, for example.) They can also store things like velocities. For example, you can use a texture as a "flow field" for animating particles or other objects. They can even be used to control geometry. You can sample a texture in a vertex shader, for example, and use the result to determine how to transform the vertex.

\$\endgroup\$
  • \$\begingroup\$ Oh wow, excellent ideas on the textures! Thank you. So it sounds like you're saying make the entire light one object as a texture, so you simplify having to do all the geometry. Makes sense for performance optimization. \$\endgroup\$ – user10869858 Mar 14 at 6:10
  • \$\begingroup\$ Yes, that's likely how I would do it. \$\endgroup\$ – user1118321 Mar 14 at 16:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.