Jump to content
  • Advertisement
vonflaken

OpenGL [Solved] Frustum clipping happens too early

Recommended Posts

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.

Edited by vonflaken
Mark as solved.

Share this post


Link to post
Share on other sites
Advertisement

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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!