UV Texture Stretching on a Custom Mesh (Cube)

Currently I’m trying to make a “Voxel” game, and things are going semi-smoothly, but I’ve hit an “interesting” problem recently. Right now, when I define a UV map, the right/top pixels are currently “crammed” (shrunk). Below is a picture.

The UV coordinates for this face are below. (Defined in left-right, bottom-top)
[java](0, 0)(.16f, 0)(0, .16f)(.16f, .16f)[/java]

And besides that the only other thing I’ve done is make the cube part of a custom mesh shape, and apply the “nearest” magnification filter.

Hey chessmaster, your picture doesn’t seem to have come through (I can’t see one). Also a picture of your UV map would be useful (assuming its not dynamically created at run time)

Also, I’m assuming the image for the face you’re trying to render is on a texture atlas (or image used as a texture atlas) where the texture you want is in the top left corner and is 16% of the totalwidth and 16% of the total height? I ask because 1/0.16 is a non exact number, so are your textures different sizes? (not that thats a problem).

Also, when you say ‘cube’, do you mean face of cube, because generally a voxel game doesn’t render full cubes, just the faces of the cube that are visible.

Any more code you have would be useful as well, preferably a “Short, Self Contained, Correct (Compilable), Example” http://sscce.org/

Thanks for the response, as far as the picture is concerned, I’m still learning, but it looks like clicking on the icon will pull it up.

As far as the texture, I some-how got it in my head that “.01f” was one pixel, and I was trying to assign it to pixel 16. I think that that is where my problem is.
As far as rendering individual faces, that is what I’m doing, but at the moment, it’s just one-block, so it’s effectively a cube.

If this doesn’t fix it, I’ll post here if I find something, or I’ll find some sort of “condensed” test-case for an example.

EDIT :: The above did fix my problem. Don’t know how I got the original idea in my head, probably trial-and-error…

One thing I noticed in your picture, if that cube is the only thing in the scene, I don’t think you should have over 900 vertices.

Off topic, but are you running a Linux distribution or is that a windows theme with rocketdock?

<cite>@chessmaster942 said:</cite> trial-and-error...

root of all evil :slight_smile: better to take the time to understand what you are doing, rather than guessing until something looks right

<cite>@8Keep123 said:</cite> One thing I noticed in your picture, if that cube is the only thing in the scene, I don't think you should have over 900 vertices.

Those vertices mostly comes from the text you see in the bottom left, it would probably be better to calibrate it to 0 first

<cite>@wezrule said:</cite> Those vertices mostly comes from the text you see in the bottom left, it would probably be better to calibrate it to 0 first

My bad, I forgot about that lol

How strange, firefox hid the picture, in internet explorer it shows as you describe. Strange, anyway I’m glad you’ve got it sorted. I’m playing about with a voxel game myself and its a whole lot of work and amazing fun, I wish you good luck with it

@wezrule root of all evil better to take the time to understand what you are doing, rather than guessing until something looks right
Yup, I do my best, but some things still slip through XD
@wezrule Those vertices mostly comes from the text you see in the bottom left, it would probably be better to calibrate it to 0 first
I would love to know how to do that, I'm still having to do old-school math by looking away, then looking at it, and subtracting the two numbers...

Thanks agian to @richtea for helping me find the solution.

1 Like

The trouble is the number used for the text will change (i.e. the number 10 uses more vertices than the number 9).

True, but it works for rough-estimates…