Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - petej

Pages: [1]
1
General discussions / Re: Texture atlas tiling
« on: August 19, 2024, 09:42:03 pm »
Thanks for the reply!  A little broader research suggests this is possible with OpenGL shaders, so maybe I can do this by using the Shader class and binding a Texture to it.

https://community.khronos.org/t/repeat-tile-from-texture-atlas/104500

2
General discussions / Texture atlas tiling
« on: August 19, 2024, 10:03:52 am »
I am trying to draw a 2D terrain.  I have defined a heightmap, created a VertexArray of type Triangles, and populated it with the vertices of my heightmap.  Specifying vertex colors works great, but I am now trying to use textures instead.

I have a texture atlas (e.g. see attached) that contains sub-textures for the different areas (e.g. grass, rock, etc.).  I need to have those sub-textures tile across the triangles because some triangles are bigger than the sub-texture and most do not align with a texture boundary.  Note that I am using an irregular grid (think something derived from a voronoi diagram) for the heightmap, so using grid-aligned quads is not possible.

When I set the texture to repeat, and specify texture coordinates, it tiles the whole texture atlas, not just a single texture.  I can make this work (e.g. see attached) by breaking the atlas into individual textures, and creating one VertexArray per area (e.g. grass, rock, etc.).  However, this means I must use a single texture across an area, with no ability to vary the texture, unless I create more individual textures and VertexArrays.

Is there another way to accomplish tiling of a sub-texture in an atlas?  Does the question make sense?

Pages: [1]
anything