Guidance on how to create a mesh

I know next to nothing about 3D, and I would really appreciate if someone could offer some guidance

Basically what I want to do is to create a mesh fully through code
( I dont want to model it in blender for example )

How do I create a plane like this for example, and then texture it using tiles from a texture2D?

here is an image of what im looking for

I want to achieve this purely by generating it through code ( the textures abcd already exist as texture2D)

I realize this might me an extremely trivial ground level task

so if you could send me to some appropriate tutorials I would greatly appreciate it.

Thanks

It sort of is, I mean it’s more elaborate than “move a character” but sure, if you search for it you’ll find plenty of examples and tutorials. Start with the manual example for instance.

I have a whole repository of random versions of procgen that I call MakeGeo:

MakeGeo is presently hosted at these locations:

https://bitbucket.org/kurtdekker/makegeo

There’s one to make a plane.

Be patient: making procgen geometry is trivial to do, but to do it well takes a lifetime of learning. It is very detail oriented stuff.

thanks for the reply friends

I feel like I am on the right track but just to check…

so lets say that I wanted to do what I have on my example
I cant do 4 vertices only, because of how I need to map the UV

so I would need to do 9 vertices? and so also uv[9]
am I wrong though since the same UV index would be repeated and that wouldnt work for my example

so do I just need to doubleup every vertex? so 4x4 for 16 vertices in this mesh? and uv size [16] aswell

and do I need to have all my tiles on the same texture or is there some way to sample from multiple textures on the same material?

THANKS

No, you would need 16 vertices if you want to specify a different UV for each of your quads. A vertex is not just a point / position. The vertex includes all the other vertex parameters like normal, uv, … If any of those parameters should be different, even though all the other attributes are the same, you need to split the vertex into separate ones.

Note that when you want to create a single mesh and apply 4 separate textures, you would need to use 4 submeshes and 4 materials. This would be quite inefficient. You usually would create a texture atlas with all 4 textures in one texture and use uv coordinates to map individual parts of the texture to your quads.

I once made this WebGL example which might help you to understand how UV mapping works.

1 Like

thank you for the insight

in the event that when I scale I dont have enough space in 1 texture, what is the prescription?

I have seen something like feeding a texture array to the material and then also adding index on the UV that points to the index of the texture array

is that valid?