2
\$\begingroup\$

I am making a voxel game with OpenGl, I've got the major parts working, except the camera seems small compared to the the blocks. How do I make the camera bigger?
Do I do a scaling on the model matrix for each chunk? Or do I do something with the view matrix of the camera? When i tried these things, it messed up the coordinate system of my game, the blocks were not where they really were. I just want the player to be visually 2x bigger.

// the view matrix
glm::mat4 Camera::GetViewMatrix()
{
    glm::mat4 view = glm::lookAt(position, position + target, up);
    return view;
}


    // Where i do the chunk rendering
void WorldRenderer::RenderChunck(Chunk *c)
{
    glActiveTexture(GL_TEXTURE0);
    worldTexture->BindTexture();
    worldShader->Bind();
    worldVertexBuffer->BindVertexArrayBuffer();
    worldVertexBuffer->PutVertexData(c->meshData.verts, c->meshData.indices, c->meshData.textureCoords);

    glm::mat4 model = glm::mat4(1.0f); // model = local space to world space
    model = glm::translate(model, vec3(c->pos.x * Chunk::CHUNCK_SIZE, c->pos.y * Chunk::CHUNCK_SIZE, c->pos.z * Chunk::CHUNCK_SIZE));

    worldShader->setMat4f("model", model);
    glDrawElements(GL_TRIANGLES, c->meshData.indices.size(), GL_UNSIGNED_INT, 0);
}
void WorldRenderer::Render(glm::mat4 projectionMatrix, glm::mat4 viewMatrix)
{
    worldShader->setMat4f("view", viewMatrix);
    worldShader->setMat4f("projection", projectionMatrix);

    for (Chunk *c : renderedChunks)
    {
        this->RenderChunck(c);
    }
}

Image of the game

\$\endgroup\$
3
  • \$\begingroup\$ Try scaling geometry in view space in the shader \$\endgroup\$
    – Ocelot
    Sep 6, 2020 at 0:21
  • \$\begingroup\$ For anybody finding this question from search engine: depth of field is something else that affects the perception of size. \$\endgroup\$
    – Theraot
    Feb 20, 2021 at 21:55
  • \$\begingroup\$ @Theraot I think the vast majority of 3D games don't even have depth of field, and they work just fine. Eye height is more important. \$\endgroup\$
    – user253751
    Feb 21, 2021 at 12:38

2 Answers 2

3
\$\begingroup\$

Move the camera higher up. The human brain expects to see things from the normal human eye height above the ground, about 150-170 cm. So your walls look about 4-6 metres high. Make the camera 10 times as high, and now they're 0.4-0.6 metres high.

Your current perspective is appropriate for a dungeon crawler where each wall is a voxel and the walls have traps and doors in them and so on. It's not appropriate for a Minecraft-style game. Minecraft intends to have 1-metre cubes, so it places the camera 1.6 cubes above the ground.

As HolyBlackCat said, don't forget to choose an appropriate movement speed as well.

\$\endgroup\$
1
\$\begingroup\$

There's no such thing as "camera size". If you have a free-moving camera, the perceived "camera size" depends solely on the camera movement speed.

If you make your world N times larger and increase the movement speed N times, those two actions will cancel each other out, and the end result will be the same.

So instead of making the world larger, make the camera move faster. There's nothing more to it (except maybe changing the initial camera position to be higher above the ground).

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .