Search Home Members Contacts
About Us
Products
Downloads
Community
Support
Pages: [1]
  Print  
Author Topic: Meshes disappear in certain angles (and transparency)?  (Read 1142 times)
bbence
Customers
Community Member
*****
Posts: 944


WWW
« on: December 07, 2011, 04:28:23 PM »

Hi!

I have a strange problem that meshes disappear at certain angles. It seems to be a quite consistent behaviour. Here is a video showing the effect:
www.meltingpot.hu/data/model_disappears.avi

Any ideas how and why does it happen?


Thanks in advance for any help!

Best wishes,
Bence
Logged
Mithrandir
Community Member
*
Posts: 325


« Reply #1 on: December 07, 2011, 07:27:50 PM »

Alpha sorting?
Logged
bbence
Customers
Community Member
*****
Posts: 944


WWW
« Reply #2 on: December 08, 2011, 07:40:53 AM »

Hm, what do you mean exactly? Smiley
I have enabled alpha sorting for the meshes in question...
Logged
Mithrandir
Community Member
*
Posts: 325


« Reply #3 on: December 09, 2011, 03:12:48 PM »

Well I'm not sure how to fix it but it looks like the alpha order is getting messed up.
Are the windows part of the same mesh as the train?
Logged
bbence
Customers
Community Member
*****
Posts: 944


WWW
« Reply #4 on: December 12, 2011, 11:43:50 AM »

Yes. But I have also tried it with a separate mesh for the windows (not for each window, but if all else fails, I might try that).

It seems that MergeMeshes is the culprit, at least partially. If I don't merge all the trees into 1, then it works. Problem is, I'm cheating and the train is not really moving, but all the other meshes are moving, that is why it has to be ideally one mesh, to be able to call SetPosition more effectively. The reason that I don't want to move the train mesh is because the player can stay on the train for however long he wants, and if I moved the train, then the physics engine migh "run out" of coordinates.
Logged
Mithrandir
Community Member
*
Posts: 325


« Reply #5 on: December 12, 2011, 02:51:46 PM »

What if you just merge meshes on one side of the train. I'm not sure how exactly is the alpha sorting implemented but I imagine that you get problems when you put the camera inside the mesh. So if you merge meshes on each side of the train separately the camera will be effectively between them, not inside.

Also culling, collision detection and other stuff works faster if you have separate meshes so reconsider your merging strategy.
Logged
Mithrandir_
Moderator
Community Member
*****
Posts: 349


WWW
« Reply #6 on: December 12, 2011, 04:46:07 PM »

So you merge everything outside the train together and then move that as one? How many meshes are there? I don't think changing the position of meshes is all the CPU intensive.

Have you considered attaching meshes (not merging them)? Then if you move a parent mesh all the child meshes move too.
Logged

bbence
Customers
Community Member
*****
Posts: 944


WWW
« Reply #7 on: December 13, 2011, 04:14:04 AM »

Yes, I have already separated them on each side, so I have two merged meshes.

But good idea that I should attach them together! I haven't thought about that but I will definitely give it a shot! Thanks!
Logged
Waterman
Moderator
Community Member
*****
Posts: 1157


« Reply #8 on: December 13, 2011, 07:20:56 PM »

Ya that must be a depth sorting issue. If the trees are billboards, then their rotation matrix is bound to the cameras rotation. Maybe that's why they disappear when just turning the cam. And related to what Mith said; meshes have center points, by which various comparisons take place. It's always good to have them clearly distinguished, so that not all mashes are located at (0,0,0) or identical coordinates.

I don't know what you actually code, but IF it's some kind of train (or large area) simulator, your technique is not good. As such, it's correct to keep the camera at 0 and move everything else. But going your current way, you lock yourself into technique of adjusting the position of (more and more, as your scenario gets richer) objects - per frame! Plus you have no realistic motion (with mass forces, G forces) for the train (and actor, everything inside the train).

It's never good to do too much work per frame. And you now probably have a repeating schema for the trees? I.e. you have no way to get variations in their locations. No (easy) way to get more dense forest, other types of trees, groups of trees, bushes... odd mysterious boxes along the path :-).

