[Solved] Frustum clipping happens too early

Started by
4 comments, last by vonflaken 6 years, 6 months ago

Hi there, 

In my engine, the window in z-space to be culled by GL is very thin.

Sprites have to be set at 1-5 units from the camera for not be culled, closer or farther than that won't be rendered.

Camera is orthographic with 0.1 near plane and 100 far.

Please, give me some hint of what's going on.

Thanks in advance.

Advertisement

If you're still struggling with this problem post the relevant sections. Its hard to tell whats going on without seeing the code.

Hi @Yxjmir thanks for your reply.

Yep, It's still up. I recently uploaded project to Github so you can check out here. I guess camera class It's a hot spot here, you can find it in vongine/src/vongine/rendering/, source file is called VGCamera.

The order of matrix multiplication matters, so in Camera::GetViewMatrix() you may have to uncomment this line, I don't know how glm::lookat calculates the view matrix.


//_viewMatrix = glm::lookAt(GetEye(), target, glm::vec3(0.f, 1.f, 0.f)); // Set

Because this maybe be in the wrong order, you could just  reverse the multiplication to check, or use glm::lookat:


_viewMatrix = rotate * translate;

Also, as a side note you can combine Camera::InitOrtho & Camera::CreateOrtho since they're both really small functions (2-3 lines) and CreateOrtho calls InitOrtho.

Hey, 

You are right, the correct order should be translate * rotate.

Anyway that's no that it was causing me headache. Actually, the engine is fine, it just that the camera front is pointing towards negative z-axis and I thought it was upside down, my bad. I always was testing sprites with positive z and the camera at -10 in z.

Pretty dumb on my side.

This topic is closed to new replies.

Advertisement