I’ve an 8 vertices dice whose vertices are outlined as follows:
static constexpr fixed float3 dice() = {
{ 0.5, 0.5, 0.5},
{-0.5, 0.5, 0.5},
{ 0.5, -0.5, 0.5},
{-0.5, -0.5, 0.5},
{ 0.5, 0.5, -0.5},
{-0.5, 0.5, -0.5},
{ 0.5, -0.5, -0.5},
{-0.5, -0.5, -0.5}
};
static constexpr fixed float2 uv() = {{0, 0}, {1, 0}, {0, 1}, {1, 1}};
Dice index buffer:
let indices: MTLBuffer
// ...
indices = machine.makeBuffer(bytes: (
0, 1, 3, 3, 2, 0,
4, 6, 7, 7, 5, 4,
0, 4, 5, 5, 1, 0,
3, 7, 6, 6, 2, 3,
2, 6, 4, 4, 0, 2,
1, 5, 7, 7, 3, 1
) as (UInt16), size: 72, choices: ())!
For the reason that indices solely go 0-7, there are solely 8 indices in whole processed by the vertices shador. However this has the limitation that the 8 vertices will need to have the identical Texture coordinates worth, along with the place, and many others.
At present, I’m configuring the feel coordinates of the output vertex to uv(vid & 4 ? vid ^ 7 : vid)
the place uv
It was outlined above and vid
It’s merely the vertex_id
0-7. I’m attempting to use This texture to all of the faces of the dice.
Nonetheless, this isn’t totally right. The dice is being represented to the left, whereas a guide building dice of 6 particular person quads is being processed accurately to the proper. Observe easy methods to the left, the textures on the perimeters are distorted.
Is there any clever strategy to render an 8 -vertices dice to see? additional* Just like the one on the proper with out having to signify 24 vertices as a substitute of 8?
*I do know that if the vertices share texture coordinates, have a distinct edge edge (as proven to the proper) is straight away inconceivable, however is there any clever strategy to keep away from distortion? Or is it so inconceivable with out altering to the tactic of constructing 24 vertices, or 4 for every of the 6 faces, after which apply the right texture coordinates from there? Possibly there some type relying on how int
both uint
Is the vertex shador outlet about, I do not utterly perceive?