Instead, you should use minimeshes for the trees. And work in the domain of 0...1000 meters. Each time your train (and camera) is further away from (0,0,0) than 1000 meters (or TVUnits), move EVERYTHING back to (0,0,0). The train, camera, landscape, minimeshes. As you do it, you just add (1000,0) to a variable called Orig (that holds X,Z). If you go backwards with the train (or actually any X/Z direction), just move accordingly, so Orig may also be e.g. (-3000,4000). Use SetPosition(GetPosition() - deltaOrig). Also SetBodyPosition() accepts that happily.

This way you get a proper coordinate system for the landscape. This allows for sensible management of landscape chunks and all the rest - i.e. seed new trees at surrounding chunks (of e.g. 1000,1000 in size) as the train moves. New trees in chunks ahead, and discard from chunks to forget.

One reason to stay close to (0,0,0) in ALL positioning calculations is indeed also Newton and it's maximum area... was it 10000x10000 by default? Or 30000. Anyway, and this is IMPORTANT: Once your train (and camera) reaches a position of "a few thousand" along X or Z or both, movement becomes CHOPPY. You can see it easily; movement happens in small but increasingly bigger portions, as you get further away from 0.

The reason is that DX works with singles only. 32 bits gives max 7 significant digits and it's apparent that small increments cannot be added to large numbers with that precision. Only when a big enuff number is added (the accumulated movement of several frames) it's actually realized visually - whop, jump! You must get this right from start, otherwise you're doomed.

Another advantage is that you can check the current position only occasionally, say every 10 seconds - no need to do it per frame. If pos is over 1000, re-set everything back to the zero domain. That's only one step, then you have fast business as usual again until the re-positioning is triggered next time, maybe several minutes later.

Are you using Engine.SetFPUPrecision 1? You should do that, otherwise you have only single precision even though you define doubles in code. The doubles will have only 7 significant numbers instead of 14. By using doubles (with SetFPUPrecision 1) you can define exact geographical (absolute) positions accurately, then pass them as needed to Newton (which uses singles) in the (0,0,0) domain. I.e. (AbsolutePosition - Orig) = what you tell Newton.

Well, 5 cents :-)
Logged

Things should be described as simply as possible - but not simpler [A. Einstein]
bbence
Customers
Community Member
*****
Posts: 944


WWW
« Reply #9 on: December 16, 2011, 05:53:51 AM »

Hi!

Actually this is going to a very short level in my FPS, it's not a simulator, so elegance of the solution is not really a must. Smiley

The trees are actually meshes. I will play around with the suggestions, but it's still not really what I want. The attach method did not really work, eg. the original coordinates where not translated into local coordinates for the attached mesh, also the scale was off, so I did not really continue with that approach. The mergemesh approach however still gives these artifacts and glitches, but not only for the tree.
Well, I know that inside mesh alpha sorting is not really going to work well... Problem is that I have windows on both sides, so I cannot manually sort the the meshes in my modeling tool or in the X file.
Logged
Mithrandir_
Moderator
Community Member
*****
Posts: 349


WWW
« Reply #10 on: December 17, 2011, 07:55:46 AM »

Can you make the windows separate meshes?
Logged

jviper
Community Member
*
Posts: 2130

Discipline in training


« Reply #11 on: January 04, 2012, 05:59:30 AM »

I think in this scene all you should have to worry about is making sure your windows get rendered last. Also if you never go outside the train and look in, all you would need is to just render the train last. So first render everthing but the train, then render the train.

TrainMesh.Enable(false)
Scene.Render()
TrainMesh.Enable(true)
TrainMesh.Render()

Renember, the depth buffer does not handle transparency. So if you render somthing transparent before you render what's behind it, your transparent objects will occupy the depth buffer and block anything from being rendered behind it, even though the object is supposed to be see through.
« Last Edit: January 04, 2012, 06:01:03 AM by jviper » Logged

JAbstract.....Don't just imagine, make it happen!
Pages: [1]
  Print  
 
Jump to:  

Powered by SMF 1.1.3 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks