• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
EternityZA

Projection Matrix generation

7 posts in this topic

Hi.

 

This s a followup question to the one I asked here http://www.gamedev.net/topic/640939-projection-matrix-issue/.

 

In order to pull the near clipping pane close to the camera I had to scale all the values (except for far clipping pane) to glFrustum smaller. This works except it creates alot of jitter in animating models. Im asuming its some kind of percision error. I thought that the solution would simply be to move the far clipping pane closer as wel but no matter how close I move it the jitter remains.

 

How should I improve this?

Thanks in Advance!

 

 

[source]
 
//old values
//l = -1.0;
//r = 1.0;
//b = -768.0 / 1024.0;    //-height / width
//t = 768.0 / 1024.0;      //height / width
//n = 1.0;                       //near clipping pane
//f = 10000.0;                //far clipping pane
 
//new values with clipping pane moved closer but with unacceptable jitter
//l = -0.1;
//r = 0.1;
//b = -768.0 / 1024.0 / 10;    //-height / width
//t = 768.0 / 1024.0 / 10;      //height / width
//n = 0.1;                       //near clipping pane
//f = 10000.0;                //far clipping pane
 
public static Matrix4 glFrustum(float l, float r, float b, float t, float n,float f)
{
FloatBuffer fb = FloatBuffer.allocate(16);
 
fb.put((2*n)/(r-l));
fb.put(0);
fb.put(0);
fb.put(0);
fb.put(0);
fb.put((2*n)/(t-b));
fb.put(0);
fb.put(0);
fb.put((r+l)/(r-l));
fb.put((t+b)/(t-b));
fb.put(-(f+n)/(f-n));
fb.put(-1);
fb.put(0);
fb.put(0);
fb.put((-2*f*n)/(f-n));
fb.put(0);
 
return new Matrix4(fb);
}
[/source]
0

Share this post


Link to post
Share on other sites

The depth buffer resolution at a certain depth is almost exclusively determined by the near clip plane, the far clip plane has almost no impact at all. Trying to improve the depth resolution by adjusting the far clip plane is usually not going to help at all.

 

There was a suggestion in that other thread: make sure that the view point doesn't get too close to the object to introduce clipping at the near plane. This just ensures that the clipping from your first thread cannot happen in the first place. Just don't get closer to the wall than the distance to corners of the near clip plane.

 

Another suggestion to improve the over-all depth buffer resolution is to partition the depth range. That is, split the depth range into sections: given your numbers, let's say two sections from 1 to 100, and from 100 to 10000, and use glDepthRange. then you draw the corresponding depth ranges individually (everything from 1 to 100 in one pass, and the rest in a second pass), but that may be difficult if you have a continuous scene with no easy way to partition objects by depth such that there are no overlap between depth ranges.

 

But to begin with, ensure that you have a maximum resolution depth buffer. Do you have a 24 or 32 bit depth buffer, or do you actually have a reason why you must use a 16 bit depth buffer if that's what you're using?

2

Share this post


Link to post
Share on other sites

The depth buffer resolution at a certain depth is almost exclusively determined by the near clip plane, the far clip plane has almost no impact at all. Trying to improve the depth resolution by adjusting the far clip plane is usually not going to help at all.

 

A recent paper has indeed argued that setting the far plane to infinity can actually improve the precision (particularly if the modelview and projection matrices are not multiplied together before transforming the vertices). But it's the near plane who makes the bigger difference. One should always try to make the near plane as far as possible. 

2

Share this post


Link to post
Share on other sites

hmm. Setting my depth buffer percision to 32 bit doesnt seem to make a difference (unless im doing it wrong). Im just going to move my near clipping pane back to what it was and then im going to scale everything in the scene up 10 times. (1 unit = 1 meter ingame, now 10 units will be 1 meter). That will give the same effect as moving the near clipping pane from 1 meter to 0.1 meter. Its a very tedious solution at this point though but I guess its my only solid option.

0

Share this post


Link to post
Share on other sites

Moving the clip plane and scaling the scene at the same time will do nothing for the precision, because your scene is still at the same relative distance from the near clip plane.

0

Share this post


Link to post
Share on other sites

Im not quite sure I understand. Or we might not be talking about exactly the same thing. If I make the near clipping pane bigger (like it was) that should fix my precision. Why would using bigger models in my scene reduce my precision again? I might be misunderstanding something simple though. Maybe its a matter of just using the available bits in the depth buffer better?

Edited by Wilhelm van Huyssteen
0

Share this post


Link to post
Share on other sites
The precision at a certian depth depends on the ratio between the near plane and the depth you draw at. If you scale the near plane and scale the models at the same time, you negate the effect since the ratio will be unchanged, and the ratio dictates the precision. If you want to improve the precision you need to scale the near plane without scaling your models. THAT will reduce the relative distance of your models to the near plane where the precision is greater.
0

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
Sign in to follow this  
Followers 0