I just started out with D3D 11. My goal is to write a cube voxel engine (Minecraft style). Actually it's working pretty solid already, but when I finally tried to change the size of my cubes, I ran into a problem:

No matter how large I make my cubes, they always appear super large when I move very close to them. Although they appear in a different size when I declare them in a different size and look at them from the same absolute distance.

For example: Let's say I make my cubes have a width, height, and depth of 1.0, and another time I give them a width, height, and depth of 0.01, and both times I look at them from a distance along the z axis of -1.0. The 1.0 cubes look larger than the 0.01 cubes. But I think this is only because the "relative" distance (100 cubes vs 1 cube) is a lot larger. The problem is, when I move very close to my 0.01 cubes, they become just as large as my 1.0 cubes with the front side filling almost the entire screen. I am very confused right now, since I have no clue as to how I can make my cubes appear smaller when I get very close to them. The problem is, the smaller I make my cubes, the closer I have to be able to get to them in order to make them appear as if they were right in front of me, which always results in huge cubes. Can anybody please help me figure out how to make my cubes appear smaller?

I don't know if this matters, but here is how I make my cubes:

1) Create a mesh for each chunk of voxels. In this process, I already define my vertices in world coordinates taking into account the cube size that I want (this is working, I printed out my vertex data with different cube sizes).

2) When rendering, each frame, I take the view projection matrix from my camera and send it to the shader. My vertex shader then simply does the following to my world coordinate vertices:

vout.pos = mul(float4(vin.pos, 1.0f), vpMatrix);

I also made some screenshots to show my problem. I just made a simple 32x3x32 map with different textures at each height.

1) Cube size 1.0, distance 10.0: Cube size 1.0, distance 10.0

2) Cube size 0.1, distance 10.0: Cube size 0.1, distance 10.0

3) Cube size 1.0, close distance: Cube size 1.0, close distance

4) Cube size: 0.1, close distance: Cube size 0.1, close distance

As you can see, at a distance of 10.0, the size difference is noticeable. But the closer I get, the less the size difference appears. A cube size of 0.1 at a close distance is still way too large. Almost as large as a cube size of 1.0 (which should be 10 times bigger?). I can go lower and lower on the cube size, but it just stays way too big at close range. And at some point, I can't go any lower. So, is there a way to make my cubes at a close distance look just a little bit bigger than the cubes seen in the second picture (cube size 0.1 at distance 10.0)?

Here is another screenshot of a more complex "map" proving, that I should actually be rendering stuff correctly: rendering

  • 3
    \$\begingroup\$ a screenshots would help here i think. \$\endgroup\$ – Raxvan Dec 9 '13 at 17:28
  • \$\begingroup\$ Make your player taller, that's how you make the world smaller in a first person game. \$\endgroup\$ – MickLH Jan 8 '14 at 20:07

I think there is a problem with your "close distance"

Because even if your object is very small, when you get extremely close to it, it will look large.

Is your "close distance" same in picture 3 and 4? Or do you get closer to them manually? If you are navigating manually, if your step_length is very small, then it is possible to come very close to a very small object, which will make it appear large.

Edit: Can't comment so I post this as an answer.

  • \$\begingroup\$ you are absolutely right, i was using the camera to get closer to the objects and my step distance in this case was simply half the cube size. so yes, i am getting "closer" (in an absolute sense) to the smaller cubes than to the larger cubes. the problem is, the distance in pictures 3 and 4 were still the size of half a cube each, which is still a lot. so in pic3, it was 0.05 and in pic4 it was 0.5. but in games like minecraft, you can walk up to a cube until u basically touch it (so the distance is definately smaller than half the cube size) and the cubes still wont look super large. \$\endgroup\$ – webman Dec 9 '13 at 19:40
  • \$\begingroup\$ @webman I have never played minecraft so I won't be able to help you much further, but if you get extremely close to something, that means you should only see that and see it very large. (your whole screen should be only one box for example). So that means, in minecraft, the prespective view is implemented in a way that it is not realistic (this is what I conclude from what you tell, I may be wrong). So very close objects are scaled less than further objects is my guess. So for example, in shader, for perspective view you divide by "w" coordinate. That w can be dependent on z by a formula \$\endgroup\$ – Kogesho Dec 9 '13 at 19:47
  • \$\begingroup\$ what you say makes perfect sense. maybe i do have a matrix problem at last. is there an easy way to create a projection matrix, that does exactly what i need (create a matrix manually instead of using XMMatrixPerspectiveFovLH), or will i really have to do extra computations inside the shaders with w coordinates like you stated? \$\endgroup\$ – webman Dec 9 '13 at 20:28
  • \$\begingroup\$ @webman I don't really know because I don't know the exact requirements (as I don't know minecraft). It is better if you create a new topic specifying your requirements more clearly (as they are more clear now), by providing screenshots from your application and from minecraft for the same case. Then I and other people can help you better. \$\endgroup\$ – Kogesho Dec 10 '13 at 12:45

Make your player taller. Currently you are not tall enough to give the illusion of size you want.

The reason you can get so close is obvious if you imagine real life, because even while standing against a wall, your relative height is what determines your perception of size, not the distance.


I am not sure I understand your problem, but it always helps to check your matrices. Have you transposed them before sending to shader (edit: base on your implementation, you might need to)

  • \$\begingroup\$ It depends on the implementation if the matrix is required transposed or not. Even if this would be the there would be nothing rendered or just garbage polygons. \$\endgroup\$ – Raxvan Dec 9 '13 at 17:31
  • \$\begingroup\$ You are right, but he should still be checking them out. \$\endgroup\$ – János Turánszki Dec 9 '13 at 19:01
  • \$\begingroup\$ if i transpose my matrices before sending them to the shader, nothing is shown. so i think it shouldnt be a matrix problem and rendering in general works. \$\endgroup\$ – webman Dec 9 '13 at 19:10
  • \$\begingroup\$ Ok I just didn't get it with no screenshots. I understand the problem now. \$\endgroup\$ – János Turánszki Dec 9 '13 at 20:13

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.