Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / Objects disappearing as they move away from the camera

Author
Message
047
18
Years of Service
User Offline
Joined: 4th Jun 2006
Location:
Posted: 12th Aug 2007 06:53
Does anyone know why or how to prevent some objects (usually thin, open ones) from disappearing or partially disappearing as they move away from the camera? I tried changing the object culling with the 'Set Object' command but unless I'm doing something wrong or missing something else, it seems to have no effect on the object whether I set it to '0' or to '1'. Making the 3d object slightly thicker has helped in some case, unfortunately that isn't always an option for the type of 3d models I need to create for my project. I'm using DBC. Any ideas? Thank you!
Crazy Programmer
AGK Developer
20
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Lost in AGK
Posted: 12th Aug 2007 07:06
did you try set camera range?


http://www.freewebs.com/zornoxstudios/
Learning C++ thanks DGDK
047
18
Years of Service
User Offline
Joined: 4th Jun 2006
Location:
Posted: 12th Aug 2007 07:34
It's not all the objects that disappear. For example I created a model of a person with 3 separate objects, one for the body, one for the hair and one for the clothes glued to the body object. When the distance from the camera is about 200 part of the hair and the clothing objects begin to partially disappear as the distance increases, until they are completely invisible. The main object will still show OK long after the clothing and hair limbs are no longer visible. So no, it's not a camera range problem. And it seems to happen mainly with open models.
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 12th Aug 2007 10:10
@ 047

Hello,

If you are making your objects in a 3d modeler, try making sure the normals are calculated for both sides of the object. If the normals are in one direction, chances are you will only be able to see one side of the face. Or simply try reversing the normals. You may have to experiment to see what works best.

The normals in combination with the culling setting might help to solve the problem.

Enjoy your day.
047
18
Years of Service
User Offline
Joined: 4th Jun 2006
Location:
Posted: 12th Aug 2007 10:50
I don't know much about normals but I thought that it only affected lighting on the surface of an object to make it look smoother. Can normals actually cause an object to become transparent or to make it disappear? Are there any commands in DBC to calculate object normals other than Set Normalization On and Off or am I supposed to do that with the modeler program (I use Anim8or)? I'm going to experiment with it but can you give me an example of what I need to do? I searched the forum but most posts are about Matrix Normals.
Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 12th Aug 2007 16:47
Quote: "I tried changing the object culling with the 'Set Object' command"

Culling means that only the polygons that are visible to the camera will be drawn, the "back" of the object wont be drawn.
Turning culling off would mean that the "back" of the object is drawn to screen, it would not solve your problem.

Your signature has been erased by a mod because it was rubbish.
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 12th Aug 2007 18:58
It sounds like the problem you are describing is a Z-Depth problem which occurs when objects are placed very close together and viewed from quite large distances.

You can set one object to always appear over another to stop this happening, but in this case I don't think it would help.

I would look at scaling everything down considerably - it should fix the problem.

TDK_Man

Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 12th Aug 2007 21:42
Quote: "I don't know much about normals but I thought that it only affected lighting on the surface of an object to make it look smoother. Can normals actually cause an object to become transparent or to make it disappear?"


It gets a little tricky and without going into too much detail - there is a winding order of vertices that draws a face. This winding order determines which side of the face is the front and which side is the back and the perpedicular to this face is the normal. The direction of the normal is determined by this winding order. The left hand rule and right hand rule will determine the direction of the normal based on the winding order of the vertices. Depending on the direction of the normals, and object can appear inside out - what is supposed to be the front face is actually the backface. If culling is on, a face may be completely invisible to the camera from the front (instead of from the back). If culling is off, you won't see the effect at all.

As far as lighting, a 3d engine will use the normals to calculate how to disperse light. The same rules apply as to the camera. The direction of the normal will determine how the light reflects or passes through a face.

The object doesn't become transparent and doesn't disappear per se, but the faces may not be drawn because they would be considered to be backfaces.

I've attached an example of a cube with reversed normals. I created it in Anim8or, then just used the flip normals menu item to reverse the normals. It should appear insde-out.

Enjoy your day.

Attachments

Login to view attachments
Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 12th Aug 2007 22:29
@Latch
How can a cube be inside out?
I will test it and see
Am I right in thinking that each vertex has its own normal, like it has its own XYZ axis that are rotated to the direction of the normal?

Your signature has been erased by a mod because it was rubbish.
047
18
Years of Service
User Offline
Joined: 4th Jun 2006
Location:
Posted: 13th Aug 2007 03:28
OK, here's an example of what happens to some of my models. In this example when the distance from the camera is about 334 some parts of the model that were created with separate objects begin to disappear. Look at the bike's muffler or the headlight or the rear view mirrors. In this case it doesn't affect my project too badly, it actually kind of adds a shine effect. But when it happens to a human model's clothing it's no so good anymore. What do you guys think the problem is? Still think it's some of the previously suggested ideas? Thanks!

Attachments

Login to view attachments
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 13th Aug 2007 04:39 Edited at: 13th Aug 2007 05:02
Quote: "How can a cube be inside out?
Am I right in thinking that each vertex has its own normal"


When looking at the cube you won't see the outside faces - you will see the three inside backfaces so it will look as though there are no sides towards the camera. It will appear to recess. It's hard to describe but you'll see it if you look for it.

A normal is calculated using vectors. Since a vertex is a point, it can't have a normal. However, for lighting effects and smoother gradation, an average of the face normals surrounding a vertex are taken and this average vector is often called the vertex normal. In a directx file, the normals are usually represented as averaged face normals and called vertex normals.

As far as displaying the polygon, the crossproduct of the actual vertices is taken to produce a face normal (seems redundant doesn't it?). The reason is a face normal is needed in order to be able to display the polygon. The vertex normals are used to control the lighting. I haven't downloaded your example so I don't know if this has naything to do with your problem.

Anyway, here's a clearer example of what I was talking about. I'm attaching a grid that has normals on only the front side. If you rotate this grid around x (basically flip it over) it will disappear once the backside is exposed to the camera.

Enjoy your day.

Attachments

Login to view attachments

Login to post a reply

Server time is: 2025-05-30 13:43:17
Your offset time is: 2025-05-30 13:43:17